@limetech/lime-elements 37.58.0 → 37.59.0
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/CHANGELOG.md +13 -0
- package/dist/cjs/limel-form.cjs.entry.js +106 -59
- package/dist/cjs/limel-form.cjs.entry.js.map +1 -1
- package/dist/collection/components/form/fields/schema-field.js +4 -0
- package/dist/collection/components/form/fields/schema-field.js.map +1 -1
- package/dist/collection/components/form/widgets/date-only-picker.js +24 -0
- package/dist/collection/components/form/widgets/date-only-picker.js.map +1 -0
- package/dist/collection/components/form/widgets/date-picker.js +15 -11
- package/dist/collection/components/form/widgets/date-picker.js.map +1 -1
- package/dist/collection/components/form/widgets/index.js +2 -1
- package/dist/collection/components/form/widgets/index.js.map +1 -1
- package/dist/collection/components/form/widgets/time-picker.js +23 -0
- package/dist/collection/components/form/widgets/time-picker.js.map +1 -0
- package/dist/esm/limel-form.entry.js +106 -59
- package/dist/esm/limel-form.entry.js.map +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/{p-b3b87ff5.entry.js → p-5de66206.entry.js} +5 -5
- package/dist/lime-elements/p-5de66206.entry.js.map +1 -0
- package/dist/types/components/form/widgets/date-only-picker.d.ts +4 -0
- package/dist/types/components/form/widgets/time-picker.d.ts +4 -0
- package/package.json +2 -2
- package/dist/lime-elements/p-b3b87ff5.entry.js.map +0 -1
|
@@ -5,6 +5,7 @@ import { isEmpty, capitalize } from 'lodash-es';
|
|
|
5
5
|
import { resetDependentFields } from './field-helpers';
|
|
6
6
|
import { FieldTemplate } from '../templates';
|
|
7
7
|
import { getHelpComponent } from '../help';
|
|
8
|
+
import { TimePicker } from '../widgets/time-picker';
|
|
8
9
|
/**
|
|
9
10
|
* If given a value and schema, check if the value should be translated
|
|
10
11
|
* from null to undefined to avoid issues with validation
|
|
@@ -179,6 +180,9 @@ export class SchemaField extends React.Component {
|
|
|
179
180
|
return this.renderCustomComponent(this.props);
|
|
180
181
|
}
|
|
181
182
|
const fieldProps = Object.assign(Object.assign({}, this.props), { onChange: this.handleChange });
|
|
183
|
+
if (this.props.schema.format === 'time') {
|
|
184
|
+
fieldProps.uiSchema = Object.assign({ 'ui:widget': TimePicker }, fieldProps.uiSchema);
|
|
185
|
+
}
|
|
182
186
|
return React.createElement(JSONSchemaField, fieldProps);
|
|
183
187
|
}
|
|
184
188
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-field.js","sourceRoot":"","sources":["../../../../src/components/form/fields/schema-field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,eAAe,MAAM,8CAA8C,CAAC;AAC3E,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAG3C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,uBAAuB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAW,EAAE;EACvD,OAAO,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC3D,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAW,EAAE;;EAC3C,MAAM,IAAI,GAAG,MAAA,MAAA,MAAM,CAAC,IAAI,0CAAE,SAAS,0CAAE,IAAI,CAAC;EAC1C,IAAI,CAAC,IAAI,EAAE;IACP,OAAO,KAAK,CAAC;GAChB;EAED,IAAI;IACA,8BAA8B,CAAC,IAAI,CAAC,CAAC;GACxC;EAAC,WAAM;IACJ,sCAAsC;IACtC,OAAO,CAAC,IAAI,CAAC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tC;MACD,MAAM,EAAE;QACJ,MAAM,EAAE,IAAI,CAAC,2BAA2B;OAC3C;KACJ,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC,aAAa,CACtB,aAAa,kCAEN,IAAI,CAAC,KAAK,KACb,UAAU,EAAE,+BAA+B,KAE/C,SAAS,EACT,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,CACjC,CAAC;EACN,CAAC;EAED,MAAM;IACF,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;MACvC,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACjD;IAED,MAAM,UAAU,mCACT,IAAI,CAAC,KAAK,KACb,QAAQ,EAAE,IAAI,CAAC,YAAY,GAC9B,CAAC;IAEF,OAAO,KAAK,CAAC,aAAa,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;EAC5D,CAAC;EAED;;;;;;;;;KASG;EACK,aAAa,CAAC,QAAgB;IAClC,IAAI,QAAQ,KAAK,SAAS,EAAE;MACxB,OAAO,SAAS,CAAC;KACpB;IAED,OAAO,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;EACpD,CAAC;CACJ","sourcesContent":["import { LimeElementsAdapter } from '../adapters';\nimport JSONSchemaField from '@rjsf/core/lib/components/fields/SchemaField';\nimport React from 'react';\nimport { FieldProps } from './types';\nimport { isEmpty, capitalize } from 'lodash-es';\nimport { resetDependentFields } from './field-helpers';\nimport { FieldTemplate } from '../templates';\nimport { getHelpComponent } from '../help';\nimport { FormSchema } from '../form.types';\n\n/**\n * If given a value and schema, check if the value should be translated\n * from null to undefined to avoid issues with validation\n *\n * This function needs to be used for several reasons:\n * 1. CustomEvent does not allow `detail` to equal `undefined`, but we can call onChange with `undefined` in React\n * 2. `null` is treated as a valid value in a jsonschema and with marshmallow and it has its own type (null)\n * 3. Without changing `null` to `undefined` there would be no way to remove a field from\n * from the submitted form data once it had any data. (when POSTing, undefined is not posted since its not valid json)\n * 4. The only applies to custom web components since widgets handle transforming null/'' to undefined depending on the widget\n * and its purpose.\n *\n * Example:\n * If I have an object `{ name?: string, email?: string }` that I am using a custom web component for `name`,\n * then initially, the formData will be `{}` which is fine because neither name or email are required. Then if i input a\n * value for name the formData will be `{ name: 'some_value' }` which is also fine. But then if I want to remove name\n * from the form data I would delete all the text from the name input field. Web components would emit this empty value\n * as '' or null. If the web component tries to emit `undefined`, null would be emitted instead because CustomEvent has\n * a default `detail` value of null\n *\n * @param value - the value associated with the schema\n * @param schema - the schema for the value\n * @returns whether or not null should be changed to undefined\n */\nconst shouldChangeToUndefined = (value, schema): boolean => {\n return value === null && !schema.type.includes('null');\n};\n\nconst hasCustomComponent = (schema): boolean => {\n const name = schema.lime?.component?.name;\n if (!name) {\n return false;\n }\n\n try {\n verifyCustomComponentIsDefined(name);\n } catch {\n // eslint-disable-next-line no-console\n console.warn(`Custom component ${name} not defined`);\n\n return false;\n }\n\n return true;\n};\n\nconst verifyCustomComponentIsDefined = (elementName): void => {\n const supportsCustomElements = 'customElements' in window;\n\n if (!supportsCustomElements) {\n throw new Error(\n 'Custom form elements are not supported by this browser!',\n );\n }\n\n if (!customElements.get(elementName)) {\n throw new Error(`Custom form element '${elementName}' is not defined!`);\n }\n};\n\nconst getCustomComponent = (\n schema,\n): { name: string; props: { [key: string]: any } } => {\n const name = schema.lime?.component?.name;\n const props = schema.lime?.component?.props || {};\n\n return { name: name, props: props };\n};\n\n/**\n * Create properties from the factory that is set on `limel-form`\n *\n * @param formContext - the form context\n * @param schema - the schema for the current field\n * @returns the properties created by the factory\n */\nexport function getFactoryProps(\n formContext: any,\n schema: FormSchema,\n): Record<string, any> {\n const factory: (schema: FormSchema) => Record<string, any> =\n formContext.propsFactory;\n if (typeof factory !== 'function') {\n return {};\n }\n\n const props = factory(schema);\n if (!props) {\n return {};\n }\n\n return props;\n}\n\nexport class SchemaField extends React.Component<FieldProps> {\n state = {\n modified: false,\n };\n\n constructor(props) {\n super(props);\n this.handleChange = this.handleChange.bind(this);\n this.handleCustomComponentChange =\n this.handleCustomComponentChange.bind(this);\n }\n\n private hasValue() {\n const value = this.getValue();\n if (!value) {\n return false;\n }\n\n if (Array.isArray(value)) {\n return !!value.length;\n }\n\n if (typeof value === 'object') {\n return !isEmpty(value);\n }\n\n return true;\n }\n\n private getLabel() {\n const { schema } = this.props;\n\n return schema.title;\n }\n\n private isInvalid() {\n const { modified } = this.state;\n const { errorSchema } = this.props;\n\n return (\n (modified || this.hasValue() || !this.isRequired()) &&\n !isEmpty(errorSchema)\n );\n }\n\n private isRequired() {\n const { required, schema } = this.props;\n\n return required || schema.minItems > 0;\n }\n\n private getHelperText() {\n const { errorSchema, schema } = this.props;\n\n if (!this.isInvalid()) {\n const helperText = schema.lime?.component?.props?.helperText;\n\n return helperText || schema.description;\n }\n\n if (!isEmpty(errorSchema) && '__errors' in errorSchema) {\n return capitalize(errorSchema.__errors[0]); // eslint-disable-line no-underscore-dangle\n }\n\n return schema.description;\n }\n\n private getValue() {\n const { formData } = this.props;\n\n return formData;\n }\n\n private handleCustomComponentChange(event) {\n const { schema } = this.props;\n event.stopPropagation();\n\n let value = event.detail;\n\n if (shouldChangeToUndefined(value, schema)) {\n value = undefined;\n }\n\n this.handleChange(value);\n }\n\n private handleChange(data) {\n const { formData, schema } = this.props;\n const { rootSchema } = this.props.registry;\n\n this.setState({ modified: true });\n\n const newData = resetDependentFields(\n formData,\n data,\n schema,\n rootSchema,\n );\n\n this.props.onChange(newData);\n }\n\n private buildCustomComponentProps() {\n const {\n disabled,\n readonly,\n name,\n registry,\n schema,\n errorSchema,\n idSchema,\n } = this.props;\n const factoryProps = getFactoryProps(registry.formContext, schema);\n\n return {\n ...factoryProps,\n value: this.getValue(),\n required: this.isRequired(),\n readonly: readonly || schema.readOnly,\n disabled: disabled,\n invalid: this.isInvalid(),\n label: this.getLabel(),\n helperText: this.getHelperText(),\n formInfo: {\n schema: schema,\n rootSchema: registry.formContext.schema,\n errorSchema: errorSchema,\n rootValue: registry.formContext.rootValue,\n name: name,\n schemaPath: this.getSchemaPath(idSchema?.$id),\n },\n };\n }\n\n private renderCustomComponent(props: FieldProps) {\n const { name, props: userDefinedComponentProps } = getCustomComponent(\n props.schema,\n );\n\n verifyCustomComponentIsDefined(name);\n\n const component = React.createElement(LimeElementsAdapter, {\n name: name,\n elementProps: {\n ...userDefinedComponentProps,\n ...this.buildCustomComponentProps(),\n },\n events: {\n change: this.handleCustomComponentChange,\n },\n });\n\n return React.createElement(\n FieldTemplate,\n {\n ...this.props,\n classNames: 'form-group field field-custom',\n },\n component,\n getHelpComponent(props.schema),\n );\n }\n\n render() {\n if (hasCustomComponent(this.props.schema)) {\n return this.renderCustomComponent(this.props);\n }\n\n const fieldProps = {\n ...this.props,\n onChange: this.handleChange,\n };\n\n return React.createElement(JSONSchemaField, fieldProps);\n }\n\n /**\n * Gets the path to the current property within the schema\n *\n * @param schemaId - the id of the schema\n * @returns an array with the schema path for the current property\n * @example\n * const schemaId = 'root_sections_0_controls_0_name';\n * const schemaPath = getSchemaPath(schemaId);\n * // ➡ ['sections', '0', 'controls', '0', 'name']\n */\n private getSchemaPath(schemaId: string): string[] {\n if (schemaId === undefined) {\n return undefined;\n }\n\n return schemaId.replace('root_', '').split('_');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"schema-field.js","sourceRoot":"","sources":["../../../../src/components/form/fields/schema-field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,eAAe,MAAM,8CAA8C,CAAC;AAC3E,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C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W,EAAE,UAAU,IACpB,UAAU,CAAC,QAAQ,CACzB,CAAC;KACL;IAED,OAAO,KAAK,CAAC,aAAa,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;EAC5D,CAAC;EAED;;;;;;;;;KASG;EACK,aAAa,CAAC,QAAgB;IAClC,IAAI,QAAQ,KAAK,SAAS,EAAE;MACxB,OAAO,SAAS,CAAC;KACpB;IAED,OAAO,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;EACpD,CAAC;CACJ","sourcesContent":["import { LimeElementsAdapter } from '../adapters';\nimport JSONSchemaField from '@rjsf/core/lib/components/fields/SchemaField';\nimport React from 'react';\nimport { FieldProps } from './types';\nimport { isEmpty, capitalize } from 'lodash-es';\nimport { resetDependentFields } from './field-helpers';\nimport { FieldTemplate } from '../templates';\nimport { getHelpComponent } from '../help';\nimport { FormSchema } from '../form.types';\nimport { TimePicker } from '../widgets/time-picker';\n\n/**\n * If given a value and schema, check if the value should be translated\n * from null to undefined to avoid issues with validation\n *\n * This function needs to be used for several reasons:\n * 1. CustomEvent does not allow `detail` to equal `undefined`, but we can call onChange with `undefined` in React\n * 2. `null` is treated as a valid value in a jsonschema and with marshmallow and it has its own type (null)\n * 3. Without changing `null` to `undefined` there would be no way to remove a field from\n * from the submitted form data once it had any data. (when POSTing, undefined is not posted since its not valid json)\n * 4. The only applies to custom web components since widgets handle transforming null/'' to undefined depending on the widget\n * and its purpose.\n *\n * Example:\n * If I have an object `{ name?: string, email?: string }` that I am using a custom web component for `name`,\n * then initially, the formData will be `{}` which is fine because neither name or email are required. Then if i input a\n * value for name the formData will be `{ name: 'some_value' }` which is also fine. But then if I want to remove name\n * from the form data I would delete all the text from the name input field. Web components would emit this empty value\n * as '' or null. If the web component tries to emit `undefined`, null would be emitted instead because CustomEvent has\n * a default `detail` value of null\n *\n * @param value - the value associated with the schema\n * @param schema - the schema for the value\n * @returns whether or not null should be changed to undefined\n */\nconst shouldChangeToUndefined = (value, schema): boolean => {\n return value === null && !schema.type.includes('null');\n};\n\nconst hasCustomComponent = (schema): boolean => {\n const name = schema.lime?.component?.name;\n if (!name) {\n return false;\n }\n\n try {\n verifyCustomComponentIsDefined(name);\n } catch {\n // eslint-disable-next-line no-console\n console.warn(`Custom component ${name} not defined`);\n\n return false;\n }\n\n return true;\n};\n\nconst verifyCustomComponentIsDefined = (elementName): void => {\n const supportsCustomElements = 'customElements' in window;\n\n if (!supportsCustomElements) {\n throw new Error(\n 'Custom form elements are not supported by this browser!',\n );\n }\n\n if (!customElements.get(elementName)) {\n throw new Error(`Custom form element '${elementName}' is not defined!`);\n }\n};\n\nconst getCustomComponent = (\n schema,\n): { name: string; props: { [key: string]: any } } => {\n const name = schema.lime?.component?.name;\n const props = schema.lime?.component?.props || {};\n\n return { name: name, props: props };\n};\n\n/**\n * Create properties from the factory that is set on `limel-form`\n *\n * @param formContext - the form context\n * @param schema - the schema for the current field\n * @returns the properties created by the factory\n */\nexport function getFactoryProps(\n formContext: any,\n schema: FormSchema,\n): Record<string, any> {\n const factory: (schema: FormSchema) => Record<string, any> =\n formContext.propsFactory;\n if (typeof factory !== 'function') {\n return {};\n }\n\n const props = factory(schema);\n if (!props) {\n return {};\n }\n\n return props;\n}\n\nexport class SchemaField extends React.Component<FieldProps> {\n state = {\n modified: false,\n };\n\n constructor(props) {\n super(props);\n this.handleChange = this.handleChange.bind(this);\n this.handleCustomComponentChange =\n this.handleCustomComponentChange.bind(this);\n }\n\n private hasValue() {\n const value = this.getValue();\n if (!value) {\n return false;\n }\n\n if (Array.isArray(value)) {\n return !!value.length;\n }\n\n if (typeof value === 'object') {\n return !isEmpty(value);\n }\n\n return true;\n }\n\n private getLabel() {\n const { schema } = this.props;\n\n return schema.title;\n }\n\n private isInvalid() {\n const { modified } = this.state;\n const { errorSchema } = this.props;\n\n return (\n (modified || this.hasValue() || !this.isRequired()) &&\n !isEmpty(errorSchema)\n );\n }\n\n private isRequired() {\n const { required, schema } = this.props;\n\n return required || schema.minItems > 0;\n }\n\n private getHelperText() {\n const { errorSchema, schema } = this.props;\n\n if (!this.isInvalid()) {\n const helperText = schema.lime?.component?.props?.helperText;\n\n return helperText || schema.description;\n }\n\n if (!isEmpty(errorSchema) && '__errors' in errorSchema) {\n return capitalize(errorSchema.__errors[0]); // eslint-disable-line no-underscore-dangle\n }\n\n return schema.description;\n }\n\n private getValue() {\n const { formData } = this.props;\n\n return formData;\n }\n\n private handleCustomComponentChange(event) {\n const { schema } = this.props;\n event.stopPropagation();\n\n let value = event.detail;\n\n if (shouldChangeToUndefined(value, schema)) {\n value = undefined;\n }\n\n this.handleChange(value);\n }\n\n private handleChange(data) {\n const { formData, schema } = this.props;\n const { rootSchema } = this.props.registry;\n\n this.setState({ modified: true });\n\n const newData = resetDependentFields(\n formData,\n data,\n schema,\n rootSchema,\n );\n\n this.props.onChange(newData);\n }\n\n private buildCustomComponentProps() {\n const {\n disabled,\n readonly,\n name,\n registry,\n schema,\n errorSchema,\n idSchema,\n } = this.props;\n const factoryProps = getFactoryProps(registry.formContext, schema);\n\n return {\n ...factoryProps,\n value: this.getValue(),\n required: this.isRequired(),\n readonly: readonly || schema.readOnly,\n disabled: disabled,\n invalid: this.isInvalid(),\n label: this.getLabel(),\n helperText: this.getHelperText(),\n formInfo: {\n schema: schema,\n rootSchema: registry.formContext.schema,\n errorSchema: errorSchema,\n rootValue: registry.formContext.rootValue,\n name: name,\n schemaPath: this.getSchemaPath(idSchema?.$id),\n },\n };\n }\n\n private renderCustomComponent(props: FieldProps) {\n const { name, props: userDefinedComponentProps } = getCustomComponent(\n props.schema,\n );\n\n verifyCustomComponentIsDefined(name);\n\n const component = React.createElement(LimeElementsAdapter, {\n name: name,\n elementProps: {\n ...userDefinedComponentProps,\n ...this.buildCustomComponentProps(),\n },\n events: {\n change: this.handleCustomComponentChange,\n },\n });\n\n return React.createElement(\n FieldTemplate,\n {\n ...this.props,\n classNames: 'form-group field field-custom',\n },\n component,\n getHelpComponent(props.schema),\n );\n }\n\n render() {\n if (hasCustomComponent(this.props.schema)) {\n return this.renderCustomComponent(this.props);\n }\n\n const fieldProps = {\n ...this.props,\n onChange: this.handleChange,\n };\n\n if (this.props.schema.format === 'time') {\n fieldProps.uiSchema = {\n 'ui:widget': TimePicker,\n ...fieldProps.uiSchema,\n };\n }\n\n return React.createElement(JSONSchemaField, fieldProps);\n }\n\n /**\n * Gets the path to the current property within the schema\n *\n * @param schemaId - the id of the schema\n * @returns an array with the schema path for the current property\n * @example\n * const schemaId = 'root_sections_0_controls_0_name';\n * const schemaPath = getSchemaPath(schemaId);\n * // ➡ ['sections', '0', 'controls', '0', 'name']\n */\n private getSchemaPath(schemaId: string): string[] {\n if (schemaId === undefined) {\n return undefined;\n }\n\n return schemaId.replace('root_', '').split('_');\n }\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s)
|
|
4
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { DatePicker } from './date-picker';
|
|
15
|
+
export const DateOnlyPicker = (_a) => {
|
|
16
|
+
var { value } = _a, props = __rest(_a, ["value"]);
|
|
17
|
+
// A date-only string is treated as UTC by the Date constructor,
|
|
18
|
+
// but we want to parse it as local date
|
|
19
|
+
if (typeof value === 'string' && /-\d\d$/.test(value)) {
|
|
20
|
+
value += 'T00:00';
|
|
21
|
+
}
|
|
22
|
+
return React.createElement(DatePicker, Object.assign({ type: 'date', value: value }, props));
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=date-only-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-only-picker.js","sourceRoot":"","sources":["../../../../src/components/form/widgets/date-only-picker.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,CAAC,MAAM,cAAc,GAAyC,CAAC,EAGpE,EAAE,EAAE;MAHgE,EACjE,KAAK,OAER,EADM,KAAK,cAFyD,SAGpE,CADW;EAER,gEAAgE;EAChE,wCAAwC;EACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;IACnD,KAAK,IAAI,QAAQ,CAAC;GACrB;EAED,OAAO,KAAK,CAAC,aAAa,CAAC,UAAU,kBACjC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,KAAK,IACT,KAAK,EACV,CAAC;AACP,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { DatePicker } from './date-picker';\nimport { WidgetProps } from './types';\n\nexport const DateOnlyPicker: React.FunctionComponent<WidgetProps> = ({\n value,\n ...props\n}) => {\n // A date-only string is treated as UTC by the Date constructor,\n // but we want to parse it as local date\n if (typeof value === 'string' && /-\\d\\d$/.test(value)) {\n value += 'T00:00';\n }\n\n return React.createElement(DatePicker, {\n type: 'date',\n value: value,\n ...props,\n });\n};\n"]}
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s)
|
|
4
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
1
13
|
import moment from 'moment/moment';
|
|
2
14
|
import React from 'react';
|
|
3
15
|
import { LimeElementsWidgetAdapter } from '../adapters';
|
|
@@ -11,8 +23,8 @@ export class DatePicker extends React.Component {
|
|
|
11
23
|
this.handleChange = this.handleChange.bind(this);
|
|
12
24
|
}
|
|
13
25
|
render() {
|
|
14
|
-
|
|
15
|
-
const
|
|
26
|
+
var _a, _b;
|
|
27
|
+
const _c = this.props, { type = 'datetime' } = _c, props = __rest(_c, ["type"]);
|
|
16
28
|
return React.createElement(LimeElementsWidgetAdapter, {
|
|
17
29
|
name: 'limel-date-picker',
|
|
18
30
|
value: this.getValue(),
|
|
@@ -20,7 +32,7 @@ export class DatePicker extends React.Component {
|
|
|
20
32
|
change: this.handleChange,
|
|
21
33
|
},
|
|
22
34
|
widgetProps: props,
|
|
23
|
-
extraProps: Object.assign({},
|
|
35
|
+
extraProps: Object.assign({ type: type }, (_b = (_a = props.schema.lime) === null || _a === void 0 ? void 0 : _a.component) === null || _b === void 0 ? void 0 : _b.props),
|
|
24
36
|
});
|
|
25
37
|
}
|
|
26
38
|
getValue() {
|
|
@@ -50,12 +62,4 @@ export class DatePicker extends React.Component {
|
|
|
50
62
|
props.onChange(dateString);
|
|
51
63
|
}
|
|
52
64
|
}
|
|
53
|
-
function getAdditionalProps(schema) {
|
|
54
|
-
var _a, _b;
|
|
55
|
-
let props = {};
|
|
56
|
-
if ((_b = (_a = schema.lime) === null || _a === void 0 ? void 0 : _a.component) === null || _b === void 0 ? void 0 : _b.props) {
|
|
57
|
-
props = schema.lime.component.props;
|
|
58
|
-
}
|
|
59
|
-
return props;
|
|
60
|
-
}
|
|
61
65
|
//# sourceMappingURL=date-picker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.js","sourceRoot":"","sources":["../../../../src/components/form/widgets/date-picker.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,eAAe,CAAC;AACnC,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"date-picker.js","sourceRoot":"","sources":["../../../../src/components/form/widgets/date-picker.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,MAAM,MAAM,eAAe,CAAC;AACnC,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAMxD,MAAM,OAAO,UAAW,SAAQ,KAAK,CAAC,SAA0B;EAM5D,YAAmB,KAAsB;IACrC,KAAK,CAAC,KAAK,CAAC,CAAC;IADE,UAAK,GAAL,KAAK,CAAiB;IAJlC,UAAK,GAAG;MACX,QAAQ,EAAE,KAAK;KAClB,CAAC;IAIE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;EACrD,CAAC;EAEM,MAAM;;IACT,MAAM,KAAkC,IAAI,CAAC,KAAK,EAA5C,EAAE,IAAI,GAAG,UAAU,OAAyB,EAApB,KAAK,cAA7B,QAA+B,CAAa,CAAC;IAEnD,OAAO,KAAK,CAAC,aAAa,CAAC,yBAAyB,EAAE;MAClD,IAAI,EAAE,mBAAmB;MACzB,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE;MACtB,MAAM,EAAE;QACJ,MAAM,EAAE,IAAI,CAAC,YAAY;OAC5B;MACD,WAAW,EAAE,KAAK;MAClB,UAAU,kBACN,IAAI,EAAE,IAAI,IACP,MAAA,MAAA,KAAK,CAAC,MAAM,CAAC,IAAI,0CAAE,SAAS,0CAAE,KAAK,CACzC;KACJ,CAAC,CAAC;EACP,CAAC;EAEO,QAAQ;IACZ,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,QAAQ,EAAE;MACtC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACrC;SAAM;MACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;KAC3B;EACL,CAAC;EAEO,YAAY,CAAC,KAAwB;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IACzB,KAAK,CAAC,eAAe,EAAE,CAAC;IAExB,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;MACjB,OAAO;KACV;IAED,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;MACf,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;MAErB,OAAO;KACV;IAED,MAAM,aAAa,GAAG;MAClB,WAAW,EAAE,sBAAsB;MACnC,IAAI,EAAE,YAAY;MAClB,IAAI,EAAE,UAAU;KACnB,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,CAC1C,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CACrC,CAAC;IACF,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;EAC/B,CAAC;CACJ","sourcesContent":["import moment from 'moment/moment';\nimport React from 'react';\nimport { DateType } from '../../date-picker/date.types';\nimport { WidgetProps } from './types';\nimport { LimeElementsWidgetAdapter } from '../adapters';\n\ntype DateWidgetProps = WidgetProps & {\n type?: DateType;\n};\n\nexport class DatePicker extends React.Component<DateWidgetProps> {\n public refs: any;\n public state = {\n modified: false,\n };\n\n constructor(public props: DateWidgetProps) {\n super(props);\n this.handleChange = this.handleChange.bind(this);\n }\n\n public render() {\n const { type = 'datetime', ...props } = this.props;\n\n return React.createElement(LimeElementsWidgetAdapter, {\n name: 'limel-date-picker',\n value: this.getValue(),\n events: {\n change: this.handleChange,\n },\n widgetProps: props,\n extraProps: {\n type: type,\n ...props.schema.lime?.component?.props,\n },\n });\n }\n\n private getValue() {\n if (typeof this.props.value === 'string') {\n return new Date(this.props.value);\n } else {\n return this.props.value;\n }\n }\n\n private handleChange(event: CustomEvent<Date>) {\n const props = this.props;\n event.stopPropagation();\n\n if (!props.onChange) {\n return;\n }\n\n if (!event.detail) {\n props.onChange(null);\n\n return;\n }\n\n const formatMapping = {\n 'date-time': 'YYYY-MM-DDTHH:mm:ssZ',\n date: 'YYYY-MM-DD',\n time: 'HH:mm:ss',\n };\n const dateString = moment(event.detail).format(\n formatMapping[props.schema.format],\n );\n props.onChange(dateString);\n }\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Checkbox } from './checkbox';
|
|
2
|
+
import { DateOnlyPicker } from './date-only-picker';
|
|
2
3
|
import { DatePicker } from './date-picker';
|
|
3
4
|
import { InputField } from './input-field';
|
|
4
5
|
import { Select } from './select';
|
|
@@ -6,7 +7,7 @@ import { Slider } from './slider';
|
|
|
6
7
|
export const widgets = {
|
|
7
8
|
CheckboxWidget: Checkbox,
|
|
8
9
|
DateTimeWidget: DatePicker,
|
|
9
|
-
DateWidget:
|
|
10
|
+
DateWidget: DateOnlyPicker,
|
|
10
11
|
EmailWidget: InputField,
|
|
11
12
|
TextWidget: InputField,
|
|
12
13
|
SelectWidget: Select,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/form/widgets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAuBlC,MAAM,CAAC,MAAM,OAAO,GAAqC;EACrD,cAAc,EAAE,QAAQ;EACxB,cAAc,EAAE,UAAU;EAC1B,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/form/widgets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAuBlC,MAAM,CAAC,MAAM,OAAO,GAAqC;EACrD,cAAc,EAAE,QAAQ;EACxB,cAAc,EAAE,UAAU;EAC1B,UAAU,EAAE,cAAc;EAC1B,WAAW,EAAE,UAAU;EACvB,UAAU,EAAE,UAAU;EACtB,YAAY,EAAE,MAAM;EACpB,WAAW,EAAE,MAAM;CACtB,CAAC","sourcesContent":["import { Checkbox } from './checkbox';\nimport { DateOnlyPicker } from './date-only-picker';\nimport { DatePicker } from './date-picker';\nimport { InputField } from './input-field';\nimport { Select } from './select';\nimport { Slider } from './slider';\n\n// These are defined by react-json-schema-form\nexport type WidgetType =\n | 'AltDateTimeWidget'\n | 'AltDateWidget'\n | 'CheckboxesWidget'\n | 'CheckboxWidget'\n | 'ColorWidget'\n | 'DateTimeWidget'\n | 'DateWidget'\n | 'EmailWidget'\n | 'FileWidget'\n | 'HiddenWidget'\n | 'PasswordWidget'\n | 'RadioWidget'\n | 'RangeWidget'\n | 'SelectWidget'\n | 'TextareaWidget'\n | 'TextWidget'\n | 'UpDownWidget'\n | 'URLWidget';\n\nexport const widgets: Partial<Record<WidgetType, any>> = {\n CheckboxWidget: Checkbox,\n DateTimeWidget: DatePicker,\n DateWidget: DateOnlyPicker,\n EmailWidget: InputField,\n TextWidget: InputField,\n SelectWidget: Select,\n RangeWidget: Slider,\n};\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s)
|
|
4
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { DatePicker } from './date-picker';
|
|
15
|
+
export const TimePicker = (_a) => {
|
|
16
|
+
var { value } = _a, props = __rest(_a, ["value"]);
|
|
17
|
+
if (typeof value === 'string' && timeStringPattern.test(value)) {
|
|
18
|
+
value = new Date('2000-01-01T' + value);
|
|
19
|
+
}
|
|
20
|
+
return React.createElement(DatePicker, Object.assign({ type: 'time', value: value }, props));
|
|
21
|
+
};
|
|
22
|
+
const timeStringPattern = /^\d\d:\d\d/;
|
|
23
|
+
//# sourceMappingURL=time-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-picker.js","sourceRoot":"","sources":["../../../../src/components/form/widgets/time-picker.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,CAAC,MAAM,UAAU,GAAyC,CAAC,EAGhE,EAAE,EAAE;MAH4D,EAC7D,KAAK,OAER,EADM,KAAK,cAFqD,SAGhE,CADW;EAER,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;IAC5D,KAAK,GAAG,IAAI,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;GAC3C;EAED,OAAO,KAAK,CAAC,aAAa,CAAC,UAAU,kBACjC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,KAAK,IACT,KAAK,EACV,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,YAAY,CAAC","sourcesContent":["import React from 'react';\nimport { DatePicker } from './date-picker';\nimport { WidgetProps } from './types';\n\nexport const TimePicker: React.FunctionComponent<WidgetProps> = ({\n value,\n ...props\n}) => {\n if (typeof value === 'string' && timeStringPattern.test(value)) {\n value = new Date('2000-01-01T' + value);\n }\n\n return React.createElement(DatePicker, {\n type: 'time',\n value: value,\n ...props,\n });\n};\n\nconst timeStringPattern = /^\\d\\d:\\d\\d/;\n"]}
|
|
@@ -28851,6 +28851,87 @@ function isAdditionalProperty(schema) {
|
|
|
28851
28851
|
return schema[ADDITIONAL_PROPERTY_FLAG] === true;
|
|
28852
28852
|
}
|
|
28853
28853
|
|
|
28854
|
+
var __rest$2 = (undefined && undefined.__rest) || function (s, e) {
|
|
28855
|
+
var t = {};
|
|
28856
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28857
|
+
t[p] = s[p];
|
|
28858
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
28859
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
28860
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
28861
|
+
t[p[i]] = s[p[i]];
|
|
28862
|
+
}
|
|
28863
|
+
return t;
|
|
28864
|
+
};
|
|
28865
|
+
class DatePicker extends react.Component {
|
|
28866
|
+
constructor(props) {
|
|
28867
|
+
super(props);
|
|
28868
|
+
this.props = props;
|
|
28869
|
+
this.state = {
|
|
28870
|
+
modified: false,
|
|
28871
|
+
};
|
|
28872
|
+
this.handleChange = this.handleChange.bind(this);
|
|
28873
|
+
}
|
|
28874
|
+
render() {
|
|
28875
|
+
var _a, _b;
|
|
28876
|
+
const _c = this.props, { type = 'datetime' } = _c, props = __rest$2(_c, ["type"]);
|
|
28877
|
+
return react.createElement(LimeElementsWidgetAdapter, {
|
|
28878
|
+
name: 'limel-date-picker',
|
|
28879
|
+
value: this.getValue(),
|
|
28880
|
+
events: {
|
|
28881
|
+
change: this.handleChange,
|
|
28882
|
+
},
|
|
28883
|
+
widgetProps: props,
|
|
28884
|
+
extraProps: Object.assign({ type: type }, (_b = (_a = props.schema.lime) === null || _a === void 0 ? void 0 : _a.component) === null || _b === void 0 ? void 0 : _b.props),
|
|
28885
|
+
});
|
|
28886
|
+
}
|
|
28887
|
+
getValue() {
|
|
28888
|
+
if (typeof this.props.value === 'string') {
|
|
28889
|
+
return new Date(this.props.value);
|
|
28890
|
+
}
|
|
28891
|
+
else {
|
|
28892
|
+
return this.props.value;
|
|
28893
|
+
}
|
|
28894
|
+
}
|
|
28895
|
+
handleChange(event) {
|
|
28896
|
+
const props = this.props;
|
|
28897
|
+
event.stopPropagation();
|
|
28898
|
+
if (!props.onChange) {
|
|
28899
|
+
return;
|
|
28900
|
+
}
|
|
28901
|
+
if (!event.detail) {
|
|
28902
|
+
props.onChange(null);
|
|
28903
|
+
return;
|
|
28904
|
+
}
|
|
28905
|
+
const formatMapping = {
|
|
28906
|
+
'date-time': 'YYYY-MM-DDTHH:mm:ssZ',
|
|
28907
|
+
date: 'YYYY-MM-DD',
|
|
28908
|
+
time: 'HH:mm:ss',
|
|
28909
|
+
};
|
|
28910
|
+
const dateString = moment(event.detail).format(formatMapping[props.schema.format]);
|
|
28911
|
+
props.onChange(dateString);
|
|
28912
|
+
}
|
|
28913
|
+
}
|
|
28914
|
+
|
|
28915
|
+
var __rest$1 = (undefined && undefined.__rest) || function (s, e) {
|
|
28916
|
+
var t = {};
|
|
28917
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28918
|
+
t[p] = s[p];
|
|
28919
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
28920
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
28921
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
28922
|
+
t[p[i]] = s[p[i]];
|
|
28923
|
+
}
|
|
28924
|
+
return t;
|
|
28925
|
+
};
|
|
28926
|
+
const TimePicker = (_a) => {
|
|
28927
|
+
var { value } = _a, props = __rest$1(_a, ["value"]);
|
|
28928
|
+
if (typeof value === 'string' && timeStringPattern.test(value)) {
|
|
28929
|
+
value = new Date('2000-01-01T' + value);
|
|
28930
|
+
}
|
|
28931
|
+
return react.createElement(DatePicker, Object.assign({ type: 'time', value: value }, props));
|
|
28932
|
+
};
|
|
28933
|
+
const timeStringPattern = /^\d\d:\d\d/;
|
|
28934
|
+
|
|
28854
28935
|
/**
|
|
28855
28936
|
* If given a value and schema, check if the value should be translated
|
|
28856
28937
|
* from null to undefined to avoid issues with validation
|
|
@@ -29025,6 +29106,9 @@ class SchemaField extends react.Component {
|
|
|
29025
29106
|
return this.renderCustomComponent(this.props);
|
|
29026
29107
|
}
|
|
29027
29108
|
const fieldProps = Object.assign(Object.assign({}, this.props), { onChange: this.handleChange });
|
|
29109
|
+
if (this.props.schema.format === 'time') {
|
|
29110
|
+
fieldProps.uiSchema = Object.assign({ 'ui:widget': TimePicker }, fieldProps.uiSchema);
|
|
29111
|
+
}
|
|
29028
29112
|
return react.createElement(SchemaField$1, fieldProps);
|
|
29029
29113
|
}
|
|
29030
29114
|
/**
|
|
@@ -29198,7 +29282,7 @@ class Checkbox extends react.Component {
|
|
|
29198
29282
|
}
|
|
29199
29283
|
render() {
|
|
29200
29284
|
const props = this.props;
|
|
29201
|
-
const additionalProps = getAdditionalProps$
|
|
29285
|
+
const additionalProps = getAdditionalProps$2(props.schema);
|
|
29202
29286
|
return react.createElement(LimeElementsWidgetAdapter, {
|
|
29203
29287
|
name: 'limel-checkbox',
|
|
29204
29288
|
value: props.value,
|
|
@@ -29218,68 +29302,31 @@ class Checkbox extends react.Component {
|
|
|
29218
29302
|
props.onChange(event.detail);
|
|
29219
29303
|
}
|
|
29220
29304
|
}
|
|
29221
|
-
function getAdditionalProps$
|
|
29305
|
+
function getAdditionalProps$2(schema) {
|
|
29222
29306
|
var _a, _b, _c;
|
|
29223
29307
|
return (_c = (_b = (_a = schema.lime) === null || _a === void 0 ? void 0 : _a.component) === null || _b === void 0 ? void 0 : _b.props) !== null && _c !== void 0 ? _c : {};
|
|
29224
29308
|
}
|
|
29225
29309
|
|
|
29226
|
-
|
|
29227
|
-
|
|
29228
|
-
|
|
29229
|
-
|
|
29230
|
-
|
|
29231
|
-
|
|
29232
|
-
|
|
29233
|
-
|
|
29234
|
-
}
|
|
29235
|
-
render() {
|
|
29236
|
-
const props = this.props;
|
|
29237
|
-
const additionalProps = getAdditionalProps$2(props.schema);
|
|
29238
|
-
return react.createElement(LimeElementsWidgetAdapter, {
|
|
29239
|
-
name: 'limel-date-picker',
|
|
29240
|
-
value: this.getValue(),
|
|
29241
|
-
events: {
|
|
29242
|
-
change: this.handleChange,
|
|
29243
|
-
},
|
|
29244
|
-
widgetProps: props,
|
|
29245
|
-
extraProps: Object.assign({}, additionalProps),
|
|
29246
|
-
});
|
|
29247
|
-
}
|
|
29248
|
-
getValue() {
|
|
29249
|
-
if (typeof this.props.value === 'string') {
|
|
29250
|
-
return new Date(this.props.value);
|
|
29251
|
-
}
|
|
29252
|
-
else {
|
|
29253
|
-
return this.props.value;
|
|
29254
|
-
}
|
|
29255
|
-
}
|
|
29256
|
-
handleChange(event) {
|
|
29257
|
-
const props = this.props;
|
|
29258
|
-
event.stopPropagation();
|
|
29259
|
-
if (!props.onChange) {
|
|
29260
|
-
return;
|
|
29261
|
-
}
|
|
29262
|
-
if (!event.detail) {
|
|
29263
|
-
props.onChange(null);
|
|
29264
|
-
return;
|
|
29310
|
+
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
29311
|
+
var t = {};
|
|
29312
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
29313
|
+
t[p] = s[p];
|
|
29314
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
29315
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
29316
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
29317
|
+
t[p[i]] = s[p[i]];
|
|
29265
29318
|
}
|
|
29266
|
-
|
|
29267
|
-
|
|
29268
|
-
|
|
29269
|
-
|
|
29270
|
-
|
|
29271
|
-
|
|
29272
|
-
|
|
29273
|
-
|
|
29274
|
-
}
|
|
29275
|
-
|
|
29276
|
-
|
|
29277
|
-
let props = {};
|
|
29278
|
-
if ((_b = (_a = schema.lime) === null || _a === void 0 ? void 0 : _a.component) === null || _b === void 0 ? void 0 : _b.props) {
|
|
29279
|
-
props = schema.lime.component.props;
|
|
29280
|
-
}
|
|
29281
|
-
return props;
|
|
29282
|
-
}
|
|
29319
|
+
return t;
|
|
29320
|
+
};
|
|
29321
|
+
const DateOnlyPicker = (_a) => {
|
|
29322
|
+
var { value } = _a, props = __rest(_a, ["value"]);
|
|
29323
|
+
// A date-only string is treated as UTC by the Date constructor,
|
|
29324
|
+
// but we want to parse it as local date
|
|
29325
|
+
if (typeof value === 'string' && /-\d\d$/.test(value)) {
|
|
29326
|
+
value += 'T00:00';
|
|
29327
|
+
}
|
|
29328
|
+
return react.createElement(DatePicker, Object.assign({ type: 'date', value: value }, props));
|
|
29329
|
+
};
|
|
29283
29330
|
|
|
29284
29331
|
class Slider extends react.Component {
|
|
29285
29332
|
constructor(props) {
|
|
@@ -29480,7 +29527,7 @@ function findValues(value, options) {
|
|
|
29480
29527
|
const widgets = {
|
|
29481
29528
|
CheckboxWidget: Checkbox,
|
|
29482
29529
|
DateTimeWidget: DatePicker,
|
|
29483
|
-
DateWidget:
|
|
29530
|
+
DateWidget: DateOnlyPicker,
|
|
29484
29531
|
EmailWidget: InputField,
|
|
29485
29532
|
TextWidget: InputField,
|
|
29486
29533
|
SelectWidget: Select,
|