@vaadin/hilla-react-crud 25.1.0 → 25.2.0-alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/autoform-field.js.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +6 -6
- package/util.js +1 -1
- package/util.js.map +1 -1
package/autoform-field.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoform-field.js","sourceRoot":"","sources":["src/autoform-field.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAsD,MAAM,wBAAwB,CAAC;AAEnG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EACL,YAAY,EAEZ,aAAa,EAGb,SAAS,EACT,OAAO,GACR,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AA+H/C,SAAS,gBAAgB,CAAC,IAAwB,EAAE,YAA0B;IAC5E,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;I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KAAK,SAAS;YACZ,OAAO,KAAC,oBAAoB,OAAK,aAAa,GAAyB,CAAC;QAC1E,KAAK,SAAS;YACZ,OAAO,KAAC,oBAAoB,OAAK,aAAa,GAAyB,CAAC;QAC1E,KAAK,MAAM;YACT,OAAO,KAAC,iBAAiB,OAAK,aAAa,GAAsB,CAAC;QACpE,KAAK,MAAM;YACT,OAAO,KAAC,iBAAiB,OAAK,aAAa,GAAsB,CAAC;QACpE,KAAK,UAAU;YACb,OAAO,KAAC,qBAAqB,OAAK,aAAa,GAA0B,CAAC;QAC5E,KAAK,MAAM;YACT,OAAO,KAAC,iBAAiB,OAAK,aAAa,GAAsB,CAAC;QACpE,KAAK,SAAS;YACZ,OAAO,KAAC,oBAAoB,OAAK,aAAa,GAAyB,CAAC;QAC1E,KAAK,QAAQ;YACX,OAAO,KAAC,mBAAmB,OAAK,aAAa,GAAwB,CAAC;QACxE;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC","sourcesContent":["import { _enum, type AbstractModel, type EnumModel, type Validator } from '@vaadin/hilla-lit-form';\nimport type { FieldDirectiveResult, UseFormResult } from '@vaadin/hilla-react-form';\nimport { useFormPart } from '@vaadin/hilla-react-form';\nimport { Checkbox } from '@vaadin/react-components/Checkbox.js';\nimport { DatePicker } from '@vaadin/react-components/DatePicker.js';\nimport { DateTimePicker } from '@vaadin/react-components/DateTimePicker.js';\nimport { IntegerField } from '@vaadin/react-components/IntegerField.js';\nimport { NumberField } from '@vaadin/react-components/NumberField.js';\nimport { Select } from '@vaadin/react-components/Select.js';\nimport { TextArea } from '@vaadin/react-components/TextArea.js';\nimport { TextField } from '@vaadin/react-components/TextField.js';\nimport { TimePicker } from '@vaadin/react-components/TimePicker.js';\nimport {\n cloneElement,\n type ComponentType,\n createElement,\n type CSSProperties,\n type JSX,\n useEffect,\n useMemo,\n} from 'react';\nimport { useDatePickerI18n, useDateTimePickerI18n } from './locale.js';\nimport type { PropertyInfo } from './model-info.js';\nimport { convertToTitleCase } from './util.js';\n\nexport type AutoFormFieldProps = Readonly<{\n propertyInfo: PropertyInfo;\n form: UseFormResult<any>;\n options: FieldOptions;\n disabled?: boolean;\n}>;\n\ntype CustomFormFieldProps = FieldDirectiveResult & Readonly<{ label?: string; disabled?: boolean }>;\n\nexport type FieldOptions = Readonly<{\n /**\n * The id to apply to the field.\n */\n id?: string;\n /**\n * The class names to add to the field.\n */\n className?: string;\n /**\n * The style to apply to the field.\n */\n style?: CSSProperties;\n /**\n * The label to show for the field. If not specified, a human-readable label\n * is generated from the property name.\n */\n label?: string;\n /**\n * The placeholder to when the field is empty.\n *\n * Note that some field types, such as checkbox, do not support a placeholder.\n */\n placeholder?: string;\n /**\n * The helper text to display below the field.\n *\n * Note that some field types, such as checkbox, do not support a helper text.\n */\n helperText?: string;\n /**\n * The number of columns to span. This value is passed to the underlying\n * FormLayout, unless a custom layout is used. In that case, the value is\n * ignored.\n */\n colspan?: number;\n /**\n * Whether the field should be disabled.\n */\n disabled?: boolean;\n /**\n * Whether the field should be readonly.\n */\n readonly?: boolean;\n /**\n * The element to render for the field. This allows customizing field props\n * that are not supported by the field options, or to render a different field\n * component. Other field options are automatically applied to the element,\n * and the element is automatically bound to the form. If not specified, a\n * default field element is rendered based on the property type.\n *\n * The element must be a field component, such as TextField, TextArea,\n * NumberField, etc., otherwise form binding will not work. For more\n * sophisticated customizations, use the `renderer` option.\n *\n * If the field options also specify a renderer function, then the element is\n * ignored.\n *\n * Example enabling the clear button for a text field:\n * ```tsx\n * {\n * element: <TextField clearButtonVisible />\n * }\n * ```\n *\n * Example rendering a text area instead of a text field:\n * ```tsx\n * {\n * element: <TextArea />\n * }\n * ```\n */\n element?: JSX.Element;\n /**\n * Allows to specify a custom renderer for the field, for example to render a\n * custom type of field or apply an additional layout around the field. The\n * renderer receives field props that must be applied to the custom field\n * component in order to connect it to the form.\n *\n * In order to customize one of the default fields, or render a different type\n * of field, consider using the `element` option instead.\n *\n * Example:\n * ```tsx\n * {\n * renderer: ({ field }) => (\n * <div>\n * <TextArea {...field} />\n * <p>Number of words: {calculateNumberOfWords()}</p>\n * </div>\n * )\n * }\n * ```\n */\n renderer?(props: { field: CustomFormFieldProps }): JSX.Element;\n /**\n * Validators to apply to the field. The validators are added to the form\n * when the field is rendered.\n * UseMemo is recommended for the validators, so that they are not recreated\n * on every render.\n */\n validators?: Validator[];\n}>;\n\ntype CommonFieldProps = Pick<\n FieldOptions,\n 'className' | 'colspan' | 'disabled' | 'helperText' | 'id' | 'label' | 'placeholder' | 'readonly' | 'style'\n>;\n\ntype FieldRendererProps = Readonly<{\n model: AbstractModel;\n field: FieldDirectiveResult;\n element?: JSX.Element;\n fieldProps: CommonFieldProps;\n}>;\n\nfunction getPropertyModel(form: UseFormResult<any>, propertyInfo: PropertyInfo) {\n const pathParts = propertyInfo.name.split('.');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return pathParts.reduce<any>((model, property) => (model ? model[property] : undefined), form.model);\n}\n\nfunction renderFieldElement(\n defaultComponentType: ComponentType,\n { element, field, fieldProps }: FieldRendererProps,\n additionalProps: any = {},\n) {\n const fieldElement = element ?? createElement(defaultComponentType);\n return cloneElement(fieldElement, { ...fieldProps, ...additionalProps, ...fieldElement.props, ...field });\n}\n\nfunction AutoFormTextField(props: FieldRendererProps) {\n return renderFieldElement(TextField, props);\n}\n\nfunction AutoFormIntegerField(props: FieldRendererProps) {\n return renderFieldElement(IntegerField, props);\n}\n\nfunction AutoFormDecimalField(props: FieldRendererProps) {\n return renderFieldElement(NumberField, props);\n}\n\nfunction AutoFormDateField(props: FieldRendererProps) {\n const i18n = useDatePickerI18n();\n return renderFieldElement(DatePicker, props, { i18n });\n}\n\nfunction AutoFormTimeField(props: FieldRendererProps) {\n return renderFieldElement(TimePicker, props);\n}\n\nfunction AutoFormDateTimeField(props: FieldRendererProps) {\n const i18n = useDateTimePickerI18n();\n return renderFieldElement(DateTimePicker, props, { i18n });\n}\n\nfunction AutoFormEnumField(props: FieldRendererProps) {\n const enumModel = props.model as EnumModel;\n const items = Object.keys(enumModel[_enum]).map((value) => ({\n label: convertToTitleCase(value),\n value,\n }));\n return renderFieldElement(Select, props, { items });\n}\n\nfunction AutoFormBooleanField(props: FieldRendererProps) {\n return renderFieldElement(Checkbox, props);\n}\n\nfunction AutoFormObjectField({ model, fieldProps }: FieldRendererProps) {\n const part = useFormPart(model);\n const jsonString = part.value ? JSON.stringify(part.value) : '';\n return <TextArea {...fieldProps} value={jsonString} readonly />;\n}\n\nexport function AutoFormField(props: AutoFormFieldProps): JSX.Element | null {\n const { form, propertyInfo, options } = props;\n const label = options.label ?? propertyInfo.humanReadableName;\n const model = getPropertyModel(form, propertyInfo);\n const field = form.field(model);\n\n const formPart = useFormPart(model);\n const defaultValidators = useMemo(() => formPart.validators, []);\n const { validators } = options;\n useEffect(() => {\n formPart.setValidators([...defaultValidators, ...(validators ?? [])]);\n }, [validators]);\n\n if (options.renderer) {\n const customFieldProps = { ...field, disabled: props.disabled, label };\n return options.renderer({ field: customFieldProps });\n }\n\n const fieldProps: CommonFieldProps = {\n id: options.id,\n className: options.className,\n style: options.style,\n label,\n placeholder: options.placeholder,\n helperText: options.helperText,\n colspan: options.colspan,\n disabled: options.disabled ?? props.disabled,\n readonly: options.readonly,\n };\n\n const rendererProps: FieldRendererProps = { model, field, element: options.element, fieldProps };\n\n switch (props.propertyInfo.type) {\n case 'string':\n return <AutoFormTextField {...rendererProps}></AutoFormTextField>;\n case 'integer':\n return <AutoFormIntegerField {...rendererProps}></AutoFormIntegerField>;\n case 'decimal':\n return <AutoFormDecimalField {...rendererProps}></AutoFormDecimalField>;\n case 'date':\n return <AutoFormDateField {...rendererProps}></AutoFormDateField>;\n case 'time':\n return <AutoFormTimeField {...rendererProps}></AutoFormTimeField>;\n case 'datetime':\n return <AutoFormDateTimeField {...rendererProps}></AutoFormDateTimeField>;\n case 'enum':\n return <AutoFormEnumField {...rendererProps}></AutoFormEnumField>;\n case 'boolean':\n return <AutoFormBooleanField {...rendererProps}></AutoFormBooleanField>;\n case 'object':\n return <AutoFormObjectField {...rendererProps}></AutoFormObjectField>;\n default:\n return null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"autoform-field.js","sourceRoot":"","sources":["src/autoform-field.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAsD,MAAM,wBAAwB,CAAC;AAEnG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EACL,YAAY,EAEZ,aAAa,EAGb,SAAS,EACT,OAAO,GACR,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AA+H/C,SAAS,gBAAgB,CAAC,IAAwB,EAAE,YAA0B;IAC5E,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE/C,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,QAAgB,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,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,iBAAiB,OAAK,aAAa,GAAsB,CAAC;QACpE,KAAK,MAAM;YACT,OAAO,KAAC,iBAAiB,OAAK,aAAa,GAAsB,CAAC;QACpE,KAAK,UAAU;YACb,OAAO,KAAC,qBAAqB,OAAK,aAAa,GAA0B,CAAC;QAC5E,KAAK,MAAM;YACT,OAAO,KAAC,iBAAiB,OAAK,aAAa,GAAsB,CAAC;QACpE,KAAK,SAAS;YACZ,OAAO,KAAC,oBAAoB,OAAK,aAAa,GAAyB,CAAC;QAC1E,KAAK,QAAQ;YACX,OAAO,KAAC,mBAAmB,OAAK,aAAa,GAAwB,CAAC;QACxE;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC","sourcesContent":["import { _enum, type AbstractModel, type EnumModel, type Validator } from '@vaadin/hilla-lit-form';\nimport type { FieldDirectiveResult, UseFormResult } from '@vaadin/hilla-react-form';\nimport { useFormPart } from '@vaadin/hilla-react-form';\nimport { Checkbox } from '@vaadin/react-components/Checkbox.js';\nimport { DatePicker } from '@vaadin/react-components/DatePicker.js';\nimport { DateTimePicker } from '@vaadin/react-components/DateTimePicker.js';\nimport { IntegerField } from '@vaadin/react-components/IntegerField.js';\nimport { NumberField } from '@vaadin/react-components/NumberField.js';\nimport { Select } from '@vaadin/react-components/Select.js';\nimport { TextArea } from '@vaadin/react-components/TextArea.js';\nimport { TextField } from '@vaadin/react-components/TextField.js';\nimport { TimePicker } from '@vaadin/react-components/TimePicker.js';\nimport {\n cloneElement,\n type ComponentType,\n createElement,\n type CSSProperties,\n type JSX,\n useEffect,\n useMemo,\n} from 'react';\nimport { useDatePickerI18n, useDateTimePickerI18n } from './locale.js';\nimport type { PropertyInfo } from './model-info.js';\nimport { convertToTitleCase } from './util.js';\n\nexport type AutoFormFieldProps = Readonly<{\n propertyInfo: PropertyInfo;\n form: UseFormResult<any>;\n options: FieldOptions;\n disabled?: boolean;\n}>;\n\ntype CustomFormFieldProps = FieldDirectiveResult & Readonly<{ label?: string; disabled?: boolean }>;\n\nexport type FieldOptions = Readonly<{\n /**\n * The id to apply to the field.\n */\n id?: string;\n /**\n * The class names to add to the field.\n */\n className?: string;\n /**\n * The style to apply to the field.\n */\n style?: CSSProperties;\n /**\n * The label to show for the field. If not specified, a human-readable label\n * is generated from the property name.\n */\n label?: string;\n /**\n * The placeholder to when the field is empty.\n *\n * Note that some field types, such as checkbox, do not support a placeholder.\n */\n placeholder?: string;\n /**\n * The helper text to display below the field.\n *\n * Note that some field types, such as checkbox, do not support a helper text.\n */\n helperText?: string;\n /**\n * The number of columns to span. This value is passed to the underlying\n * FormLayout, unless a custom layout is used. In that case, the value is\n * ignored.\n */\n colspan?: number;\n /**\n * Whether the field should be disabled.\n */\n disabled?: boolean;\n /**\n * Whether the field should be readonly.\n */\n readonly?: boolean;\n /**\n * The element to render for the field. This allows customizing field props\n * that are not supported by the field options, or to render a different field\n * component. Other field options are automatically applied to the element,\n * and the element is automatically bound to the form. If not specified, a\n * default field element is rendered based on the property type.\n *\n * The element must be a field component, such as TextField, TextArea,\n * NumberField, etc., otherwise form binding will not work. For more\n * sophisticated customizations, use the `renderer` option.\n *\n * If the field options also specify a renderer function, then the element is\n * ignored.\n *\n * Example enabling the clear button for a text field:\n * ```tsx\n * {\n * element: <TextField clearButtonVisible />\n * }\n * ```\n *\n * Example rendering a text area instead of a text field:\n * ```tsx\n * {\n * element: <TextArea />\n * }\n * ```\n */\n element?: JSX.Element;\n /**\n * Allows to specify a custom renderer for the field, for example to render a\n * custom type of field or apply an additional layout around the field. The\n * renderer receives field props that must be applied to the custom field\n * component in order to connect it to the form.\n *\n * In order to customize one of the default fields, or render a different type\n * of field, consider using the `element` option instead.\n *\n * Example:\n * ```tsx\n * {\n * renderer: ({ field }) => (\n * <div>\n * <TextArea {...field} />\n * <p>Number of words: {calculateNumberOfWords()}</p>\n * </div>\n * )\n * }\n * ```\n */\n renderer?(props: { field: CustomFormFieldProps }): JSX.Element;\n /**\n * Validators to apply to the field. The validators are added to the form\n * when the field is rendered.\n * UseMemo is recommended for the validators, so that they are not recreated\n * on every render.\n */\n validators?: Validator[];\n}>;\n\ntype CommonFieldProps = Pick<\n FieldOptions,\n 'className' | 'colspan' | 'disabled' | 'helperText' | 'id' | 'label' | 'placeholder' | 'readonly' | 'style'\n>;\n\ntype FieldRendererProps = Readonly<{\n model: AbstractModel;\n field: FieldDirectiveResult;\n element?: JSX.Element;\n fieldProps: CommonFieldProps;\n}>;\n\nfunction getPropertyModel(form: UseFormResult<any>, propertyInfo: PropertyInfo) {\n const pathParts = propertyInfo.name.split('.');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n return pathParts.reduce((model: any, property: string) => (model ? model[property] : undefined), form.model);\n}\n\nfunction renderFieldElement(\n defaultComponentType: ComponentType,\n { element, field, fieldProps }: FieldRendererProps,\n additionalProps: any = {},\n) {\n const fieldElement = element ?? createElement(defaultComponentType);\n return cloneElement(fieldElement, { ...fieldProps, ...additionalProps, ...fieldElement.props, ...field });\n}\n\nfunction AutoFormTextField(props: FieldRendererProps) {\n return renderFieldElement(TextField, props);\n}\n\nfunction AutoFormIntegerField(props: FieldRendererProps) {\n return renderFieldElement(IntegerField, props);\n}\n\nfunction AutoFormDecimalField(props: FieldRendererProps) {\n return renderFieldElement(NumberField, props);\n}\n\nfunction AutoFormDateField(props: FieldRendererProps) {\n const i18n = useDatePickerI18n();\n return renderFieldElement(DatePicker, props, { i18n });\n}\n\nfunction AutoFormTimeField(props: FieldRendererProps) {\n return renderFieldElement(TimePicker, props);\n}\n\nfunction AutoFormDateTimeField(props: FieldRendererProps) {\n const i18n = useDateTimePickerI18n();\n return renderFieldElement(DateTimePicker, props, { i18n });\n}\n\nfunction AutoFormEnumField(props: FieldRendererProps) {\n const enumModel = props.model as EnumModel;\n const items = Object.keys(enumModel[_enum]).map((value) => ({\n label: convertToTitleCase(value),\n value,\n }));\n return renderFieldElement(Select, props, { items });\n}\n\nfunction AutoFormBooleanField(props: FieldRendererProps) {\n return renderFieldElement(Checkbox, props);\n}\n\nfunction AutoFormObjectField({ model, fieldProps }: FieldRendererProps) {\n const part = useFormPart(model);\n const jsonString = part.value ? JSON.stringify(part.value) : '';\n return <TextArea {...fieldProps} value={jsonString} readonly />;\n}\n\nexport function AutoFormField(props: AutoFormFieldProps): JSX.Element | null {\n const { form, propertyInfo, options } = props;\n const label = options.label ?? propertyInfo.humanReadableName;\n const model = getPropertyModel(form, propertyInfo);\n const field = form.field(model);\n\n const formPart = useFormPart(model);\n const defaultValidators = useMemo(() => formPart.validators, []);\n const { validators } = options;\n useEffect(() => {\n formPart.setValidators([...defaultValidators, ...(validators ?? [])]);\n }, [validators]);\n\n if (options.renderer) {\n const customFieldProps = { ...field, disabled: props.disabled, label };\n return options.renderer({ field: customFieldProps });\n }\n\n const fieldProps: CommonFieldProps = {\n id: options.id,\n className: options.className,\n style: options.style,\n label,\n placeholder: options.placeholder,\n helperText: options.helperText,\n colspan: options.colspan,\n disabled: options.disabled ?? props.disabled,\n readonly: options.readonly,\n };\n\n const rendererProps: FieldRendererProps = { model, field, element: options.element, fieldProps };\n\n switch (props.propertyInfo.type) {\n case 'string':\n return <AutoFormTextField {...rendererProps}></AutoFormTextField>;\n case 'integer':\n return <AutoFormIntegerField {...rendererProps}></AutoFormIntegerField>;\n case 'decimal':\n return <AutoFormDecimalField {...rendererProps}></AutoFormDecimalField>;\n case 'date':\n return <AutoFormDateField {...rendererProps}></AutoFormDateField>;\n case 'time':\n return <AutoFormTimeField {...rendererProps}></AutoFormTimeField>;\n case 'datetime':\n return <AutoFormDateTimeField {...rendererProps}></AutoFormDateTimeField>;\n case 'enum':\n return <AutoFormEnumField {...rendererProps}></AutoFormEnumField>;\n case 'boolean':\n return <AutoFormBooleanField {...rendererProps}></AutoFormBooleanField>;\n case 'object':\n return <AutoFormObjectField {...rendererProps}></AutoFormObjectField>;\n default:\n return null;\n }\n}\n"]}
|
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export { useDataProvider, useGridDataProvider, useComboBoxDataProvider } from '.
|
|
|
6
6
|
vaadinObj.registrations ??= [];
|
|
7
7
|
vaadinObj.registrations.push({
|
|
8
8
|
is: feature ? `@vaadin/hilla-react-crud/${feature}` : '@vaadin/hilla-react-crud',
|
|
9
|
-
version: '25.
|
|
9
|
+
version: '25.2.0-alpha1',
|
|
10
10
|
});
|
|
11
11
|
})();
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AAEtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAInG,CAAC,CAAC,OAAO,EAAE,SAAS,GAAG,CAAC,UAAU,CAAC,MAAM,KAAK,EAAE,CAAC,EAAE,EAAE;IACnD,SAAS,CAAC,aAAa,KAAK,EAAE,CAAC;IAC/B,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC;QAC3B,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,4BAA4B,OAAO,EAAE,CAAC,CAAC,CAAC,0BAA0B;QAChF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AAEtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAInG,CAAC,CAAC,OAAO,EAAE,SAAS,GAAG,CAAC,UAAU,CAAC,MAAM,KAAK,EAAE,CAAC,EAAE,EAAE;IACnD,SAAS,CAAC,aAAa,KAAK,EAAE,CAAC;IAC/B,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC;QAC3B,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,4BAA4B,OAAO,EAAE,CAAC,CAAC,CAAC,0BAA0B;QAChF,OAAO,EAAE,eAAe;KACzB,CAAC,CAAC;AACL,CAAC,CAAC,EAAE,CAAC","sourcesContent":["export * from './autogrid-feature.js';\nexport type * from './crud.js';\nexport * from './autoform-feature.js';\nexport * from './autocrud-feature.js';\nexport { useDataProvider, useGridDataProvider, useComboBoxDataProvider } from './data-provider.js';\n\n// @ts-expect-error: esbuild injection\n// eslint-disable-next-line @typescript-eslint/no-unsafe-call\n((feature, vaadinObj = (globalThis.Vaadin ??= {})) => {\n vaadinObj.registrations ??= [];\n vaadinObj.registrations.push({\n is: feature ? `@vaadin/hilla-react-crud/${feature}` : '@vaadin/hilla-react-crud',\n version: '25.2.0-alpha1',\n });\n})();\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/hilla-react-crud",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.2.0-alpha1",
|
|
4
4
|
"description": "Hilla CRUD utils for React",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@vaadin/hilla-frontend": "25.
|
|
58
|
-
"@vaadin/hilla-lit-form": "25.
|
|
59
|
-
"@vaadin/hilla-react-form": "25.
|
|
60
|
-
"@vaadin/vaadin-lumo-styles": "25.
|
|
61
|
-
"@vaadin/react-components": "25.
|
|
57
|
+
"@vaadin/hilla-frontend": "25.2.0-alpha1",
|
|
58
|
+
"@vaadin/hilla-lit-form": "25.2.0-alpha1",
|
|
59
|
+
"@vaadin/hilla-react-form": "25.2.0-alpha1",
|
|
60
|
+
"@vaadin/vaadin-lumo-styles": "25.2.0-alpha5",
|
|
61
|
+
"@vaadin/react-components": "25.2.0-alpha5",
|
|
62
62
|
"type-fest": "4.35.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
package/util.js
CHANGED
|
@@ -24,7 +24,7 @@ function useFeatureRegistration(feature) {
|
|
|
24
24
|
vaadinObj.registrations ??= [];
|
|
25
25
|
vaadinObj.registrations.push({
|
|
26
26
|
is: feature ? `@vaadin/hilla-react-crud/${feature}` : '@vaadin/hilla-react-crud',
|
|
27
|
-
version: '25.
|
|
27
|
+
version: '25.2.0-alpha1',
|
|
28
28
|
});
|
|
29
29
|
})(feature);
|
|
30
30
|
}
|
package/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["src/util.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAsB,UAAU,EAAE,MAAM,OAAO,CAAC;AAS9D,MAAM,UAAU,kBAAkB,CAAC,WAAmB;IAEpD,MAAM,gBAAgB,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAGzD,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1C,MAAM,cAAc,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IAGvG,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,UAAyB;IAC1D,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;SACxC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;SAC3B,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,C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AAC;IACrD,CAAC,CAAiB,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAmB;IAC/C,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,KAAK,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;QAC1D,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAoB,CAAC,CAAC,CAAC;IAC/E,CAAC;IACD,IAAI,aAAa,IAAI,MAAM,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC,WAAW,KAAK,EAAE,CAAC;IACnC,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,wBAAwB,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAC3G,CAAC","sourcesContent":["import React, { type CSSProperties, forwardRef } from 'react';\nimport type FilterUnion from './types/com/vaadin/hilla/crud/filter/FilterUnion.js';\n\nexport type ComponentStyleProps = Readonly<{\n id?: string;\n style?: CSSProperties;\n className?: string;\n}>;\n\nexport function convertToTitleCase(inputString: string): string {\n // Convert underscores to spaces\n const stringWithSpaces = inputString.replace(/_/gu, ' ');\n\n // Convert to title case\n const words = stringWithSpaces.split(' ');\n const titleCaseWords = words.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase());\n\n // Join the title case words with spaces\n return titleCaseWords.join(' ');\n}\n\nexport function registerStylesheet(stylesheet: CSSStyleSheet): void {\n const css = Array.from(stylesheet.cssRules)\n .map((rule) => rule.cssText)\n .join('\\n');\n\n const styleTag = document.createElement('style');\n styleTag.textContent = css;\n document.head.prepend(styleTag);\n}\n\nconst registeredFeatures = new Set<string>();\nfunction useFeatureRegistration(feature: string): void {\n if (registeredFeatures.has(feature)) {\n return;\n }\n\n registeredFeatures.add(feature);\n // @ts-expect-error: esbuild injection\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n ((feature, vaadinObj = (globalThis.Vaadin ??= {})) => {\n vaadinObj.registrations ??= [];\n vaadinObj.registrations.push({\n is: feature ? `@vaadin/hilla-react-crud/${feature}` : '@vaadin/hilla-react-crud',\n version: '25.2.0-alpha1',\n });\n})(feature);\n}\n\nexport function featureRegistration<C extends (...args: any[]) => any>(Component: C, feature: string): C {\n return forwardRef<unknown, React.JSX.LibraryManagedAttributes<C, NonNullable<unknown>>>((props, ref) => {\n useFeatureRegistration(feature);\n return <Component {...(props as any)} ref={ref} />;\n }) as unknown as C;\n}\n\nexport function isFilterEmpty(filter: FilterUnion): boolean {\n if (filter['@type'] === 'and' || filter['@type'] === 'or') {\n if (filter.children.length === 0) {\n return true;\n }\n return filter.children.every((child) => isFilterEmpty(child as FilterUnion));\n }\n if ('filterValue' in filter) {\n return filter.filterValue === '';\n }\n throw new Error(`Unknown filter type: ${'@type' in filter ? filter['@type'] : JSON.stringify(filter)} `);\n}\n"]}
|