@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 CHANGED
@@ -1,3 +1,16 @@
1
+ ## [37.59.0](https://github.com/Lundalogik/lime-elements/compare/v37.58.0...v37.59.0) (2024-09-16)
2
+
3
+
4
+ ### Features
5
+
6
+
7
+ * **form:** support time picker ([2bddee1](https://github.com/Lundalogik/lime-elements/commit/2bddee1e084f106bf18c322fe412b90647af30e9))
8
+
9
+ ### Bug Fixes
10
+
11
+
12
+ * **form:** pass date type for format in date widget ([4753d4b](https://github.com/Lundalogik/lime-elements/commit/4753d4bb0599fec82f96d80be70d22802e3c97b9)), closes [#1489](https://github.com/Lundalogik/lime-elements/issues/1489)
13
+
1
14
  ## [37.58.0](https://github.com/Lundalogik/lime-elements/compare/v37.57.6...v37.58.0) (2024-09-13)
2
15
 
3
16
 
@@ -28855,6 +28855,87 @@ function isAdditionalProperty(schema) {
28855
28855
  return schema[ADDITIONAL_PROPERTY_FLAG] === true;
28856
28856
  }
28857
28857
 
28858
+ var __rest$2 = (undefined && undefined.__rest) || function (s, e) {
28859
+ var t = {};
28860
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28861
+ t[p] = s[p];
28862
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
28863
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
28864
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28865
+ t[p[i]] = s[p[i]];
28866
+ }
28867
+ return t;
28868
+ };
28869
+ class DatePicker extends react.Component {
28870
+ constructor(props) {
28871
+ super(props);
28872
+ this.props = props;
28873
+ this.state = {
28874
+ modified: false,
28875
+ };
28876
+ this.handleChange = this.handleChange.bind(this);
28877
+ }
28878
+ render() {
28879
+ var _a, _b;
28880
+ const _c = this.props, { type = 'datetime' } = _c, props = __rest$2(_c, ["type"]);
28881
+ return react.createElement(LimeElementsWidgetAdapter, {
28882
+ name: 'limel-date-picker',
28883
+ value: this.getValue(),
28884
+ events: {
28885
+ change: this.handleChange,
28886
+ },
28887
+ widgetProps: props,
28888
+ 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),
28889
+ });
28890
+ }
28891
+ getValue() {
28892
+ if (typeof this.props.value === 'string') {
28893
+ return new Date(this.props.value);
28894
+ }
28895
+ else {
28896
+ return this.props.value;
28897
+ }
28898
+ }
28899
+ handleChange(event) {
28900
+ const props = this.props;
28901
+ event.stopPropagation();
28902
+ if (!props.onChange) {
28903
+ return;
28904
+ }
28905
+ if (!event.detail) {
28906
+ props.onChange(null);
28907
+ return;
28908
+ }
28909
+ const formatMapping = {
28910
+ 'date-time': 'YYYY-MM-DDTHH:mm:ssZ',
28911
+ date: 'YYYY-MM-DD',
28912
+ time: 'HH:mm:ss',
28913
+ };
28914
+ const dateString = moment.moment(event.detail).format(formatMapping[props.schema.format]);
28915
+ props.onChange(dateString);
28916
+ }
28917
+ }
28918
+
28919
+ var __rest$1 = (undefined && undefined.__rest) || function (s, e) {
28920
+ var t = {};
28921
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28922
+ t[p] = s[p];
28923
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
28924
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
28925
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28926
+ t[p[i]] = s[p[i]];
28927
+ }
28928
+ return t;
28929
+ };
28930
+ const TimePicker = (_a) => {
28931
+ var { value } = _a, props = __rest$1(_a, ["value"]);
28932
+ if (typeof value === 'string' && timeStringPattern.test(value)) {
28933
+ value = new Date('2000-01-01T' + value);
28934
+ }
28935
+ return react.createElement(DatePicker, Object.assign({ type: 'time', value: value }, props));
28936
+ };
28937
+ const timeStringPattern = /^\d\d:\d\d/;
28938
+
28858
28939
  /**
28859
28940
  * If given a value and schema, check if the value should be translated
28860
28941
  * from null to undefined to avoid issues with validation
@@ -29029,6 +29110,9 @@ class SchemaField extends react.Component {
29029
29110
  return this.renderCustomComponent(this.props);
29030
29111
  }
29031
29112
  const fieldProps = Object.assign(Object.assign({}, this.props), { onChange: this.handleChange });
29113
+ if (this.props.schema.format === 'time') {
29114
+ fieldProps.uiSchema = Object.assign({ 'ui:widget': TimePicker }, fieldProps.uiSchema);
29115
+ }
29032
29116
  return react.createElement(SchemaField$1, fieldProps);
29033
29117
  }
29034
29118
  /**
@@ -29202,7 +29286,7 @@ class Checkbox extends react.Component {
29202
29286
  }
29203
29287
  render() {
29204
29288
  const props = this.props;
29205
- const additionalProps = getAdditionalProps$3(props.schema);
29289
+ const additionalProps = getAdditionalProps$2(props.schema);
29206
29290
  return react.createElement(LimeElementsWidgetAdapter, {
29207
29291
  name: 'limel-checkbox',
29208
29292
  value: props.value,
@@ -29222,68 +29306,31 @@ class Checkbox extends react.Component {
29222
29306
  props.onChange(event.detail);
29223
29307
  }
29224
29308
  }
29225
- function getAdditionalProps$3(schema) {
29309
+ function getAdditionalProps$2(schema) {
29226
29310
  var _a, _b, _c;
29227
29311
  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 : {};
29228
29312
  }
29229
29313
 
29230
- class DatePicker extends react.Component {
29231
- constructor(props) {
29232
- super(props);
29233
- this.props = props;
29234
- this.state = {
29235
- modified: false,
29236
- };
29237
- this.handleChange = this.handleChange.bind(this);
29238
- }
29239
- render() {
29240
- const props = this.props;
29241
- const additionalProps = getAdditionalProps$2(props.schema);
29242
- return react.createElement(LimeElementsWidgetAdapter, {
29243
- name: 'limel-date-picker',
29244
- value: this.getValue(),
29245
- events: {
29246
- change: this.handleChange,
29247
- },
29248
- widgetProps: props,
29249
- extraProps: Object.assign({}, additionalProps),
29250
- });
29251
- }
29252
- getValue() {
29253
- if (typeof this.props.value === 'string') {
29254
- return new Date(this.props.value);
29255
- }
29256
- else {
29257
- return this.props.value;
29258
- }
29259
- }
29260
- handleChange(event) {
29261
- const props = this.props;
29262
- event.stopPropagation();
29263
- if (!props.onChange) {
29264
- return;
29265
- }
29266
- if (!event.detail) {
29267
- props.onChange(null);
29268
- return;
29314
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
29315
+ var t = {};
29316
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
29317
+ t[p] = s[p];
29318
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
29319
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
29320
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
29321
+ t[p[i]] = s[p[i]];
29269
29322
  }
29270
- const formatMapping = {
29271
- 'date-time': 'YYYY-MM-DDTHH:mm:ssZ',
29272
- date: 'YYYY-MM-DD',
29273
- time: 'HH:mm:ss',
29274
- };
29275
- const dateString = moment.moment(event.detail).format(formatMapping[props.schema.format]);
29276
- props.onChange(dateString);
29277
- }
29278
- }
29279
- function getAdditionalProps$2(schema) {
29280
- var _a, _b;
29281
- let props = {};
29282
- if ((_b = (_a = schema.lime) === null || _a === void 0 ? void 0 : _a.component) === null || _b === void 0 ? void 0 : _b.props) {
29283
- props = schema.lime.component.props;
29284
- }
29285
- return props;
29286
- }
29323
+ return t;
29324
+ };
29325
+ const DateOnlyPicker = (_a) => {
29326
+ var { value } = _a, props = __rest(_a, ["value"]);
29327
+ // A date-only string is treated as UTC by the Date constructor,
29328
+ // but we want to parse it as local date
29329
+ if (typeof value === 'string' && /-\d\d$/.test(value)) {
29330
+ value += 'T00:00';
29331
+ }
29332
+ return react.createElement(DatePicker, Object.assign({ type: 'date', value: value }, props));
29333
+ };
29287
29334
 
29288
29335
  class Slider extends react.Component {
29289
29336
  constructor(props) {
@@ -29484,7 +29531,7 @@ function findValues(value, options) {
29484
29531
  const widgets = {
29485
29532
  CheckboxWidget: Checkbox,
29486
29533
  DateTimeWidget: DatePicker,
29487
- DateWidget: DatePicker,
29534
+ DateWidget: DateOnlyPicker,
29488
29535
  EmailWidget: InputField,
29489
29536
  TextWidget: InputField,
29490
29537
  SelectWidget: Select,