138 lines
6.0 KiB
JavaScript
138 lines
6.0 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.primitiveOverrideProp = exports.PRIMITIVE_OVERRIDE_PROPS = exports.PrimitiveTypeParameter = exports.isPrimitive = exports.PrimitiveDefaultPropertyValue = exports.PrimitiveChildrenPropMapping = exports.PrimitivesWithChangeEvent = exports.Primitive = void 0;
|
|
const typescript_1 = require("typescript");
|
|
var Primitive;
|
|
(function (Primitive) {
|
|
Primitive["Alert"] = "Alert";
|
|
Primitive["Badge"] = "Badge";
|
|
Primitive["Button"] = "Button";
|
|
Primitive["ButtonGroup"] = "ButtonGroup";
|
|
Primitive["Card"] = "Card";
|
|
Primitive["CheckboxField"] = "CheckboxField";
|
|
Primitive["Collection"] = "Collection";
|
|
Primitive["Divider"] = "Divider";
|
|
Primitive["Expander"] = "Expander";
|
|
Primitive["ExpanderItem"] = "ExpanderItem";
|
|
Primitive["Flex"] = "Flex";
|
|
Primitive["Grid"] = "Grid";
|
|
Primitive["Heading"] = "Heading";
|
|
Primitive["Icon"] = "Icon";
|
|
Primitive["Image"] = "Image";
|
|
Primitive["Link"] = "Link";
|
|
Primitive["Loader"] = "Loader";
|
|
Primitive["Menu"] = "Menu";
|
|
Primitive["MenuButton"] = "MenuButton";
|
|
Primitive["MenuItem"] = "MenuItem";
|
|
Primitive["Pagination"] = "Pagination";
|
|
Primitive["PasswordField"] = "PasswordField";
|
|
Primitive["PhoneNumberField"] = "PhoneNumberField";
|
|
Primitive["Placeholder"] = "Placeholder";
|
|
Primitive["Radio"] = "Radio";
|
|
Primitive["RadioGroupField"] = "RadioGroupField";
|
|
Primitive["Rating"] = "Rating";
|
|
Primitive["ScrollView"] = "ScrollView";
|
|
Primitive["SearchField"] = "SearchField";
|
|
Primitive["SelectField"] = "SelectField";
|
|
Primitive["SliderField"] = "SliderField";
|
|
Primitive["StepperField"] = "StepperField";
|
|
Primitive["SwitchField"] = "SwitchField";
|
|
Primitive["Table"] = "Table";
|
|
Primitive["TableBody"] = "TableBody";
|
|
Primitive["TableCell"] = "TableCell";
|
|
Primitive["TableFoot"] = "TableFoot";
|
|
Primitive["TableHead"] = "TableHead";
|
|
Primitive["TableRow"] = "TableRow";
|
|
Primitive["Tabs"] = "Tabs";
|
|
Primitive["TabItem"] = "TabItem";
|
|
Primitive["Text"] = "Text";
|
|
Primitive["TextAreaField"] = "TextAreaField";
|
|
Primitive["TextField"] = "TextField";
|
|
Primitive["ToggleButton"] = "ToggleButton";
|
|
Primitive["ToggleButtonGroup"] = "ToggleButtonGroup";
|
|
Primitive["View"] = "View";
|
|
Primitive["VisuallyHidden"] = "VisuallyHidden";
|
|
Primitive["Autocomplete"] = "Autocomplete";
|
|
})(Primitive = exports.Primitive || (exports.Primitive = {}));
|
|
/*
|
|
* temporary list of Primitives with a change event. Final implementation will pull from amplify UI
|
|
*/
|
|
exports.PrimitivesWithChangeEvent = new Set([
|
|
Primitive.CheckboxField,
|
|
Primitive.PasswordField,
|
|
Primitive.PhoneNumberField,
|
|
Primitive.RadioGroupField,
|
|
Primitive.SearchField,
|
|
Primitive.SelectField,
|
|
Primitive.SliderField,
|
|
Primitive.StepperField,
|
|
Primitive.SwitchField,
|
|
Primitive.TextAreaField,
|
|
Primitive.TextField,
|
|
]);
|
|
exports.PrimitiveChildrenPropMapping = {
|
|
[Primitive.Alert]: 'label',
|
|
[Primitive.Badge]: 'label',
|
|
[Primitive.Button]: 'label',
|
|
[Primitive.Heading]: 'label',
|
|
[Primitive.Link]: 'label',
|
|
[Primitive.MenuButton]: 'label',
|
|
[Primitive.MenuItem]: 'label',
|
|
[Primitive.Radio]: 'label',
|
|
[Primitive.TableCell]: 'label',
|
|
[Primitive.Text]: 'label',
|
|
[Primitive.ToggleButton]: 'label',
|
|
};
|
|
exports.PrimitiveDefaultPropertyValue = {
|
|
[Primitive.CheckboxField]: {
|
|
checked: { value: false, type: 'boolean' },
|
|
},
|
|
[Primitive.PasswordField]: {
|
|
value: { value: '', type: 'string' },
|
|
},
|
|
[Primitive.PhoneNumberField]: {
|
|
value: { value: '', type: 'string' },
|
|
},
|
|
[Primitive.RadioGroupField]: {
|
|
value: { value: '', type: 'string' },
|
|
},
|
|
[Primitive.SearchField]: {
|
|
value: { value: '', type: 'string' },
|
|
},
|
|
[Primitive.SwitchField]: {
|
|
isChecked: { value: false, type: 'boolean' },
|
|
},
|
|
[Primitive.TextAreaField]: {
|
|
value: { value: '', type: 'string' },
|
|
},
|
|
[Primitive.TextField]: {
|
|
value: { value: '', type: 'string' },
|
|
},
|
|
};
|
|
function isPrimitive(componentType) {
|
|
return Object.values(Primitive).includes(componentType);
|
|
}
|
|
exports.isPrimitive = isPrimitive;
|
|
exports.PrimitiveTypeParameter = {
|
|
[Primitive.TextField]: {
|
|
declaration: () => [
|
|
typescript_1.factory.createTypeParameterDeclaration(typescript_1.factory.createIdentifier('Multiline'), typescript_1.factory.createKeywordTypeNode(typescript_1.SyntaxKind.BooleanKeyword), undefined),
|
|
],
|
|
reference: () => [typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createIdentifier('Multiline'), undefined)],
|
|
},
|
|
[Primitive.Collection]: {
|
|
declaration: () => undefined,
|
|
reference: () => [typescript_1.factory.createKeywordTypeNode(typescript_1.SyntaxKind.AnyKeyword)],
|
|
},
|
|
};
|
|
exports.PRIMITIVE_OVERRIDE_PROPS = 'PrimitiveOverrideProps';
|
|
/**
|
|
* export declare type PrimitiveOverrideProp<T> = Partial<T> & React.DOMAttributes<HTMLDivElement>;
|
|
*/
|
|
exports.primitiveOverrideProp = typescript_1.factory.createTypeAliasDeclaration(undefined, [typescript_1.factory.createModifier(typescript_1.SyntaxKind.ExportKeyword), typescript_1.factory.createModifier(typescript_1.SyntaxKind.DeclareKeyword)], typescript_1.factory.createIdentifier(exports.PRIMITIVE_OVERRIDE_PROPS), [typescript_1.factory.createTypeParameterDeclaration(typescript_1.factory.createIdentifier('T'), undefined, undefined)], typescript_1.factory.createIntersectionTypeNode([
|
|
typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createIdentifier('Partial'), [
|
|
typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createIdentifier('T'), undefined),
|
|
]),
|
|
typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createQualifiedName(typescript_1.factory.createIdentifier('React'), typescript_1.factory.createIdentifier('DOMAttributes')), [typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createIdentifier('HTMLDivElement'), undefined)]),
|
|
]));
|
|
//# sourceMappingURL=primitive.js.map
|