grep-components 2.23.0 → 2.23.1-GREPF-2925.1

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.
@@ -13,3 +13,4 @@ export declare const WithError: Story;
13
13
  export declare const WithHelperText: Story;
14
14
  export declare const WithClearText: Story;
15
15
  export declare const WithMoreControls: Story;
16
+ export declare const WithMinMaxDates: Story;
package/dist/index.js CHANGED
@@ -3138,14 +3138,24 @@ const GrepDatePicker = ({ id, label, value, variant, errorMessage, fullWidth, re
3138
3138
  setError('Ugyldig dato');
3139
3139
  break;
3140
3140
  case 'maxDate':
3141
- setError(`Dato må være før ${dayjs(props.maxDate)
3142
- .add(1, 'day')
3143
- .format('DD/MM/YYYY')}`);
3141
+ if (!props.maxDate) {
3142
+ props.maxDate = dayjs('31/12/2089', 'DD/MM/YYYY');
3143
+ }
3144
+ if (props.maxDate) {
3145
+ setError(`Dato må være før ${dayjs(props.maxDate)
3146
+ .add(1, 'day')
3147
+ .format('DD/MM/YYYY')}`);
3148
+ }
3144
3149
  break;
3145
3150
  case 'minDate':
3146
- setError(`Dato må være etter ${dayjs(props.minDate)
3147
- .subtract(1, 'day')
3148
- .format('DD/MM/YYYY')}`);
3151
+ if (!props.minDate) {
3152
+ props.minDate = dayjs('02/01/1900', 'DD/MM/YYYY');
3153
+ }
3154
+ if (props.minDate) {
3155
+ setError(`Dato må være etter ${dayjs(props.minDate)
3156
+ .subtract(1, 'day')
3157
+ .format('DD/MM/YYYY')}`);
3158
+ }
3149
3159
  break;
3150
3160
  default:
3151
3161
  setError(undefined);
@@ -3169,18 +3179,16 @@ const GrepDatePicker = ({ id, label, value, variant, errorMessage, fullWidth, re
3169
3179
  }, ...props })));
3170
3180
  };
3171
3181
 
3172
- const GrepDateRange = ({ onChange, spacing = 3, style, fullWidth, clearable, from: fromProperties, to: toProperties, ...properties }) => {
3182
+ const GrepDateRange = ({ onChange, spacing = 3, style, fullWidth, from: fromProperties, to: toProperties, ...properties }) => {
3173
3183
  const [from, setFrom] = useDate(fromProperties.value);
3174
3184
  const [to, setTo] = useDate(toProperties.value);
3175
3185
  const { minDate, maxDate, ...commonProperties } = properties;
3176
- useEffect(() => {
3177
- onChange(new DateRangeValue(from ? String(from) : from, to ? String(to) : to));
3178
- }, [String(from), String(to)]);
3186
+ useEffect(() => onChange(new DateRangeValue(from ? String(from) : from, to ? String(to) : to)), [String(from), String(to)]);
3179
3187
  return (React__default.createElement(Grid, { container: true, spacing: spacing, style: style },
3180
3188
  React__default.createElement(Grid, { size: { xs: 12, sm: fullWidth ? 12 : 6 } },
3181
- React__default.createElement(GrepDatePicker, { id: String(fromProperties.label), fullWidth: true, minDate: minDate, ...commonProperties, ...fromProperties, value: from, maxDate: to?.subtract(1, 'day') || undefined, onChange: setFrom, clearable: clearable || fromProperties.clearable })),
3189
+ React__default.createElement(GrepDatePicker, { id: String(fromProperties.label), fullWidth: true, minDate: minDate, ...commonProperties, ...fromProperties, value: from, maxDate: to?.subtract(1, 'day') || undefined, onChange: setFrom })),
3182
3190
  React__default.createElement(Grid, { size: { xs: 12, sm: fullWidth ? 12 : 6 } },
3183
- React__default.createElement(GrepDatePicker, { id: String(toProperties.label), fullWidth: true, maxDate: maxDate, ...commonProperties, ...toProperties, value: to, minDate: from?.add(1, 'day') || undefined, onChange: setTo, clearable: clearable || toProperties.clearable }))));
3191
+ React__default.createElement(GrepDatePicker, { id: String(toProperties.label), fullWidth: true, maxDate: maxDate, ...commonProperties, ...toProperties, value: to, minDate: from?.add(1, 'day') || undefined, onChange: setTo }))));
3184
3192
  };
3185
3193
 
3186
3194
  const renderField = ({ key, value }) => (React.createElement(Box$1, { key: key, sx: { display: 'flex', marginRight: '20px' } },