onekijs-ui 1.0.4 → 1.0.6

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.
Files changed (39) hide show
  1. package/dist/components/datetime/FormDatePicker.d.ts +28 -0
  2. package/dist/components/datetime/FormDateRangePicker.d.ts +28 -0
  3. package/dist/components/datetime/FormDateTimePicker.d.ts +21 -0
  4. package/dist/components/datetime/FormDateTimeRangePicker.d.ts +21 -0
  5. package/dist/components/datetime/hooks/useDateAdapter.d.ts +4 -0
  6. package/dist/components/datetime/hooks/useDateRangeAdapter.d.ts +5 -0
  7. package/dist/components/datetime/hooks/useTimestampAdapter.d.ts +8 -0
  8. package/dist/components/datetime/hooks/useTimestampRangeAdapter.d.ts +17 -2
  9. package/dist/components/datetime/index.d.ts +8 -8
  10. package/dist/components/datetime/typings.d.ts +55 -9
  11. package/dist/components/select/SelectService.d.ts +3 -3
  12. package/dist/components/wizard/WizardModal.d.ts +2 -2
  13. package/dist/components/wizard/index.d.ts +2 -2
  14. package/dist/index.d.ts +73 -70
  15. package/dist/index.js +2290 -2102
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.module.js +2284 -2104
  18. package/dist/index.module.js.map +1 -1
  19. package/package.json +3 -3
  20. package/src/components/button/components/DropdownButtonComponent.tsx +6 -3
  21. package/src/components/datetime/FormDatePicker.tsx +79 -0
  22. package/src/components/datetime/FormDateRangePicker.tsx +79 -0
  23. package/src/components/datetime/FormDateTimePicker.tsx +43 -0
  24. package/src/components/datetime/FormDateTimeRangePicker.tsx +38 -0
  25. package/src/components/datetime/components/DatePickerComponent.tsx +8 -4
  26. package/src/components/datetime/components/DateRangePickerComponent.tsx +8 -4
  27. package/src/components/datetime/components/DateTimePickerComponent.tsx +8 -4
  28. package/src/components/datetime/components/DateTimeRangePickerComponent.tsx +8 -4
  29. package/src/components/datetime/components/TimeComponent.tsx +3 -0
  30. package/src/components/datetime/components/TimeRangeComponent.tsx +4 -2
  31. package/src/components/datetime/components/TimeSelectorComponent.tsx +5 -4
  32. package/src/components/datetime/components/TimeSelectorPartComponent.tsx +16 -1
  33. package/src/components/datetime/hooks/useDateAdapter.ts +14 -0
  34. package/src/components/datetime/hooks/useDateRangeAdapter.ts +11 -11
  35. package/src/components/datetime/hooks/useTimestampAdapter.ts +37 -0
  36. package/src/components/datetime/hooks/useTimestampRangeAdapter.ts +15 -26
  37. package/src/components/datetime/style.ts +14 -3
  38. package/src/components/datetime/typings.ts +66 -10
  39. package/src/index.ts +96 -130
@@ -1,6 +1,6 @@
1
1
  import styled, { css, keyframes, ThemeContext, ThemeProvider } from 'styled-components';
2
2
  import React, { useContext, useId, useEffect, useRef, useCallback, useMemo, useState, createElement, Children, useReducer } from 'react';
3
- import { reducer, DefaultService, service, lcfirst, toKebabCase, useService, get, useTryRouter, ucfirst, toArray, useThrottle, useIsomorphicLayoutEffect as useIsomorphicLayoutEffect$1, useLazyRef, useSubmit, ValidationCode, FORM_GLOBAL_VALIDATION_KEY, DefaultDisplayer, useFormDecorator, useForm, useFormMetadata, useFieldContainer, FormContext, useTrySetting, extractValidators, useField, useValidation, saga, SagaEffect, useEventListener, isTrue, DefaultBasicError, set, isFalse, isMobile, isNull, useCollectionInitialState, useCollectionProxy, CollectionService, LoadingStatus, isItemFetching, last, isCollectionInitializing, isCollection, eventLocks, useNotificationService, NotificationLevel, useNotifications, isSameFilter, shallowEqual, clone, ensureFieldValue, defaultComparator, isItemLoading, ValidationStatus, isCollectionLoading, isCollectionFetching, first, DefaultCollectionBroker, formatFilter, applyFilter, applySearch, applySortBy, formatSortBy, applySort, generateUniqueId, asyncHttp, HttpMethod, applyMixins, useLogger, ContainerValidation, isQueryFilterCriteria, useValue, Link, simpleMergeDeep } from 'onekijs-framework';
3
+ import { reducer, DefaultService, service, lcfirst, toKebabCase, useService, get, useTryRouter, ucfirst, toArray, useThrottle, useIsomorphicLayoutEffect as useIsomorphicLayoutEffect$1, useLazyRef, useSubmit, ValidationCode, FORM_GLOBAL_VALIDATION_KEY, DefaultDisplayer, useFormDecorator, useFormMetadata, useFieldContainer, FormContext, useForm, useTrySetting, extractValidators, useField, useValidation, saga, SagaEffect, useEventListener, isTrue, DefaultBasicError, set, isFalse, isMobile, isNull, useCollectionInitialState, useCollectionProxy, CollectionService, LoadingStatus, isItemFetching, last, isCollectionInitializing, isCollection, eventLocks, useNotificationService, NotificationLevel, useNotifications, isSameFilter, shallowEqual, clone, ensureFieldValue, defaultComparator, isItemLoading, ValidationStatus, isCollectionLoading, isCollectionFetching, first, formatFilter, applyFilter, applySearch, applySortBy, formatSortBy, applySort, generateUniqueId, asyncHttp, HttpMethod, applyMixins, useLogger, DefaultCollectionBroker, ContainerValidation, isQueryFilterCriteria, Link, useValue, simpleMergeDeep } from 'onekijs-framework';
4
4
  import { CSSTransition, TransitionGroup } from 'react-transition-group';
5
5
  import { useFloating, autoUpdate, offset, autoPlacement, flip, size, shift, arrow, useInteractions, useHover, useFocus, useDismiss, useRole } from '@floating-ui/react';
6
6
  import ReactDOM from 'react-dom';
@@ -1690,8 +1690,9 @@ const DropdownButtonComponent = ({ animationTimeout = 100, attachDropdownToBody
1690
1690
  const classNames = addClassname('o-button-dropdown', className);
1691
1691
  const ref = useRef(null);
1692
1692
  const [Dropdown, triggerRef] = useDropdown();
1693
- useClickOutside(ref, () => onCollapse && onCollapse());
1694
- return (jsxRuntimeExports.jsxs("span", { ref: ref, children: [jsxRuntimeExports.jsxs(Button, { ...buttonProps, className: classNames, onClick: onClick ? undefined : open ? onCollapse : onDrop, ref: triggerRef, children: [jsxRuntimeExports.jsx("span", { className: "o-button-dropdown-content", onClick: onClick, children: children }), jsxRuntimeExports.jsx("span", { className: "o-button-dropdown-icon", children: jsxRuntimeExports.jsx(TogglerIcon, { width: "16px", height: "16px", open: open, closeArrowPosition: "s", openArrowPosition: "n", onClick: onClick ? (open ? onCollapse : onDrop) : undefined }) })] }), jsxRuntimeExports.jsx(Dropdown, { attachToBody: attachDropdownToBody, skidding: skidding, distance: distance, onUpdate: onUpdate, onDropStart: onDropStart, onDropping: onDropping, onDropDone: onDropDone, onCollapseStart: onCollapseStart, onCollapseDone: onCollapseDone, onCollapsing: onCollapsing, widthModifier: widthModifier, zIndex: zIndex, open: open, placement: placement, animationTimeout: animationTimeout, children: listElement })] }));
1693
+ const dropdownRef = useRef(null);
1694
+ useClickOutside([ref, dropdownRef], () => onCollapse && onCollapse());
1695
+ return (jsxRuntimeExports.jsxs("span", { ref: ref, children: [jsxRuntimeExports.jsxs(Button, { ...buttonProps, className: classNames, onClick: onClick ? undefined : open ? onCollapse : onDrop, ref: triggerRef, children: [jsxRuntimeExports.jsx("span", { className: "o-button-dropdown-content", onClick: onClick, children: children }), jsxRuntimeExports.jsx("span", { className: "o-button-dropdown-icon", children: jsxRuntimeExports.jsx(TogglerIcon, { width: "16px", height: "16px", open: open, closeArrowPosition: "s", openArrowPosition: "n", onClick: onClick ? (open ? onCollapse : onDrop) : undefined }) })] }), jsxRuntimeExports.jsx(Dropdown, { attachToBody: attachDropdownToBody, skidding: skidding, distance: distance, onUpdate: onUpdate, onDropStart: onDropStart, onDropping: onDropping, onDropDone: onDropDone, onCollapseStart: onCollapseStart, onCollapseDone: onCollapseDone, onCollapsing: onCollapsing, widthModifier: widthModifier, zIndex: zIndex, open: open, placement: placement, animationTimeout: animationTimeout, children: jsxRuntimeExports.jsx("div", { ref: dropdownRef, children: listElement }) })] }));
1695
1696
  };
1696
1697
 
1697
1698
  const DropdownButton = styled(DropdownButtonComponent) `
@@ -2094,25 +2095,6 @@ const Card = styled(CardComponent) `
2094
2095
  ${cardStyle}
2095
2096
  `;
2096
2097
 
2097
- const titlelize = (value) => {
2098
- return value
2099
- .split('_')
2100
- .map((v) => ucfirst(v))
2101
- .join(' ');
2102
- };
2103
-
2104
- const FormCardDisplayerComponent = (displayerProps) => {
2105
- const total = Object.values(displayerProps.children ?? {}).length;
2106
- return (jsxRuntimeExports.jsxs("div", { className: addClassname('o-displayer-card', displayerProps.className), children: [jsxRuntimeExports.jsx("div", { className: "o-displayer-card-title", children: displayerProps.name }), Object.values(displayerProps.children ?? {}).map((field, index) => {
2107
- const Displayer = field.Displayer ?? DefaultDisplayer;
2108
- return (createElement(Displayer, { ...field, index: index, key: `field-${index}`, first: index === 0, last: index === total - 1, format: displayerProps.format }));
2109
- })] }));
2110
- };
2111
-
2112
- const FormCardDisplayer = styled(FormCardDisplayerComponent) `
2113
- ${formCardDisplayerStyle}
2114
- `;
2115
-
2116
2098
  const getIconDivProps = (props) => {
2117
2099
  const { color, marginRight, marginLeft, ...result } = props;
2118
2100
  return result;
@@ -2306,15 +2288,25 @@ const Alert = styled(AlertComponent) `
2306
2288
  ${alertStyle}
2307
2289
  `;
2308
2290
 
2309
- const FormCard = ({ name, help, children, visible, disabled, ...cardProps }) => {
2291
+ const FormBlockDisplayerComponent = (displayerProps) => {
2292
+ const total = Object.values(displayerProps.children ?? {}).length;
2293
+ return (jsxRuntimeExports.jsx("div", { className: addClassname('o-displayer-block', displayerProps.className), children: Object.values(displayerProps.children ?? {}).map((field, index) => {
2294
+ const Displayer = field.Displayer ?? DefaultDisplayer;
2295
+ return createElement(Displayer, { ...field, index: index, key: `field-${index}`, first: index === 0, last: index === total - 1, format: displayerProps.format });
2296
+ }) }));
2297
+ };
2298
+
2299
+ const FormBlockDisplayer = styled(FormBlockDisplayerComponent) `
2300
+ `;
2301
+
2302
+ const FormBlock = ({ name, help, children, visible, disabled, className }) => {
2310
2303
  const decorator = useFormDecorator(name, {
2311
2304
  Displayer: (displayerProps) => {
2312
- return (jsxRuntimeExports.jsx(FormCardDisplayer, { ...displayerProps, name: typeof cardProps.title === 'string' ? cardProps.title : titlelize(name) }));
2305
+ return jsxRuntimeExports.jsx(FormBlockDisplayer, { ...displayerProps });
2313
2306
  },
2314
2307
  visible,
2315
2308
  disabled,
2316
2309
  });
2317
- const form = useForm();
2318
2310
  const metadata = useFormMetadata(decorator.name);
2319
2311
  const fieldContainer = useFieldContainer({
2320
2312
  container: name,
@@ -2356,28 +2348,37 @@ const FormCard = ({ name, help, children, visible, disabled, ...cardProps }) =>
2356
2348
  if (metadata.visible === false) {
2357
2349
  return null;
2358
2350
  }
2359
- return (jsxRuntimeExports.jsx(FormContext.Provider, { value: fieldContainer.context, children: jsxRuntimeExports.jsx(Card, { ...cardProps, open: !metadata.disabled, onToggle: () => (metadata.disabled ? form.enable(decorator.name) : form.disable(decorator.name)), children: jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [help && (jsxRuntimeExports.jsx(Alert, { kind: "info", size: "small", marginBottom: "2xl", children: help })), children] }) }) }));
2351
+ return (jsxRuntimeExports.jsx(FormContext.Provider, { value: fieldContainer.context, children: jsxRuntimeExports.jsxs("div", { className: addClassname('o-form-block', className), children: [help && (jsxRuntimeExports.jsx(Alert, { kind: "info", size: "small", marginBottom: "2xl", children: help })), children] }) }));
2360
2352
  };
2361
2353
 
2362
- const FormBlockDisplayerComponent = (displayerProps) => {
2354
+ const titlelize = (value) => {
2355
+ return value
2356
+ .split('_')
2357
+ .map((v) => ucfirst(v))
2358
+ .join(' ');
2359
+ };
2360
+
2361
+ const FormCardDisplayerComponent = (displayerProps) => {
2363
2362
  const total = Object.values(displayerProps.children ?? {}).length;
2364
- return (jsxRuntimeExports.jsx("div", { className: addClassname('o-displayer-block', displayerProps.className), children: Object.values(displayerProps.children ?? {}).map((field, index) => {
2365
- const Displayer = field.Displayer ?? DefaultDisplayer;
2366
- return createElement(Displayer, { ...field, index: index, key: `field-${index}`, first: index === 0, last: index === total - 1, format: displayerProps.format });
2367
- }) }));
2363
+ return (jsxRuntimeExports.jsxs("div", { className: addClassname('o-displayer-card', displayerProps.className), children: [jsxRuntimeExports.jsx("div", { className: "o-displayer-card-title", children: displayerProps.name }), Object.values(displayerProps.children ?? {}).map((field, index) => {
2364
+ const Displayer = field.Displayer ?? DefaultDisplayer;
2365
+ return (createElement(Displayer, { ...field, index: index, key: `field-${index}`, first: index === 0, last: index === total - 1, format: displayerProps.format }));
2366
+ })] }));
2368
2367
  };
2369
2368
 
2370
- const FormBlockDisplayer = styled(FormBlockDisplayerComponent) `
2369
+ const FormCardDisplayer = styled(FormCardDisplayerComponent) `
2370
+ ${formCardDisplayerStyle}
2371
2371
  `;
2372
2372
 
2373
- const FormBlock = ({ name, help, children, visible, disabled, className }) => {
2373
+ const FormCard = ({ name, help, children, visible, disabled, ...cardProps }) => {
2374
2374
  const decorator = useFormDecorator(name, {
2375
2375
  Displayer: (displayerProps) => {
2376
- return jsxRuntimeExports.jsx(FormBlockDisplayer, { ...displayerProps });
2376
+ return (jsxRuntimeExports.jsx(FormCardDisplayer, { ...displayerProps, name: typeof cardProps.title === 'string' ? cardProps.title : titlelize(name) }));
2377
2377
  },
2378
2378
  visible,
2379
2379
  disabled,
2380
2380
  });
2381
+ const form = useForm();
2381
2382
  const metadata = useFormMetadata(decorator.name);
2382
2383
  const fieldContainer = useFieldContainer({
2383
2384
  container: name,
@@ -2419,7 +2420,7 @@ const FormBlock = ({ name, help, children, visible, disabled, className }) => {
2419
2420
  if (metadata.visible === false) {
2420
2421
  return null;
2421
2422
  }
2422
- return (jsxRuntimeExports.jsx(FormContext.Provider, { value: fieldContainer.context, children: jsxRuntimeExports.jsxs("div", { className: addClassname('o-form-block', className), children: [help && (jsxRuntimeExports.jsx(Alert, { kind: "info", size: "small", marginBottom: "2xl", children: help })), children] }) }));
2423
+ return (jsxRuntimeExports.jsx(FormContext.Provider, { value: fieldContainer.context, children: jsxRuntimeExports.jsx(Card, { ...cardProps, open: !metadata.disabled, onToggle: () => (metadata.disabled ? form.enable(decorator.name) : form.disable(decorator.name)), children: jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [help && (jsxRuntimeExports.jsx(Alert, { kind: "info", size: "small", marginBottom: "2xl", children: help })), children] }) }) }));
2423
2424
  };
2424
2425
 
2425
2426
  const CheckboxComponent = ({ label, className = '', onChange, value = false, bordered = true, status, ...checkboxProps }) => {
@@ -3046,6 +3047,76 @@ const FormCheckbox = React.memo((props) => {
3046
3047
  });
3047
3048
  FormCheckbox.displayName = 'FormCheckbox';
3048
3049
 
3050
+ const contextMenuStyle = () => {
3051
+ return css `
3052
+ ${preflight()}
3053
+ ${zIndex(9999)}
3054
+ `;
3055
+ };
3056
+
3057
+ const ContextMenuComponent = ({ refElement, className, children, offsetX = 0, offsetY = 0 }) => {
3058
+ const [visible, setVisible] = useState(false);
3059
+ const { floatingStyles, refs } = useFloating({
3060
+ placement: 'bottom-start',
3061
+ middleware: [offset({ crossAxis: offsetX, mainAxis: offsetY }), flip(), shift()],
3062
+ whileElementsMounted: autoUpdate,
3063
+ });
3064
+ // Handle the right-click event
3065
+ const handleContextMenu = useCallback((e) => {
3066
+ e.preventDefault(); // Prevent the browser's default context menu
3067
+ const x = e.clientX;
3068
+ const y = e.clientY;
3069
+ // Define a VirtualElement object that implements getBoundingClientRect
3070
+ const newVirtualElement = {
3071
+ getBoundingClientRect: () => ({
3072
+ width: 0,
3073
+ height: 0,
3074
+ top: y,
3075
+ right: x,
3076
+ bottom: y,
3077
+ left: x,
3078
+ x: x,
3079
+ y: y,
3080
+ toJSON: () => { },
3081
+ }),
3082
+ };
3083
+ refs.setPositionReference(newVirtualElement);
3084
+ setVisible(true);
3085
+ }, []);
3086
+ // Close the menu on left click or scroll
3087
+ useEffect(() => {
3088
+ const closeMenu = () => setVisible(false);
3089
+ window.addEventListener('click', closeMenu);
3090
+ window.addEventListener('scroll', closeMenu);
3091
+ if (refElement instanceof HTMLElement) {
3092
+ refElement.addEventListener('contextmenu', handleContextMenu);
3093
+ }
3094
+ else if (refElement.current !== null) {
3095
+ refElement.current.addEventListener('contextmenu', handleContextMenu);
3096
+ }
3097
+ return () => {
3098
+ window.removeEventListener('click', closeMenu);
3099
+ window.removeEventListener('scroll', closeMenu);
3100
+ if (refElement instanceof HTMLElement) {
3101
+ refElement.removeEventListener('contextmenu', handleContextMenu);
3102
+ }
3103
+ else if (refElement.current !== null) {
3104
+ refElement.current.removeEventListener('contextmenu', handleContextMenu);
3105
+ }
3106
+ };
3107
+ }, []);
3108
+ if (visible) {
3109
+ return (jsxRuntimeExports.jsx("div", { ref: refs.setFloating, className: addClassname('o-context-menu', className), style: {
3110
+ ...floatingStyles,
3111
+ }, children: children }));
3112
+ }
3113
+ return null;
3114
+ };
3115
+
3116
+ const ContextMenu = styled(ContextMenuComponent) `
3117
+ ${contextMenuStyle}
3118
+ `;
3119
+
3049
3120
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
3050
3121
  const DashboardServiceContext = React.createContext(null);
3051
3122
  const useDashboardService = () => {
@@ -4618,24 +4689,6 @@ const useDashboardController = () => {
4618
4689
  return service;
4619
4690
  };
4620
4691
 
4621
- const RefreshIconComponent = (props) => {
4622
- return (jsxRuntimeExports.jsx("div", { ...getIconDivProps(props), children: jsxRuntimeExports.jsx("svg", { className: "o-icon-refresh-svg", stroke: "currentColor", fill: "none", strokeWidth: "2", viewBox: "0 0 24 24", "aria-hidden": "true", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" }) }) }));
4623
- };
4624
- var RefreshIcon = styled(RefreshIconComponent) `
4625
- ${({ width = '16px', height = '16px', color: cssColor = 'inherit', marginLeft: ml = '0', marginRight: mr = '0', }) => css `
4626
- width: ${width};
4627
- height: ${height};
4628
- ${marginLeft(ml)}
4629
- ${marginRight(mr)}
4630
- ${display('flex')};
4631
- ${alignItems('center')};
4632
- ${color(cssColor)}
4633
- .o-icon-refresh-svg {
4634
- display: inline-block;
4635
- }
4636
- `}
4637
- `;
4638
-
4639
4692
  const useDashboardHorizontalPanel = (area) => {
4640
4693
  const state = useContext(DashboardStateContext);
4641
4694
  return area === 'header' ? state.header : state.footer;
@@ -4649,76 +4702,6 @@ const useDashoardBodyPanel = () => {
4649
4702
  return state.body;
4650
4703
  };
4651
4704
 
4652
- const contextMenuStyle = () => {
4653
- return css `
4654
- ${preflight()}
4655
- ${zIndex(9999)}
4656
- `;
4657
- };
4658
-
4659
- const ContextMenuComponent = ({ refElement, className, children, offsetX = 0, offsetY = 0 }) => {
4660
- const [visible, setVisible] = useState(false);
4661
- const { floatingStyles, refs } = useFloating({
4662
- placement: 'bottom-start',
4663
- middleware: [offset({ crossAxis: offsetX, mainAxis: offsetY }), flip(), shift()],
4664
- whileElementsMounted: autoUpdate,
4665
- });
4666
- // Handle the right-click event
4667
- const handleContextMenu = useCallback((e) => {
4668
- e.preventDefault(); // Prevent the browser's default context menu
4669
- const x = e.clientX;
4670
- const y = e.clientY;
4671
- // Define a VirtualElement object that implements getBoundingClientRect
4672
- const newVirtualElement = {
4673
- getBoundingClientRect: () => ({
4674
- width: 0,
4675
- height: 0,
4676
- top: y,
4677
- right: x,
4678
- bottom: y,
4679
- left: x,
4680
- x: x,
4681
- y: y,
4682
- toJSON: () => { },
4683
- }),
4684
- };
4685
- refs.setPositionReference(newVirtualElement);
4686
- setVisible(true);
4687
- }, []);
4688
- // Close the menu on left click or scroll
4689
- useEffect(() => {
4690
- const closeMenu = () => setVisible(false);
4691
- window.addEventListener('click', closeMenu);
4692
- window.addEventListener('scroll', closeMenu);
4693
- if (refElement instanceof HTMLElement) {
4694
- refElement.addEventListener('contextmenu', handleContextMenu);
4695
- }
4696
- else if (refElement.current !== null) {
4697
- refElement.current.addEventListener('contextmenu', handleContextMenu);
4698
- }
4699
- return () => {
4700
- window.removeEventListener('click', closeMenu);
4701
- window.removeEventListener('scroll', closeMenu);
4702
- if (refElement instanceof HTMLElement) {
4703
- refElement.removeEventListener('contextmenu', handleContextMenu);
4704
- }
4705
- else if (refElement.current !== null) {
4706
- refElement.current.removeEventListener('contextmenu', handleContextMenu);
4707
- }
4708
- };
4709
- }, []);
4710
- if (visible) {
4711
- return (jsxRuntimeExports.jsx("div", { ref: refs.setFloating, className: addClassname('o-context-menu', className), style: {
4712
- ...floatingStyles,
4713
- }, children: children }));
4714
- }
4715
- return null;
4716
- };
4717
-
4718
- const ContextMenu = styled(ContextMenuComponent) `
4719
- ${contextMenuStyle}
4720
- `;
4721
-
4722
4705
  const IconComponent$8 = ({ className, onClick }) => {
4723
4706
  return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsxs("svg", { className: "o-icon-close-all-svg", viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntimeExports.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M8.621 8.086l-.707-.707L6.5 8.793 5.086 7.379l-.707.707L5.793 9.5l-1.414 1.414.707.707L6.5 10.207l1.414 1.414.707-.707L7.207 9.5l1.414-1.414z" }), jsxRuntimeExports.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M5 3l1-1h7l1 1v7l-1 1h-2v2l-1 1H3l-1-1V6l1-1h2V3zm1 2h4l1 1v4h2V3H6v2zm4 1H3v7h7V6z" })] }) }));
4724
4707
  };
@@ -4795,6 +4778,24 @@ var FolderIcon = styled(IconComponent$5) `
4795
4778
  `}
4796
4779
  `;
4797
4780
 
4781
+ const RefreshIconComponent = (props) => {
4782
+ return (jsxRuntimeExports.jsx("div", { ...getIconDivProps(props), children: jsxRuntimeExports.jsx("svg", { className: "o-icon-refresh-svg", stroke: "currentColor", fill: "none", strokeWidth: "2", viewBox: "0 0 24 24", "aria-hidden": "true", xmlns: "http://www.w3.org/2000/svg", children: jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" }) }) }));
4783
+ };
4784
+ var RefreshIcon = styled(RefreshIconComponent) `
4785
+ ${({ width = '16px', height = '16px', color: cssColor = 'inherit', marginLeft: ml = '0', marginRight: mr = '0', }) => css `
4786
+ width: ${width};
4787
+ height: ${height};
4788
+ ${marginLeft(ml)}
4789
+ ${marginRight(mr)}
4790
+ ${display('flex')};
4791
+ ${alignItems('center')};
4792
+ ${color(cssColor)}
4793
+ .o-icon-refresh-svg {
4794
+ display: inline-block;
4795
+ }
4796
+ `}
4797
+ `;
4798
+
4798
4799
  const IconComponent$4 = ({ className, onClick }) => {
4799
4800
  return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsx("svg", { className: "o-icon-search-svg", viewBox: "0 0 118.783 118.783", children: jsxRuntimeExports.jsx("path", { d: "M115.97,101.597L88.661,74.286c4.64-7.387,7.333-16.118,7.333-25.488c0-26.509-21.49-47.996-47.998-47.996\n\t\tS0,22.289,0,48.798c0,26.51,21.487,47.995,47.996,47.995c10.197,0,19.642-3.188,27.414-8.605l26.984,26.986\n\t\tc1.875,1.873,4.333,2.806,6.788,2.806c2.458,0,4.913-0.933,6.791-2.806C119.72,111.423,119.72,105.347,115.97,101.597z\n\t\t M47.996,81.243c-17.917,0-32.443-14.525-32.443-32.443s14.526-32.444,32.443-32.444c17.918,0,32.443,14.526,32.443,32.444\n\t\tS65.914,81.243,47.996,81.243z" }) }) }));
4800
4801
  };
@@ -8354,16 +8355,6 @@ const FormAutoComplete = (props) => {
8354
8355
  return (jsxRuntimeExports.jsx(FormSelect, { NotFoundComponent: null, IconComponent: null, autoCompleteAdapter: adapter, openOnFocus: true, ...props, mode: "autocomplete", autoCompleteSearch: false, validateValue: false, searchable: true, clickable: false }));
8355
8356
  };
8356
8357
 
8357
- class DefaultSelectBroker extends DefaultCollectionBroker {
8358
- defaultValue;
8359
- setDefaultValue(defaultValue, subscriberId) {
8360
- if (subscriberId === undefined) {
8361
- this.defaultValue = defaultValue;
8362
- }
8363
- this._getSubscribers(subscriberId).forEach((s) => s.setDefaultValue(defaultValue));
8364
- }
8365
- }
8366
-
8367
8358
  const useTreeInitialState = (dataSource, options) => {
8368
8359
  return useCollectionInitialState(dataSource, options);
8369
8360
  };
@@ -9498,11 +9489,21 @@ const TreeSelectComponent$1 = (props) => {
9498
9489
  TreeSelectComponent$1.displayName = 'TreeSelectComponent';
9499
9490
  var TreeSelectComponent = React.memo(TreeSelectComponent$1);
9500
9491
 
9501
- const TreeSelect = styled(TreeSelectComponent) `
9502
- ${selectStyle}
9503
- `;
9504
-
9505
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
9492
+ class DefaultSelectBroker extends DefaultCollectionBroker {
9493
+ defaultValue;
9494
+ setDefaultValue(defaultValue, subscriberId) {
9495
+ if (subscriberId === undefined) {
9496
+ this.defaultValue = defaultValue;
9497
+ }
9498
+ this._getSubscribers(subscriberId).forEach((s) => s.setDefaultValue(defaultValue));
9499
+ }
9500
+ }
9501
+
9502
+ const TreeSelect = styled(TreeSelectComponent) `
9503
+ ${selectStyle}
9504
+ `;
9505
+
9506
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
9506
9507
  const TabsServiceContext = React.createContext(null);
9507
9508
  const useTabsService = () => {
9508
9509
  return useContext(TabsServiceContext);
@@ -11065,221 +11066,6 @@ const useFormTableContext = () => {
11065
11066
  return useContext(DefaultFormTableContext);
11066
11067
  };
11067
11068
 
11068
- const DefaultDeleteRowComponent = ({ rowIndex }) => {
11069
- const form = useForm();
11070
- const { tableName, onRemove } = useFormTableContext();
11071
- const removeRow = () => {
11072
- const row = form.getValue(`${tableName}.${rowIndex}`);
11073
- if (onRemove) {
11074
- onRemove(form, row, rowIndex);
11075
- }
11076
- else {
11077
- form.remove(tableName, rowIndex);
11078
- }
11079
- };
11080
- const metadata = useFormMetadata(tableName);
11081
- let disabled = false;
11082
- if (metadata.disabled || metadata.readOnly || (metadata.editable === false && form.config.reconfigure)) {
11083
- disabled = true;
11084
- }
11085
- return (jsxRuntimeExports.jsx("div", { className: `o-form-table-remove${disabled ? ' o-form-table-remove-disabled' : ''}`, onClick: removeRow, children: jsxRuntimeExports.jsx(RemoveIcon, { width: "14px", height: "14px" }) }));
11086
- };
11087
- const DefaultSelectRowComponent = ({ item }) => {
11088
- const { onSelect } = useFormTableContext();
11089
- const selected = item?.selected;
11090
- const toggle = (selected) => onSelect(item, selected);
11091
- return jsxRuntimeExports.jsx(Checkbox, { value: selected || false, onChange: toggle });
11092
- };
11093
- const FooterComponent = () => {
11094
- const form = useForm();
11095
- const { tableName, addLabel, maxLength, onAdd } = useFormTableContext();
11096
- const isSingleColumnTable = useTableColumns().find((c) => c.id === '');
11097
- const addRow = (e) => {
11098
- e.preventDefault();
11099
- onAdd(isSingleColumnTable ? undefined : {});
11100
- };
11101
- const currentSize = (form.getValue(tableName) || []).length;
11102
- if (maxLength !== undefined && currentSize >= maxLength)
11103
- return null;
11104
- return (jsxRuntimeExports.jsxs("div", { className: "o-form-table-add", onClick: addRow, children: [jsxRuntimeExports.jsx(TogglerIcon, { open: false, model: "plus", color: "currentColor" }), jsxRuntimeExports.jsx("span", { children: addLabel })] }));
11105
- };
11106
- const CheckAllComponent = () => {
11107
- const form = useForm();
11108
- const { tableName } = useFormTableContext();
11109
- const fieldValue = useValue(tableName);
11110
- const tableService = useTableService();
11111
- const isAllChecked = Array.isArray(fieldValue) && Array.isArray(fieldValue) && fieldValue.length > 0;
11112
- const toggle = (selected) => {
11113
- if (selected) {
11114
- const items = tableService.items.map((item) => item?.data).filter((data) => data !== undefined);
11115
- form.setValue(tableName, items);
11116
- }
11117
- else {
11118
- form.setValue(tableName, []);
11119
- }
11120
- };
11121
- return jsxRuntimeExports.jsx(Checkbox, { className: "o-form-table-check-all", value: isAllChecked, onChange: toggle });
11122
- };
11123
- const FormTableComponent = React.memo(({ addLabel = 'add', controller, value, onAdd, onChange, onRemove, className, name, format = 'auto', required, minLength, maxLength, showAddButton = true, DeleteRowComponent = DefaultDeleteRowComponent, SelectRowComponent = DefaultSelectRowComponent, ...props }) => {
11124
- const form = useForm();
11125
- const field = form.fields[name];
11126
- if (field) {
11127
- const validators = field.validators;
11128
- const minlengthValidator = (validators.minLength || validators.min);
11129
- if (minlengthValidator) {
11130
- minLength = minlengthValidator.length;
11131
- }
11132
- const maxlengthValidator = (validators.maxLength || validators.max);
11133
- if (maxlengthValidator) {
11134
- maxLength = maxlengthValidator.length;
11135
- }
11136
- }
11137
- const id = useId();
11138
- const tableService = controller.asService();
11139
- const formatRef = useLazyRef(() => {
11140
- if (format === 'auto') {
11141
- return value && value.length > 0 && typeof value[0] !== 'object' ? 'id' : 'object';
11142
- }
11143
- return format;
11144
- });
11145
- const [mounted, setMounted] = useState(false);
11146
- const formTableContext = useLazyRef(() => {
11147
- const onSelect = (item, selected) => {
11148
- const getId = (v) => {
11149
- return formatRef.current === 'id' ? v : v.id;
11150
- };
11151
- const currentValues = form.getValue(name, []);
11152
- const value = formatRef.current === 'id' ? item.id : item.data;
11153
- if (selected) {
11154
- onChange && onChange([value].concat(currentValues));
11155
- }
11156
- else {
11157
- onChange && onChange(currentValues.filter((v) => getId(v) !== getId(value)));
11158
- }
11159
- };
11160
- if (!onAdd) {
11161
- onAdd = (initialValue) => {
11162
- formTableContext.current.editable = true;
11163
- form.add(name, initialValue);
11164
- };
11165
- }
11166
- return { tableName: name, onSelect, onAdd, onRemove, addLabel, required, minLength, maxLength };
11167
- });
11168
- // listen on value change from the form
11169
- // for the initial value in the table controller
11170
- // delay the rendering of the table until the value has been set in the controller
11171
- useEffect(() => {
11172
- const watch = [name];
11173
- const listener = (value) => {
11174
- if (tableService.dataSource) {
11175
- tableService.setSelected('value', value || []);
11176
- }
11177
- else if (value !== undefined) {
11178
- tableService.setData(value);
11179
- }
11180
- };
11181
- form.onValueChange(id, listener, watch);
11182
- listener(value);
11183
- setMounted(true);
11184
- return () => {
11185
- form.offValueChange(id);
11186
- };
11187
- // eslint-disable-next-line react-hooks/exhaustive-deps
11188
- }, []);
11189
- useEffect(() => {
11190
- if (tableService.dataSource) {
11191
- tableService.addColumn({
11192
- id: 'system.select',
11193
- width: '50px',
11194
- filterable: false,
11195
- sortable: false,
11196
- CellComponent: SelectRowComponent,
11197
- TitleComponent: () => jsxRuntimeExports.jsx(CheckAllComponent, {}),
11198
- }, 0);
11199
- }
11200
- else {
11201
- tableService.addColumn({
11202
- id: 'system.insert',
11203
- width: '50px',
11204
- filterable: false,
11205
- sortable: false,
11206
- CellComponent: DeleteRowComponent,
11207
- className: 'o-form-table-remove-cell',
11208
- }, 0);
11209
- }
11210
- }, [tableService]);
11211
- if (!mounted)
11212
- return null;
11213
- return (jsxRuntimeExports.jsx(DefaultFormTableContext.Provider, { value: formTableContext.current, children: jsxRuntimeExports.jsx(ControllerTableComponent, { controller: controller, className: addClassname('o-form-table', className), FooterComponent: tableService.dataSource ? undefined : FooterComponent, footer: tableService.dataSource || !showAddButton || props.disabled ? false : true, NotFoundComponent: null, ...props }) }));
11214
- });
11215
- FormTableComponent.displayName = 'FormTable';
11216
-
11217
- const FormTableItemDisplayer = ({ value, columns, first, last, className, format, name, index, }) => {
11218
- const userColumns = columns.filter((c) => !c.id.startsWith('system.'));
11219
- const monoColumnTable = userColumns.length === 1 && !userColumns[0].id;
11220
- const classNames = monoColumnTable
11221
- ? 'o-form-mono-column-table-item-displayer'
11222
- : `o-form-table-item-displayer${first ? ' o-form-table-item-displayer-first' : ''}${last ? ' o-form-table-item-displayer-last' : ''}`;
11223
- return (jsxRuntimeExports.jsx("div", { className: addClassname(classNames, className), children: userColumns.map((column, colIndex) => {
11224
- const Displayer = column.Displayer;
11225
- if (Displayer) {
11226
- return (jsxRuntimeExports.jsx(Displayer, { column: column, firstRow: first, lastRow: last, rowIndex: index, firstCol: colIndex === 0, lastCol: colIndex === columns.length - 1, colIndex: colIndex, format: format, value: value, rowName: name }, `col-${colIndex}`));
11227
- }
11228
- return null;
11229
- }) }));
11230
- };
11231
-
11232
- const FormTableValueDisplayer$1 = ({ name, columns, value, format, className }) => {
11233
- if (!Array.isArray(value))
11234
- return null;
11235
- return (jsxRuntimeExports.jsx("div", { className: addClassname('o-form-table-displayer-value', className), children: value.map((v, index) => (jsxRuntimeExports.jsx(FormTableItemDisplayer, { value: v, columns: columns, first: index === 0, last: index === value.length - 1, format: format === 'csv' ? 'csv' : 'form_summary_table', name: `${name}.${index}`, index: index }, `item-${index}`))) }));
11236
- };
11237
- var FormTableValueDisplayer = styled(FormTableValueDisplayer$1) `
11238
- .o-form-table-item-displayer {
11239
- ${borderBottomColor('primary')}
11240
- ${borderBottomStyle('solid')}
11241
- ${borderBottomWidth('1px')}
11242
- ${paddingY('sm')}
11243
- &.o-form-table-item-displayer-last {
11244
- ${paddingBottom(0)}
11245
- ${borderBottomWidth(0)}
11246
- }
11247
- &.o-form-table-item-displayer-first {
11248
- ${paddingTop(0)}
11249
- }
11250
- }
11251
- `;
11252
-
11253
- const StyledFormTableComponent = styled(FormTableComponent) `
11254
- ${tableStyle}
11255
- `;
11256
- const FormTable = React.memo((props) => {
11257
- let defaultValue = props.defaultValue;
11258
- if (defaultValue === undefined) {
11259
- let minLength = (props.minLength ?? props.min) || 0;
11260
- if (props.required && minLength < 1) {
11261
- minLength = 1;
11262
- }
11263
- const isSingleColumnTable = props.controller.columns.find((c) => c.id === '');
11264
- defaultValue = minLength > 0 ? Array(minLength).fill(isSingleColumnTable ? undefined : {}) : [];
11265
- }
11266
- const [fieldLayoutProps, fieldComponentProps] = useFieldLayout(Object.assign({
11267
- defaultValue,
11268
- Displayer: (displayerProps) => {
11269
- const form = useForm();
11270
- let value = form.getValue(displayerProps.name) ?? [];
11271
- const ValueDisplayer = props.ValueDisplayer ?? FormTableValueDisplayer;
11272
- return (jsxRuntimeExports.jsx(FieldDisplayer, { label: displayerProps.label ?? titlelize(displayerProps.name), help: props.help, first: displayerProps.first, last: displayerProps.last, value: jsxRuntimeExports.jsx(ValueDisplayer, { name: displayerProps.name, value: value, columns: props.controller.columns, format: displayerProps.format }), format: displayerProps.format }));
11273
- },
11274
- }, props));
11275
- const fieldContainer = useFieldContainer({
11276
- container: props.name,
11277
- });
11278
- const Component = props.FieldComponent || StyledFormTableComponent;
11279
- return (jsxRuntimeExports.jsx(FieldLayout, { ...fieldLayoutProps, required: props.required, children: jsxRuntimeExports.jsx(FormContext.Provider, { value: fieldContainer.context, children: jsxRuntimeExports.jsx(Component, { ...fieldComponentProps, name: props.name, required: props.required, minLength: props.minLength ?? props.min, maxLength: props.maxLength ?? props.max }) }) }));
11280
- });
11281
- FormTable.displayName = 'FormTable';
11282
-
11283
11069
  const CheckboxCellComponent = (options) => {
11284
11070
  const CheckboxCellComponent = ({ item, column, rowIndex }) => {
11285
11071
  const { tableName, editable } = useFormTableContext();
@@ -11694,18 +11480,233 @@ const textareaColumn = (id, options) => {
11694
11480
  });
11695
11481
  };
11696
11482
 
11697
- const useCheckboxColumn = (id, options) => {
11698
- const column = useLazyRef(() => {
11699
- return checkboxColumn(id, options);
11700
- });
11701
- return column.current;
11483
+ const FormTableItemDisplayer = ({ value, columns, first, last, className, format, name, index, }) => {
11484
+ const userColumns = columns.filter((c) => !c.id.startsWith('system.'));
11485
+ const monoColumnTable = userColumns.length === 1 && !userColumns[0].id;
11486
+ const classNames = monoColumnTable
11487
+ ? 'o-form-mono-column-table-item-displayer'
11488
+ : `o-form-table-item-displayer${first ? ' o-form-table-item-displayer-first' : ''}${last ? ' o-form-table-item-displayer-last' : ''}`;
11489
+ return (jsxRuntimeExports.jsx("div", { className: addClassname(classNames, className), children: userColumns.map((column, colIndex) => {
11490
+ const Displayer = column.Displayer;
11491
+ if (Displayer) {
11492
+ return (jsxRuntimeExports.jsx(Displayer, { column: column, firstRow: first, lastRow: last, rowIndex: index, firstCol: colIndex === 0, lastCol: colIndex === columns.length - 1, colIndex: colIndex, format: format, value: value, rowName: name }, `col-${colIndex}`));
11493
+ }
11494
+ return null;
11495
+ }) }));
11702
11496
  };
11703
11497
 
11704
- const useColumns = (columns) => {
11705
- const ref = useRef(columns);
11706
- return ref.current;
11498
+ const FormTableValueDisplayer$1 = ({ name, columns, value, format, className }) => {
11499
+ if (!Array.isArray(value))
11500
+ return null;
11501
+ return (jsxRuntimeExports.jsx("div", { className: addClassname('o-form-table-displayer-value', className), children: value.map((v, index) => (jsxRuntimeExports.jsx(FormTableItemDisplayer, { value: v, columns: columns, first: index === 0, last: index === value.length - 1, format: format === 'csv' ? 'csv' : 'form_summary_table', name: `${name}.${index}`, index: index }, `item-${index}`))) }));
11707
11502
  };
11708
-
11503
+ var FormTableValueDisplayer = styled(FormTableValueDisplayer$1) `
11504
+ .o-form-table-item-displayer {
11505
+ ${borderBottomColor('primary')}
11506
+ ${borderBottomStyle('solid')}
11507
+ ${borderBottomWidth('1px')}
11508
+ ${paddingY('sm')}
11509
+ &.o-form-table-item-displayer-last {
11510
+ ${paddingBottom(0)}
11511
+ ${borderBottomWidth(0)}
11512
+ }
11513
+ &.o-form-table-item-displayer-first {
11514
+ ${paddingTop(0)}
11515
+ }
11516
+ }
11517
+ `;
11518
+
11519
+ const DefaultDeleteRowComponent = ({ rowIndex }) => {
11520
+ const form = useForm();
11521
+ const { tableName, onRemove } = useFormTableContext();
11522
+ const removeRow = () => {
11523
+ const row = form.getValue(`${tableName}.${rowIndex}`);
11524
+ if (onRemove) {
11525
+ onRemove(form, row, rowIndex);
11526
+ }
11527
+ else {
11528
+ form.remove(tableName, rowIndex);
11529
+ }
11530
+ };
11531
+ const metadata = useFormMetadata(tableName);
11532
+ let disabled = false;
11533
+ if (metadata.disabled || metadata.readOnly || (metadata.editable === false && form.config.reconfigure)) {
11534
+ disabled = true;
11535
+ }
11536
+ return (jsxRuntimeExports.jsx("div", { className: `o-form-table-remove${disabled ? ' o-form-table-remove-disabled' : ''}`, onClick: removeRow, children: jsxRuntimeExports.jsx(RemoveIcon, { width: "14px", height: "14px" }) }));
11537
+ };
11538
+ const DefaultSelectRowComponent = ({ item }) => {
11539
+ const { onSelect } = useFormTableContext();
11540
+ const selected = item?.selected;
11541
+ const toggle = (selected) => onSelect(item, selected);
11542
+ return jsxRuntimeExports.jsx(Checkbox, { value: selected || false, onChange: toggle });
11543
+ };
11544
+ const FooterComponent = () => {
11545
+ const form = useForm();
11546
+ const { tableName, addLabel, maxLength, onAdd } = useFormTableContext();
11547
+ const isSingleColumnTable = useTableColumns().find((c) => c.id === '');
11548
+ const addRow = (e) => {
11549
+ e.preventDefault();
11550
+ onAdd(isSingleColumnTable ? undefined : {});
11551
+ };
11552
+ const currentSize = (form.getValue(tableName) || []).length;
11553
+ if (maxLength !== undefined && currentSize >= maxLength)
11554
+ return null;
11555
+ return (jsxRuntimeExports.jsxs("div", { className: "o-form-table-add", onClick: addRow, children: [jsxRuntimeExports.jsx(TogglerIcon, { open: false, model: "plus", color: "currentColor" }), jsxRuntimeExports.jsx("span", { children: addLabel })] }));
11556
+ };
11557
+ const CheckAllComponent = () => {
11558
+ const form = useForm();
11559
+ const { tableName } = useFormTableContext();
11560
+ const fieldValue = useValue(tableName);
11561
+ const tableService = useTableService();
11562
+ const isAllChecked = Array.isArray(fieldValue) && Array.isArray(fieldValue) && fieldValue.length > 0;
11563
+ const toggle = (selected) => {
11564
+ if (selected) {
11565
+ const items = tableService.items.map((item) => item?.data).filter((data) => data !== undefined);
11566
+ form.setValue(tableName, items);
11567
+ }
11568
+ else {
11569
+ form.setValue(tableName, []);
11570
+ }
11571
+ };
11572
+ return jsxRuntimeExports.jsx(Checkbox, { className: "o-form-table-check-all", value: isAllChecked, onChange: toggle });
11573
+ };
11574
+ const FormTableComponent = React.memo(({ addLabel = 'add', controller, value, onAdd, onChange, onRemove, className, name, format = 'auto', required, minLength, maxLength, showAddButton = true, DeleteRowComponent = DefaultDeleteRowComponent, SelectRowComponent = DefaultSelectRowComponent, ...props }) => {
11575
+ const form = useForm();
11576
+ const field = form.fields[name];
11577
+ if (field) {
11578
+ const validators = field.validators;
11579
+ const minlengthValidator = (validators.minLength || validators.min);
11580
+ if (minlengthValidator) {
11581
+ minLength = minlengthValidator.length;
11582
+ }
11583
+ const maxlengthValidator = (validators.maxLength || validators.max);
11584
+ if (maxlengthValidator) {
11585
+ maxLength = maxlengthValidator.length;
11586
+ }
11587
+ }
11588
+ const id = useId();
11589
+ const tableService = controller.asService();
11590
+ const formatRef = useLazyRef(() => {
11591
+ if (format === 'auto') {
11592
+ return value && value.length > 0 && typeof value[0] !== 'object' ? 'id' : 'object';
11593
+ }
11594
+ return format;
11595
+ });
11596
+ const [mounted, setMounted] = useState(false);
11597
+ const formTableContext = useLazyRef(() => {
11598
+ const onSelect = (item, selected) => {
11599
+ const getId = (v) => {
11600
+ return formatRef.current === 'id' ? v : v.id;
11601
+ };
11602
+ const currentValues = form.getValue(name, []);
11603
+ const value = formatRef.current === 'id' ? item.id : item.data;
11604
+ if (selected) {
11605
+ onChange && onChange([value].concat(currentValues));
11606
+ }
11607
+ else {
11608
+ onChange && onChange(currentValues.filter((v) => getId(v) !== getId(value)));
11609
+ }
11610
+ };
11611
+ if (!onAdd) {
11612
+ onAdd = (initialValue) => {
11613
+ formTableContext.current.editable = true;
11614
+ form.add(name, initialValue);
11615
+ };
11616
+ }
11617
+ return { tableName: name, onSelect, onAdd, onRemove, addLabel, required, minLength, maxLength };
11618
+ });
11619
+ // listen on value change from the form
11620
+ // for the initial value in the table controller
11621
+ // delay the rendering of the table until the value has been set in the controller
11622
+ useEffect(() => {
11623
+ const watch = [name];
11624
+ const listener = (value) => {
11625
+ if (tableService.dataSource) {
11626
+ tableService.setSelected('value', value || []);
11627
+ }
11628
+ else if (value !== undefined) {
11629
+ tableService.setData(value);
11630
+ }
11631
+ };
11632
+ form.onValueChange(id, listener, watch);
11633
+ listener(value);
11634
+ setMounted(true);
11635
+ return () => {
11636
+ form.offValueChange(id);
11637
+ };
11638
+ // eslint-disable-next-line react-hooks/exhaustive-deps
11639
+ }, []);
11640
+ useEffect(() => {
11641
+ if (tableService.dataSource) {
11642
+ tableService.addColumn({
11643
+ id: 'system.select',
11644
+ width: '50px',
11645
+ filterable: false,
11646
+ sortable: false,
11647
+ CellComponent: SelectRowComponent,
11648
+ TitleComponent: () => jsxRuntimeExports.jsx(CheckAllComponent, {}),
11649
+ }, 0);
11650
+ }
11651
+ else {
11652
+ tableService.addColumn({
11653
+ id: 'system.insert',
11654
+ width: '50px',
11655
+ filterable: false,
11656
+ sortable: false,
11657
+ CellComponent: DeleteRowComponent,
11658
+ className: 'o-form-table-remove-cell',
11659
+ }, 0);
11660
+ }
11661
+ }, [tableService]);
11662
+ if (!mounted)
11663
+ return null;
11664
+ return (jsxRuntimeExports.jsx(DefaultFormTableContext.Provider, { value: formTableContext.current, children: jsxRuntimeExports.jsx(ControllerTableComponent, { controller: controller, className: addClassname('o-form-table', className), FooterComponent: tableService.dataSource ? undefined : FooterComponent, footer: tableService.dataSource || !showAddButton || props.disabled ? false : true, NotFoundComponent: null, ...props }) }));
11665
+ });
11666
+ FormTableComponent.displayName = 'FormTable';
11667
+
11668
+ const StyledFormTableComponent = styled(FormTableComponent) `
11669
+ ${tableStyle}
11670
+ `;
11671
+ const FormTable = React.memo((props) => {
11672
+ let defaultValue = props.defaultValue;
11673
+ if (defaultValue === undefined) {
11674
+ let minLength = (props.minLength ?? props.min) || 0;
11675
+ if (props.required && minLength < 1) {
11676
+ minLength = 1;
11677
+ }
11678
+ const isSingleColumnTable = props.controller.columns.find((c) => c.id === '');
11679
+ defaultValue = minLength > 0 ? Array(minLength).fill(isSingleColumnTable ? undefined : {}) : [];
11680
+ }
11681
+ const [fieldLayoutProps, fieldComponentProps] = useFieldLayout(Object.assign({
11682
+ defaultValue,
11683
+ Displayer: (displayerProps) => {
11684
+ const form = useForm();
11685
+ let value = form.getValue(displayerProps.name) ?? [];
11686
+ const ValueDisplayer = props.ValueDisplayer ?? FormTableValueDisplayer;
11687
+ return (jsxRuntimeExports.jsx(FieldDisplayer, { label: displayerProps.label ?? titlelize(displayerProps.name), help: props.help, first: displayerProps.first, last: displayerProps.last, value: jsxRuntimeExports.jsx(ValueDisplayer, { name: displayerProps.name, value: value, columns: props.controller.columns, format: displayerProps.format }), format: displayerProps.format }));
11688
+ },
11689
+ }, props));
11690
+ const fieldContainer = useFieldContainer({
11691
+ container: props.name,
11692
+ });
11693
+ const Component = props.FieldComponent || StyledFormTableComponent;
11694
+ return (jsxRuntimeExports.jsx(FieldLayout, { ...fieldLayoutProps, required: props.required, children: jsxRuntimeExports.jsx(FormContext.Provider, { value: fieldContainer.context, children: jsxRuntimeExports.jsx(Component, { ...fieldComponentProps, name: props.name, required: props.required, minLength: props.minLength ?? props.min, maxLength: props.maxLength ?? props.max }) }) }));
11695
+ });
11696
+ FormTable.displayName = 'FormTable';
11697
+
11698
+ const useCheckboxColumn = (id, options) => {
11699
+ const column = useLazyRef(() => {
11700
+ return checkboxColumn(id, options);
11701
+ });
11702
+ return column.current;
11703
+ };
11704
+
11705
+ const useColumns = (columns) => {
11706
+ const ref = useRef(columns);
11707
+ return ref.current;
11708
+ };
11709
+
11709
11710
  const useEnumColumn = (id, options) => {
11710
11711
  const column = useLazyRef(() => {
11711
11712
  return enumColumn(id, options);
@@ -11741,1957 +11742,2136 @@ const useSelectColumn = (id, options) => {
11741
11742
  return column.current;
11742
11743
  };
11743
11744
 
11744
- const useTextColumn = (id, options) => {
11745
+ const useTextareaColumn = (id, options) => {
11745
11746
  const column = useLazyRef(() => {
11746
- return textColumn(id, options);
11747
+ return textareaColumn(id, options);
11747
11748
  });
11748
11749
  return column.current;
11749
11750
  };
11750
11751
 
11751
- const useTextareaColumn = (id, options) => {
11752
+ const useTextColumn = (id, options) => {
11752
11753
  const column = useLazyRef(() => {
11753
- return textareaColumn(id, options);
11754
+ return textColumn(id, options);
11754
11755
  });
11755
11756
  return column.current;
11756
11757
  };
11757
11758
 
11758
- const TagComponent = ({ className, children, onClick, icon }) => {
11759
- return (jsxRuntimeExports.jsxs("div", { className: addClassname('o-tag', className), onClick: onClick, children: [icon && jsxRuntimeExports.jsx("span", { className: "o-tag-icon", children: icon }), children] }));
11760
- };
11759
+ const columnCount = cssProperty('column-count');
11760
+ const columnFill = cssProperty('column-fill');
11761
+ const columnRule = cssProperty('column-rule');
11762
+ const columnRuleColor = cssProperty(null, colorFormatter('column-rule-color'));
11763
+ const columnRuleStyle = cssProperty('column-rule-style');
11764
+ const columnRuleWidth = cssProperty('column-rule-width', pxFormatter);
11765
+ const columnSpan = cssProperty('column-span');
11766
+ const columnWidth = cssProperty('column-width', pxFormatter);
11767
+ const columns = cssProperty('columns');
11768
+ const grid = cssProperty('grid');
11769
+ const gridAutoColumns = cssProperty('grid-auto-columns');
11770
+ const gridAutoFlow = cssProperty('grid-auto-flow');
11771
+ const gridAutoRows = cssProperty('grid-auto-rows');
11772
+ const gridColumn = cssProperty('grid-column');
11773
+ const gridColumnEnd = cssProperty('grid-column-start');
11774
+ const gridColumnGap = columnGap;
11775
+ const gridColumnStart = cssProperty('grid-column-start');
11776
+ const gridGap = gap;
11777
+ const gridRow = cssProperty('grid-row');
11778
+ const gridRowEnd = cssProperty('grid-row-end');
11779
+ const gridRowGap = rowGap;
11780
+ const gridRowStart = cssProperty('grid-row-start');
11781
+ const gridTemplate = cssProperty('grid-template');
11782
+ const gridTemplateAreas = cssProperty('grid-template-areas');
11783
+ const gridTemplateColumns = cssProperty('grid-template-columns');
11784
+ const gridTemplateRows = cssProperty('grid-template-rows');
11761
11785
 
11762
- const tagStyle = ({ theme, kind, bgColor = 'primary', fontColor = 'white', size = 'small', onClick, marginBottom: mb = 0, marginLeft: ml = 0, marginRight: mr = 0, marginTop: mt = 0, }) => {
11763
- let fSize = 'sm';
11764
- let lHeight = 'md';
11765
- let pX = 'md';
11766
- let radius = 'sm';
11767
- const pt = '2xs';
11768
- if (size === 'small') {
11769
- fSize = 'xs';
11770
- lHeight = 'xs';
11771
- radius = 'xs';
11772
- pX = 'sm';
11773
- }
11774
- if (size === 'large') {
11775
- fSize = 'md';
11776
- lHeight = 'lg';
11777
- }
11786
+ const datePickerStyle = () => {
11778
11787
  return css `
11779
- ${display('inline-flex')}
11780
- ${alignItems('center')}
11781
- ${backgroundColor(kind ? theme.buttons[kind].bgColor : bgColor)}
11782
- ${marginLeft(ml)}
11783
- ${marginRight(mr)}
11784
- ${marginBottom(mb)}
11785
- ${marginTop(mt)}
11786
- ${lineHeight(lHeight)}
11787
- ${paddingX(pX)}
11788
- ${paddingTop(pt)}
11789
- ${color(kind ? theme.buttons[kind].color : fontColor)}
11790
- ${fontSize(fSize)}
11791
- ${cursor(onClick ? 'pointer' : 'inherit')}
11792
- ${borderRadius(radius)}
11793
- .o-tag-icon {
11794
- ${marginRight('xs')}
11795
- ${display('inline-flex')}
11788
+ .o-calendar {
11789
+ ${width('300px')}
11790
+ }
11791
+ .o-calendar-month {
11792
+ ${display('flex')}
11796
11793
  ${alignItems('center')}
11794
+ ${marginBottom('md')}
11795
+ ${columnGap('sm')}
11797
11796
  }
11798
- `;
11799
- };
11800
-
11801
- const Tag = styled(TagComponent) `
11802
- ${tagStyle}
11803
- `;
11804
11797
 
11805
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
11806
- const WizardServiceContext = React.createContext(null);
11807
- const useWizardService = () => {
11808
- return useContext(WizardServiceContext);
11809
- };
11798
+ .o-calendar-select-month {
11799
+ ${width(24)}
11800
+ }
11810
11801
 
11811
- const WizardStateContext = React.createContext(null);
11812
- const useWizardState = () => {
11813
- return useContext(WizardStateContext);
11814
- };
11802
+ .o-calendar-select-year {
11803
+ ${width(12)}
11804
+ }
11815
11805
 
11816
- const StepTitleContent = ({ member, index }) => {
11817
- return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [member.icon, jsxRuntimeExports.jsxs("span", { className: "o-step-title", children: [index, ". ", `${member.title}`] })] }));
11818
- };
11806
+ .o-calendar-day-container {
11807
+ ${display('grid')}
11808
+ ${color('light')}
11809
+ ${gridTemplateColumns('repeat(7, 1fr)')}
11810
+ grid-template-rows: repeat(7, min(30px));
11811
+ ${rowGap('5px')}
11812
+ ${columnGap('5px')}
11813
+ }
11814
+ .o-calendar-day-title {
11815
+ ${display('flex')}
11816
+ ${alignItems('center')}
11817
+ ${justifyContent('center')}
11818
+ ${color('dark')}
11819
+ }
11820
+ .o-calendar-day {
11821
+ ${display('flex')}
11822
+ ${alignItems('center')}
11823
+ ${justifyContent('center')}
11824
+ ${cursor('pointer')}
11825
+ ${borderRadius('md')}
11819
11826
 
11820
- const StepTitle = (props) => {
11821
- const { member, onActivate, TitleContentComponent = StepTitleContent } = props;
11822
- return (jsxRuntimeExports.jsx("div", { className: `o-step${member.active ? ' o-step-active' : ' o-step-inactive'}${member.disabled ? ' o-step-disabled' : ' o-step-enabled'}${member.visible ? ' o-step-visible' : ' o-step-hidden'}${member.touched || member.touching ? ' o-step-touched' : ' o-step-untouched'}${member.success ? ' o-step-success' : ''}${member.touchingWarning || (member.touched && member.warning) ? ' o-step-warning' : ''}${member.touchingError || (member.touched && member.error) ? ' o-step-error' : ''}${member.loading ? ' o-step-loading' : ''}`, onClick: () => onActivate(member), children: jsxRuntimeExports.jsx(TitleContentComponent, { ...props }) }));
11823
- };
11827
+ &:hover {
11828
+ ${backgroundColor('darkest')}
11829
+ ${color('white')}
11830
+ }
11831
+ }
11832
+ .o-calendar-day-in-month {
11833
+ ${color('darkest')}
11834
+ ${backgroundColor('lighter')}
11835
+ }
11836
+ .o-calendar-day-current {
11837
+ ${borderColor('darker')}
11838
+ ${borderWidth('2px')}
11839
+ ${borderStyle('solid')}
11840
+ ${fontWeight('medium')}
11841
+ }
11824
11842
 
11825
- const WizardContainer = ({ cancelLabel = 'Cancel', className, children, doneLabel = 'Submit', nextLabel = 'Next', onCancel, onDone, previousLabel = 'Previous', title, stepSize = 3, TitleComponent = StepTitle, TitleContentComponent, forwardOnly = true, hasSummaryStep = false, reviewLabel = 'Review and Submit', }) => {
11826
- const classNames = addClassname('o-wizard', className);
11827
- const state = useWizardState();
11828
- const service = useWizardService();
11829
- const lastStepUid = service.getLastStep()?.uid;
11830
- const activate = useCallback((step) => {
11831
- if (!step || step.disabled || (!step.touched && !step.touching))
11832
- return;
11833
- if (!step.active) {
11834
- service.activate(step.uid);
11835
- }
11836
- }, [service]);
11837
- const errorRef = useRef([]);
11838
- errorRef.current = [];
11839
- const indexRef = useRef(0);
11840
- indexRef.current = 0;
11841
- return (jsxRuntimeExports.jsxs(Row, { className: classNames, children: [jsxRuntimeExports.jsxs(Col, { size: stepSize, className: "o-wizard-step-panel", children: [title && jsxRuntimeExports.jsx("div", { className: "o-wizard-title", children: title }), state.members.map((step) => {
11842
- if (step.visible) {
11843
- indexRef.current++;
11844
- }
11845
- else {
11846
- return null;
11847
- }
11848
- if (step.error !== undefined) {
11849
- errorRef.current.push({
11850
- stepIndex: indexRef.current,
11851
- stepTitle: step.title,
11852
- errorMessage: step.error,
11853
- });
11854
- }
11855
- return (jsxRuntimeExports.jsx(TitleComponent, { member: step, onActivate: activate, index: indexRef.current, TitleContentComponent: TitleContentComponent }, `step-title-${step.uid}`));
11856
- })] }), jsxRuntimeExports.jsxs(Col, { size: (12 - stepSize), className: "o-wizard-content-panel", children: [jsxRuntimeExports.jsx("div", { className: "o-wizard-content", children: children }), jsxRuntimeExports.jsxs("div", { className: "o-wizard-control", children: [onCancel && (jsxRuntimeExports.jsx(Button, { kind: "primary", pattern: "flat", className: "o-wizard-control-button", type: "button", onClick: () => onCancel(), children: cancelLabel })), !service.isFirstStep() && (jsxRuntimeExports.jsx(Button, { kind: "primary", pattern: "outline", className: "o-wizard-control-button", onClick: () => service.previous(), type: "button", children: previousLabel })), !service.isLastStep() && (jsxRuntimeExports.jsx(Button, { kind: service.isCurrentStepInVisibleError() ? 'danger' : 'primary', pattern: "solid", className: "o-wizard-control-button", disabled: service.isCurrentStepInVisibleError(), onClick: () => service.next(), type: "button", children: nextLabel })), (service.isLastStep() || !forwardOnly) && (jsxRuntimeExports.jsx(SubmitButton, { kind: errorRef.current.length > 0 ? 'danger' : 'success', pattern: "solid", className: "o-wizard-control-button", disabled: errorRef.current.length > 0, onClick: hasSummaryStep && !service.isLastStep() && lastStepUid ? () => service.activate(lastStepUid) : onDone, type: "button", showErrors: true, children: hasSummaryStep && !service.isLastStep() ? reviewLabel : doneLabel }))] })] })] }));
11857
- };
11843
+ .o-calendar-day-in-range {
11844
+ ${backgroundColor('lightblue')}
11845
+ ${borderRadius('none')}
11846
+ ${color('white')}
11847
+ }
11858
11848
 
11859
- const ControlledWizardComponent = ({ Component = WizardContainer, controller, ...props }) => {
11860
- return (jsxRuntimeExports.jsx(WizardServiceContext.Provider, { value: controller, children: jsxRuntimeExports.jsx(WizardStateContext.Provider, { value: controller.state, children: jsxRuntimeExports.jsx(Component, { ...props }) }) }));
11861
- };
11849
+ .o-calendar-day-in-range-transient {
11850
+ ${backgroundColor('dark')}
11851
+ ${borderRadius('none')}
11852
+ ${color('white')}
11853
+ }
11862
11854
 
11863
- let WizardService = class WizardService extends TabsService {
11864
- activateNext() {
11865
- const nextStep = this.getNextStep();
11866
- if (nextStep) {
11867
- this.activate(nextStep.uid);
11868
- }
11855
+ .o-calendar-day-start-range,
11856
+ .o-calendar-day-start-range-transient {
11857
+ ${borderTopRightRadius('none')}
11858
+ ${borderBottomRightRadius('none')}
11869
11859
  }
11870
- activatePrevious() {
11871
- const previousStep = this.getPreviousStep();
11872
- if (previousStep) {
11873
- this.activate(previousStep.uid);
11874
- }
11860
+
11861
+ .o-calendar-day-end-range,
11862
+ .o-calendar-day-end-range-transient {
11863
+ ${borderTopLeftRadius('none')}
11864
+ ${borderBottomLeftRadius('none')}
11875
11865
  }
11876
- getCurrentStep() {
11877
- return this.state.members[this.getCurrentActiveIndex()];
11866
+
11867
+ .o-datepicker-dropdown-content {
11868
+ ${borderRadius('sm')}
11869
+ ${borderTopLeftRadius(0)}
11870
+ ${borderTopRightRadius(0)}
11871
+ ${boxShadow('lg')}
11872
+ ${zIndex(2000)}
11873
+ ${backgroundColor('white')}
11874
+ ${borderWidth(1)}
11875
+ ${borderColor('light')}
11876
+ ${marginTop('-1px')}
11877
+ ${padding('lg')}
11878
+ ${userSelect('none')}
11879
+ ${display('flex')}
11878
11880
  }
11879
- getNextStep() {
11880
- for (let i = this.getCurrentActiveIndex() + 1; i < this.state.members.length; i++) {
11881
- const step = this.state.members[i];
11882
- if (step && step.visible && !step.disabled) {
11883
- return step;
11884
- }
11881
+
11882
+ .o-datepicker-active {
11883
+ .o-calendar-day-active {
11884
+ ${color('white')}
11885
+ ${backgroundColor('primary')}
11886
+ ${fontWeight('medium')}
11887
+ &.o-calendar-day-end-range-transient {
11888
+ ${backgroundColor('darkest')}
11889
+ &.o-calendar-day-start-range {
11890
+ ${backgroundColor('primary')}
11891
+ }
11885
11892
  }
11886
- return undefined;
11887
- }
11888
- getLastStep() {
11889
- return this.state.members.filter((m) => m.visible && !m.disabled).slice(-1)[0];
11890
- }
11891
- getPreviousStep() {
11892
- for (let i = this.getCurrentActiveIndex() - 1; i >= 0; i--) {
11893
- const step = this.state.members[i];
11894
- if (step && step.visible && !step.disabled) {
11895
- return step;
11896
- }
11893
+ &.o-calendar-day-start-range-transient {
11894
+ ${backgroundColor('darkest')}
11897
11895
  }
11898
- return undefined;
11896
+ }
11899
11897
  }
11900
- isFirstStep() {
11901
- if (this.state.active) {
11902
- return this.state.members.filter((m) => m.visible)[0]?.uid === this.state.active;
11903
- }
11904
- return false;
11898
+
11899
+ .o-datepicker-input {
11900
+ input:read-only {
11901
+ ${cursor('pointer')}
11902
+ }
11905
11903
  }
11906
- isLastStep() {
11907
- if (this.state.active) {
11908
- return this.state.members.filter((m) => m.visible && !m.disabled).slice(-1)[0]?.uid === this.state.active;
11909
- }
11910
- return false;
11904
+
11905
+ .o-datepicker-icon {
11906
+ ${cursor('pointer')}
11907
+ ${display('flex')}
11908
+ ${alignItems('center')}
11911
11909
  }
11912
- isCurrentStepInError() {
11913
- if (this.state.active) {
11914
- const currentStep = this.getMember(this.state.active);
11915
- return currentStep?.error !== undefined;
11916
- }
11917
- return false;
11910
+
11911
+ .o-datepicker-remover {
11912
+ ${cursor('pointer')}
11913
+ ${color('light')}
11914
+ ${fontFamily('Arial')}
11915
+ ${paddingX('sm')}
11916
+ ${userSelect('none')}
11918
11917
  }
11919
- isCurrentStepInVisibleError() {
11920
- if (this.state.active) {
11921
- const currentStep = this.getMember(this.state.active);
11922
- return currentStep?.touchingError !== undefined;
11923
- }
11924
- return false;
11918
+
11919
+ .o-toggler-icon {
11920
+ ${cursor('pointer')}
11921
+ ${color('primary')}
11925
11922
  }
11926
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
11927
- *done() {
11928
- yield this.setSubmitting(true);
11929
- if (this.state.onDone) {
11930
- yield this.state.onDone();
11931
- }
11932
- yield this.setSubmitting(false);
11933
- }
11934
- next() {
11935
- if (this.isCurrentStepInError()) {
11936
- const currentStep = this.getCurrentStep();
11937
- if (currentStep) {
11938
- this.touched(currentStep.uid);
11939
- }
11940
- }
11941
- else {
11942
- let result = true;
11943
- if (this.state.onNext) {
11944
- result = this.state.onNext(this.getCurrentStep(), this.getNextStep());
11945
- }
11946
- if (result) {
11947
- this.activateNext();
11948
- }
11949
- }
11950
- }
11951
- previous() {
11952
- let result = true;
11953
- if (this.state.onPrevious) {
11954
- result = this.state.onPrevious(this.getCurrentStep(), this.getPreviousStep());
11955
- }
11956
- if (result) {
11957
- this.activatePrevious();
11958
- }
11959
- }
11960
- setSubmitting(submitting) {
11961
- this.state.submitting = submitting;
11962
- }
11963
- };
11964
- __decorate([
11965
- reducer,
11966
- __metadata("design:type", Function),
11967
- __metadata("design:paramtypes", []),
11968
- __metadata("design:returntype", void 0)
11969
- ], WizardService.prototype, "activateNext", null);
11970
- __decorate([
11971
- reducer,
11972
- __metadata("design:type", Function),
11973
- __metadata("design:paramtypes", []),
11974
- __metadata("design:returntype", void 0)
11975
- ], WizardService.prototype, "activatePrevious", null);
11976
- __decorate([
11977
- saga(SagaEffect.Leading)
11978
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
11979
- ,
11980
- __metadata("design:type", Function),
11981
- __metadata("design:paramtypes", []),
11982
- __metadata("design:returntype", void 0)
11983
- ], WizardService.prototype, "done", null);
11984
- __decorate([
11985
- reducer,
11986
- __metadata("design:type", Function),
11987
- __metadata("design:paramtypes", []),
11988
- __metadata("design:returntype", void 0)
11989
- ], WizardService.prototype, "next", null);
11990
- __decorate([
11991
- reducer,
11992
- __metadata("design:type", Function),
11993
- __metadata("design:paramtypes", []),
11994
- __metadata("design:returntype", void 0)
11995
- ], WizardService.prototype, "previous", null);
11996
- __decorate([
11997
- reducer,
11998
- __metadata("design:type", Function),
11999
- __metadata("design:paramtypes", [Boolean]),
12000
- __metadata("design:returntype", void 0)
12001
- ], WizardService.prototype, "setSubmitting", null);
12002
- WizardService = __decorate([
12003
- service
12004
- ], WizardService);
12005
-
12006
- const useWizardController = ({ animate = 300, forwardOnly = true, onCancel, onDone, onNext, onPrevious, }) => {
12007
- const [_, service] = useService(WizardService, {
12008
- members: [],
12009
- membersIndex: {},
12010
- animate,
12011
- forwardOnly,
12012
- onCancel,
12013
- onDone,
12014
- onNext,
12015
- onPrevious,
12016
- });
12017
- return service;
12018
- };
12019
11923
 
12020
- const UncontrolledWizardComponent = (props) => {
12021
- const controller = useWizardController(props);
12022
- return jsxRuntimeExports.jsx(ControlledWizardComponent, { ...props, controller: controller });
12023
- };
11924
+ .o-time-selector-part-icon-disabled {
11925
+ .o-toggler-icon {
11926
+ ${cursor('not-allowed')}
11927
+ ${color('light')}
11928
+ }
11929
+ }
12024
11930
 
12025
- const WizardComponent = (props) => {
12026
- if (props.controller) {
12027
- return jsxRuntimeExports.jsx(ControlledWizardComponent, { ...props, controller: props.controller });
11931
+ .o-time-container {
11932
+ ${marginLeft('3xl')}
11933
+ ${display('flex')}
11934
+ ${alignItems('center')}
11935
+ ${height('full')}
11936
+ .o-time-separator {
11937
+ ${marginX('lg')}
11938
+ }
12028
11939
  }
12029
- else {
12030
- return jsxRuntimeExports.jsx(UncontrolledWizardComponent, { ...props });
11940
+
11941
+ .o-time-selector-part-header {
11942
+ ${fontWeight('medium')}
11943
+ ${backgroundColor('lightest')}
11944
+ ${paddingX('sm')}
11945
+ ${whiteSpace('nowrap')}
12031
11946
  }
12032
- };
12033
11947
 
12034
- const wizardStyle = ({ layout = 'vertical', theme, inModal }) => {
12035
- const t = theme.wizard;
12036
- const stepBorderWidthFn = layout === 'horizontal' ? borderBottomWidth : borderLeftWidth;
12037
- const stepBorderStyleFn = layout === 'horizontal' ? borderBottomStyle : borderLeftStyle;
12038
- const stepBorderColorFn = layout === 'horizontal' ? borderBottomColor : borderLeftColor;
12039
- const wizardBorderWidthFn = layout === 'horizontal' ? borderBottomWidth : borderRightWidth;
12040
- const wizardBorderStyleFn = layout === 'horizontal' ? borderBottomStyle : borderRightStyle;
12041
- const wizardBorderColorFn = layout === 'horizontal' ? borderBottomColor : borderRightColor;
12042
- return css `
12043
- ${display('flex')}
12044
- ${flexDirection(layout === 'horizontal' ? 'column' : 'row')}
12045
- .o-wizard-step-panel {
11948
+ .o-time-selector {
12046
11949
  ${display('flex')}
12047
- ${flexDirection(layout === 'horizontal' ? 'row' : 'column')}
12048
- ${alignItems(layout === 'horizontal' ? 'flex-end' : 'stretch')}
12049
- ${wizardBorderStyleFn(inModal ? t.modalStepsBorderStyle : t.stepsBorderStyle)}
12050
- ${wizardBorderWidthFn(inModal ? t.modalStepsBorderWidth : t.stepsBorderWidth)}
12051
- ${wizardBorderColorFn(inModal ? t.modalStepsBorderColor : t.stepsBorderColor)}
12052
- ${paddingRight(t.stepsPaddingRight)}
12053
- ${paddingTop(t.stepsPaddingTop)}
12054
- ${paddingLeft(t.stepsPaddingLeft)}
12055
- ${paddingBottom(t.stepsPaddingBottom)}
12056
- ${backgroundColor(inModal ? t.modalStepsBgColor : t.stepsBgColor)}
11950
+ ${alignItems('center')}
12057
11951
  }
12058
11952
 
12059
- .o-step {
12060
- ${paddingRight(t.paddingRight)}
12061
- ${paddingTop(t.paddingTop)}
12062
- ${paddingLeft(t.paddingLeft)}
12063
- ${paddingBottom(t.paddingBottom)}
12064
- ${stepBorderStyleFn(t.borderStyle)}
12065
- ${stepBorderWidthFn(t.borderWidth)}
12066
- ${stepBorderColorFn(t.borderColor)}
12067
- ${fontWeight(t.fontWeight)}
12068
- ${fontSize(t.fontSize)}
12069
- ${color(t.fontColor)}
11953
+ .o-time-edge-title {
11954
+ ${fontWeight('bold')}
11955
+ ${marginBottom('xs')}
11956
+ ${borderBottomWidth('1px')}
11957
+ ${borderBottomColor('lighter')}
11958
+ ${borderBottomStyle('solid')}
11959
+ ${textTransform('uppercase')}
11960
+ ${color('primary')}
12070
11961
  }
12071
11962
 
12072
- .o-step-active {
12073
- ${stepBorderColorFn(t.activeBorderColor)}
12074
- ${color(t.activeFontColor)}
12075
- ${fontWeight(t.activeFontWeight)}
12076
- ${fontSize(t.activeFontSize)}
12077
- ${backgroundColor(t.activeBgColor)}
12078
- &.o-step-enabled {
12079
- ${cursor('default')}
12080
- }
11963
+ .o-time-edge-empty {
11964
+ ${color('dark')}
11965
+ ${fontStyle('italic')}
11966
+ ${marginTop('md')}
11967
+ }
12081
11968
 
12082
- &.o-step-warning {
12083
- ${stepBorderColorFn(t.warningBorderColor)}
12084
- ${color(t.warningFontColor)}
12085
- ${backgroundColor(t.warningBgColor)}
12086
- }
12087
- &.o-step-error {
12088
- ${stepBorderColorFn(t.errorBorderColor)}
12089
- ${color(t.errorFontColor)}
12090
- ${backgroundColor(t.errorBgColor)}
12091
- }
11969
+ .o-time-edge-date-container {
11970
+ ${width('150px')}
12092
11971
  }
12093
11972
 
12094
- .o-step-inactive {
12095
- &.o-step-success,
12096
- &.o-step-touched {
12097
- ${stepBorderColorFn(t.successBorderColor)}
12098
- ${color(t.successFontColor)}
12099
- }
12100
- &.o-step-warning {
12101
- ${stepBorderColorFn(t.warningBorderColor)}
12102
- ${color(t.warningFontColor)}
12103
- }
12104
- &.o-step-error {
12105
- ${stepBorderColorFn(t.errorBorderColor)}
12106
- ${color(t.errorFontColor)}
11973
+ .o-time-edge-date {
11974
+ ${fontWeight('medium')}
11975
+ ${backgroundColor('lightest')}
11976
+ ${paddingX('sm')}
11977
+ ${marginRight('md')}
11978
+ ${whiteSpace('nowrap')}
11979
+ }
11980
+
11981
+ .o-time-container-range {
11982
+ ${marginLeft('3xl')}
11983
+ ${display('flex')}
11984
+ ${justifyContent('center')}
11985
+ ${height('full')}
11986
+ ${flexDirection('column')}
11987
+ ${gap('xl')}
11988
+ .o-time-separator {
11989
+ ${marginX('sm')}
12107
11990
  }
12108
11991
  }
12109
11992
 
12110
- .o-step-enabled {
12111
- ${cursor(t.cursor)}
11993
+ .o-time-edge-content {
11994
+ ${display('flex')}
11995
+ ${alignItems('center')}
12112
11996
  }
12113
11997
 
12114
- .o-step-disabled,
12115
- .o-step-untouched {
12116
- ${cursor('default')}
12117
- ${stepBorderColorFn(t.disabledBorderColor)}
12118
- ${color(t.disabledFontColor)}
12119
- ${fontWeight(t.disabledFontWeight)}
12120
- ${fontSize(t.disabledFontSize)}
12121
- ${backgroundColor(t.disabledBgColor)}
11998
+ .o-time-separator {
11999
+ ${fontWeight('bold')}
12122
12000
  }
12123
12001
 
12124
- .o-step-disabled {
12125
- ${cursor('not-allowed')}
12126
- ${textDecoration('line-through')}
12002
+ .o-time-input {
12003
+ ${width(10)}
12004
+ .o-input-field {
12005
+ ${textAlign('center')}
12006
+ }
12127
12007
  }
12128
12008
 
12129
- .o-wizard-content-panel {
12009
+ .o-time-selector-part {
12130
12010
  ${display('flex')}
12131
12011
  ${flexDirection('column')}
12012
+ ${alignItems('center')}
12132
12013
  }
12133
12014
 
12134
- .o-wizard-content {
12135
- ${flexGrow(1)}
12136
- ${padding('lg')}
12137
- ${paddingBottom(0)}
12138
- ${paddingRight('3xl')}
12015
+ .o-time-selector-part-large.o-toggler-icon-container {
12016
+ ${marginY('md')}
12139
12017
  }
12140
12018
 
12141
- .o-wizard-control {
12142
- ${display('flex')}
12143
- ${justifyContent('flex-end')}
12144
- ${padding('lg')}
12019
+ .o-quick-time-range-container {
12020
+ ${paddingRight('2xl')}
12021
+ ${marginTop('2xl')}
12022
+ ${marginX('md')}
12145
12023
  }
12146
12024
 
12147
- .o-wizard-control-button {
12148
- ${marginLeft('sm')}
12149
- }
12150
-
12151
- .o-wizard-title {
12152
- ${fontSize('2xl')}
12153
- ${fontWeight('light')}
12154
- ${color('black')}
12155
- ${lineHeight('4xl')}
12156
- ${paddingBottom('md')}
12025
+ .o-quick-time-range-title {
12026
+ ${fontWeight('bold')}
12157
12027
  }
12158
12028
 
12159
- .o-step-content-title {
12160
- ${fontSize('2xl')}
12161
- ${fontWeight('light')}
12162
- ${color('black')}
12163
- ${lineHeight('4xl')}
12164
- ${paddingBottom('md')}
12029
+ .o-quick-time-range {
12030
+ ${cursor('pointer')}
12031
+ ${fontWeight('medium')}
12032
+ ${color('primary')}
12033
+ &.o-quick-time-range-selected {
12034
+ ${cursor('auto')}
12035
+ ${fontWeight('bold')}
12036
+ ${color('pink')}
12037
+ }
12165
12038
  }
12166
12039
  `;
12167
12040
  };
12168
- const wizardModalStyle = () => {
12169
- return css ``;
12041
+
12042
+ const months = [
12043
+ 'January',
12044
+ 'February',
12045
+ 'March',
12046
+ 'April',
12047
+ 'May',
12048
+ 'June',
12049
+ 'July',
12050
+ 'August',
12051
+ 'September',
12052
+ 'October',
12053
+ 'November',
12054
+ 'December',
12055
+ ];
12056
+ const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
12057
+ const isValidDate = (value) => {
12058
+ if (!value)
12059
+ return false;
12060
+ return /^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[13-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/.test(value);
12170
12061
  };
12171
- const wizardSummaryStyle = () => {
12172
- return css `
12173
- .o-accordion-panel {
12174
- ${paddingBottom('md')}
12175
- }
12176
- .o-accordion-panel-title {
12177
- ${backgroundColor('lighter')}
12178
- }
12179
- .o-accordion-content {
12180
- ${paddingX('sm')}
12181
- ${paddingBottom('sm')}
12182
- }
12183
- `;
12062
+ const isValidTime = (value) => {
12063
+ if (!value)
12064
+ return false;
12065
+ return /^(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])$/.test(value);
12184
12066
  };
12185
-
12186
- const Wizard = styled(WizardComponent) `
12187
- ${wizardStyle}
12188
- `;
12189
-
12190
- const WizardModalComponent = ({ title, doneLabel = 'Submit', ...props }) => {
12191
- return (jsxRuntimeExports.jsx(Modal, { ...props, children: jsxRuntimeExports.jsx(Wizard, { ...props, title: title, doneLabel: doneLabel, inModal: true }) }));
12067
+ const isValidMinuteOrSecond = (value) => {
12068
+ if (!value)
12069
+ return false;
12070
+ return /^(0?|[1-5])[0-9]$/.test(value);
12071
+ };
12072
+ const isValidHour = (value) => {
12073
+ if (!value)
12074
+ return false;
12075
+ return /^(2[0-3]|0?[0-9]|1[0-9])$/.test(value);
12192
12076
  };
12193
12077
 
12194
- const WizardModal = styled(WizardModalComponent) `
12195
- ${wizardModalStyle}
12078
+ const IconComponent$1 = ({ className, onClick }) => {
12079
+ return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsxs("svg", { className: "o-icon-calendar-svg", viewBox: "0 0 512 512", children: [jsxRuntimeExports.jsx("rect", { x: "48", y: "80", width: "416", height: "384", rx: "48", fill: "none", stroke: "currentColor", strokeLinejoin: "round", strokeWidth: "32" }), jsxRuntimeExports.jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M128 48v32M384 48v32M464 160H48M304 260l43.42-32H352v168M191.87 306.63c9.11 0 25.79-4.28 36.72-15.47a37.9 37.9 0 0011.13-27.26c0-26.12-22.59-39.9-47.89-39.9-21.4 0-33.52 11.61-37.85 18.93M149 374.16c4.88 8.27 19.71 25.84 43.88 25.84 28.59 0 52.12-15.94 52.12-43.82 0-12.62-3.66-24-11.58-32.07-12.36-12.64-31.25-17.48-41.55-17.48" })] }) }));
12080
+ };
12081
+ var CalendarIcon = styled(IconComponent$1) `
12082
+ ${({ width, height, color: cssColor = 'inherit', marginLeft: ml = '0', marginRight: mr = '0' }) => css `
12083
+ width: ${width};
12084
+ height: ${height};
12085
+ ${marginLeft(ml)}
12086
+ ${marginRight(mr)}
12087
+ ${display('flex')};
12088
+ ${alignItems('center')};
12089
+ ${color(cssColor)}
12090
+ .o-icon-calendar-svg {
12091
+ display: inline-block;
12092
+ stroke-width: 0;
12093
+ stroke: currentColor;
12094
+ fill: currentColor;
12095
+ }
12096
+ `}
12196
12097
  `;
12197
12098
 
12198
- const useStep = (props) => {
12199
- const service = useWizardService();
12200
- const state = useWizardState();
12201
- const step = state.members[state.membersIndex[props.uid]];
12202
- useEffect(() => {
12203
- if (step === undefined) {
12204
- service.initMember(Object.assign({ uid: props.uid }, props));
12205
- }
12206
- }, [props, service, step]);
12207
- return step;
12099
+ const DefaultDatePickerContext = React.createContext(null);
12100
+ const useDatePickerContext = () => {
12101
+ return useContext(DefaultDatePickerContext);
12208
12102
  };
12209
12103
 
12210
- const WizardSummaryComponent = ({ className }) => {
12211
- const form = useForm();
12212
- const tree = Object.values(form.getDisplayerTree());
12213
- return (jsxRuntimeExports.jsx(Accordion, { className: className, children: tree.map((field, index) => {
12214
- const Displayer = field.Displayer || DefaultDisplayer;
12215
- return (createElement(Displayer, { ...field, index: index, key: `field-${index}`, first: index === 0, last: index === tree.length - 1, format: "form_summary" }));
12216
- }) }));
12104
+ const dateToString = (d) => {
12105
+ if (typeof d === 'function') {
12106
+ d = d();
12107
+ }
12108
+ if (typeof d === 'string') {
12109
+ d = new Date(d);
12110
+ }
12111
+ return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}:${String(d.getSeconds()).padStart(2, '0')}`;
12217
12112
  };
12218
-
12219
- const WizardSummary = styled(WizardSummaryComponent) `
12220
- ${wizardSummaryStyle}
12221
- `;
12222
-
12223
- const Step = ({ title, active = false, disabled = false, visible = true, closable = false, children, icon, uid, optional = false, showTitle = true, className, onTouch, help, }) => {
12224
- const { animate, forwardOnly } = useWizardState();
12225
- const stepRef = useRef(null);
12226
- const step = useStep({
12227
- title,
12228
- active,
12229
- disabled,
12230
- visible,
12231
- closable,
12232
- icon,
12233
- loading: false,
12234
- optional,
12235
- touched: !forwardOnly,
12236
- touching: !forwardOnly,
12237
- uid: uid === undefined ? title : uid,
12238
- });
12239
- const touched = step?.touched;
12240
- const onEnter = () => {
12241
- const node = stepRef.current;
12242
- if (!node)
12243
- return;
12244
- node.style.opacity = '0';
12245
- };
12246
- const onEntering = () => {
12247
- const node = stepRef.current;
12248
- if (!node)
12249
- return;
12250
- setTimeout(() => {
12251
- node.style.opacity = '1';
12252
- node.style.transition = `opacity ${animate}ms ease-in-out`;
12253
- }, 0);
12254
- };
12255
- useEffect(() => {
12256
- if (touched && onTouch) {
12257
- onTouch();
12258
- }
12259
- }, [touched, onTouch]);
12260
- if (!step || !step.active) {
12113
+ const toDateRange = (value, label) => {
12114
+ if (value) {
12115
+ const [from, to] = value.trim().split(/ to\s*/);
12116
+ return {
12117
+ from: from && from.trim() ? from.trim() : null,
12118
+ to: to && to.trim() ? to.trim() : null,
12119
+ label,
12120
+ };
12121
+ }
12122
+ else {
12261
12123
  return null;
12262
12124
  }
12263
- return (jsxRuntimeExports.jsx(CSSTransition, { in: true, nodeRef: stepRef, timeout: animate, appear: true, onEnter: onEnter, onEntering: onEntering, children: jsxRuntimeExports.jsxs("div", { ref: stepRef, className: addClassname('o-step-content', className), children: [showTitle && jsxRuntimeExports.jsx("div", { className: "o-step-content-title", children: title }), help && (jsxRuntimeExports.jsx(Alert, { kind: "info", marginBottom: "lg", children: help })), children] }) }));
12264
12125
  };
12265
-
12266
- const FormStep = ({ name, disabled = false, visible = true, ...stepProps }) => {
12267
- const decorator = useFormDecorator(name, {
12268
- Displayer: (displayerProps) => {
12269
- const total = Object.values(displayerProps.children ?? {}).length;
12270
- return (jsxRuntimeExports.jsx(AccordionPanel, { title: stepProps.title, initialActive: displayerProps.index === 0, initialExpand: displayerProps.index === 0, children: Object.values(displayerProps.children ?? {}).map((field, index) => {
12271
- const Displayer = field.Displayer ?? DefaultDisplayer;
12272
- return (createElement(Displayer, { ...field, index: index, key: `field-${index}`, first: index === 0, last: index === total - 1, format: displayerProps.format }));
12273
- }) }));
12274
- },
12275
- });
12276
- const metadata = useFormMetadata(decorator.name);
12277
- const service = useWizardService();
12278
- const fieldContainer = useFieldContainer({
12279
- container: name,
12280
- onValidationChange: (touchedValidation, allValidation) => {
12281
- service.onValidationChange(name, touchedValidation, allValidation);
12282
- },
12283
- });
12284
- const { touchAllFields, hide, show, disable, enable } = fieldContainer;
12285
- const initializedRef = useRef(false);
12286
- useEffect(() => {
12287
- const visible = metadata.visible ?? true;
12288
- const disabled = metadata.disabled ?? false;
12289
- if (!visible) {
12290
- if (disabled) {
12291
- service.disable(name);
12292
- disable();
12293
- }
12294
- else {
12295
- service.enable(name);
12296
- if (initializedRef.current === true) {
12297
- // we only use the enable method if this is a change and not a initialization
12298
- enable();
12299
- }
12126
+ const qr = (quickRange) => {
12127
+ return {
12128
+ label: quickRange,
12129
+ from: () => {
12130
+ const d = new Date();
12131
+ switch (quickRange) {
12132
+ case 'Last hour':
12133
+ d.setHours(d.getHours() - 1);
12134
+ break;
12135
+ case 'Last day':
12136
+ d.setDate(d.getDate() - 1);
12137
+ break;
12138
+ case 'Last week':
12139
+ d.setDate(d.getDate() - 7);
12140
+ break;
12141
+ case 'Last month':
12142
+ d.setMonth(d.getMonth() - 1);
12143
+ break;
12144
+ case 'Last year':
12145
+ d.setFullYear(d.getFullYear() - 1);
12146
+ break;
12300
12147
  }
12301
- service.hide(name);
12302
- hide();
12148
+ return d;
12149
+ },
12150
+ to: () => new Date(),
12151
+ };
12152
+ };
12153
+ const defaultQuickRanges = () => {
12154
+ return ['Last hour', 'Last day', 'Last week', 'Last month', 'Last year'].reduce((accumulator, label) => {
12155
+ const quickRange = qr(label);
12156
+ if (quickRange) {
12157
+ accumulator[label] = quickRange;
12303
12158
  }
12304
- else {
12305
- service.show(name);
12306
- if (initializedRef.current === true) {
12307
- // we only use the show method if this is a change and not a initialization
12308
- show();
12309
- }
12310
- if (disabled) {
12311
- service.disable(name);
12312
- disable();
12313
- }
12314
- else {
12315
- service.enable(name);
12316
- if (initializedRef.current === true) {
12317
- // we only use the enable method if this is a change and not a initialization
12318
- enable();
12319
- }
12320
- }
12321
- }
12322
- initializedRef.current = true;
12323
- }, [name, metadata.visible, metadata.disabled]);
12324
- // useEffect(() => {
12325
- // if (!visible) {
12326
- // if (disabled) {
12327
- // disable();
12328
- // } else {
12329
- // enable();
12330
- // }
12331
- // hide();
12332
- // } else {
12333
- // show();
12334
- // if (disabled) {
12335
- // disable();
12336
- // } else {
12337
- // enable();
12338
- // }
12339
- // }
12340
- // }, [visible, disabled, hide, show, disable, enable]);
12341
- return (jsxRuntimeExports.jsx(FormContext.Provider, { value: fieldContainer.context, children: jsxRuntimeExports.jsx(Step, { ...stepProps, uid: name, onTouch: touchAllFields }) }));
12159
+ return accumulator;
12160
+ }, {});
12342
12161
  };
12343
-
12344
- const sliderStyle = () => {
12345
- return css ``;
12162
+ const findQuickRangeLabel = (quickRanges, dateRange) => {
12163
+ if (!quickRanges || !dateRange)
12164
+ return;
12165
+ const dr = typeof dateRange === 'string' ? toDateRange(dateRange) : dateRange;
12166
+ if (dr === null)
12167
+ return;
12168
+ if (!dr.from || !dr.to)
12169
+ return;
12170
+ return Object.keys(quickRanges).find((label) => {
12171
+ return dr.from === quickRanges[label].from && dr.to === quickRanges[label].to;
12172
+ });
12346
12173
  };
12347
-
12348
- const SliderComponent = () => {
12349
- return null;
12174
+ const isSameDay = (date1, date2) => {
12175
+ return (date1.getFullYear() === date2.getFullYear() &&
12176
+ date1.getMonth() === date2.getMonth() &&
12177
+ date1.getDate() === date2.getDate());
12350
12178
  };
12351
12179
 
12352
- const Resizer = styled(SliderComponent) `
12353
- ${sliderStyle}
12354
- `;
12355
-
12356
- const columnCount = cssProperty('column-count');
12357
- const columnFill = cssProperty('column-fill');
12358
- const columnRule = cssProperty('column-rule');
12359
- const columnRuleColor = cssProperty(null, colorFormatter('column-rule-color'));
12360
- const columnRuleStyle = cssProperty('column-rule-style');
12361
- const columnRuleWidth = cssProperty('column-rule-width', pxFormatter);
12362
- const columnSpan = cssProperty('column-span');
12363
- const columnWidth = cssProperty('column-width', pxFormatter);
12364
- const columns = cssProperty('columns');
12365
- const grid = cssProperty('grid');
12366
- const gridAutoColumns = cssProperty('grid-auto-columns');
12367
- const gridAutoFlow = cssProperty('grid-auto-flow');
12368
- const gridAutoRows = cssProperty('grid-auto-rows');
12369
- const gridColumn = cssProperty('grid-column');
12370
- const gridColumnEnd = cssProperty('grid-column-start');
12371
- const gridColumnGap = columnGap;
12372
- const gridColumnStart = cssProperty('grid-column-start');
12373
- const gridGap = gap;
12374
- const gridRow = cssProperty('grid-row');
12375
- const gridRowEnd = cssProperty('grid-row-end');
12376
- const gridRowGap = rowGap;
12377
- const gridRowStart = cssProperty('grid-row-start');
12378
- const gridTemplate = cssProperty('grid-template');
12379
- const gridTemplateAreas = cssProperty('grid-template-areas');
12380
- const gridTemplateColumns = cssProperty('grid-template-columns');
12381
- const gridTemplateRows = cssProperty('grid-template-rows');
12382
-
12383
- const datePickerStyle = () => {
12384
- return css `
12385
- .o-calendar {
12386
- ${width('300px')}
12387
- }
12388
- .o-calendar-month {
12389
- ${display('flex')}
12390
- ${alignItems('center')}
12391
- ${marginBottom('md')}
12392
- ${columnGap('sm')}
12393
- }
12394
-
12395
- .o-calendar-select-month {
12396
- ${width(24)}
12397
- }
12398
-
12399
- .o-calendar-select-year {
12400
- ${width(12)}
12180
+ const isCurrent = (d, year, month, day) => {
12181
+ return d.getFullYear() === year && d.getMonth() === month && d.getDate() === day;
12182
+ };
12183
+ const isActive = (date) => {
12184
+ return date.year !== undefined && date.month !== undefined && date.year !== undefined;
12185
+ };
12186
+ const inRange = (year, month, day, from, to) => {
12187
+ let fromDate;
12188
+ if (from.year !== undefined && from.month !== undefined && from.day !== undefined) {
12189
+ fromDate = new Date(`${from.year}-${from.month.padStart(2, '0')}-${String(from.day).padStart(2, '0')}`);
12401
12190
  }
12402
-
12403
- .o-calendar-day-container {
12404
- ${display('grid')}
12405
- ${color('light')}
12406
- ${gridTemplateColumns('repeat(7, 1fr)')}
12407
- grid-template-rows: repeat(7, min(30px));
12408
- ${rowGap('5px')}
12409
- ${columnGap('5px')}
12191
+ else {
12192
+ return false;
12410
12193
  }
12411
- .o-calendar-day-title {
12412
- ${display('flex')}
12413
- ${alignItems('center')}
12414
- ${justifyContent('center')}
12415
- ${color('dark')}
12194
+ let toDate;
12195
+ if (to.year !== undefined && to.month !== undefined && to.day !== undefined) {
12196
+ toDate = new Date(`${to.year}-${to.month.padStart(2, '0')}-${String(to.day).padStart(2, '0')}`);
12416
12197
  }
12417
- .o-calendar-day {
12418
- ${display('flex')}
12419
- ${alignItems('center')}
12420
- ${justifyContent('center')}
12421
- ${cursor('pointer')}
12422
- ${borderRadius('md')}
12423
-
12424
- &:hover {
12425
- ${backgroundColor('darkest')}
12426
- ${color('white')}
12427
- }
12198
+ else {
12199
+ return false;
12428
12200
  }
12429
- .o-calendar-day-in-month {
12430
- ${color('darkest')}
12431
- ${backgroundColor('lighter')}
12201
+ let currentDate = new Date(`${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`);
12202
+ return (currentDate > fromDate && currentDate < toDate) || (currentDate < fromDate && currentDate > toDate);
12203
+ };
12204
+ const isInversedDate = (from, to) => {
12205
+ if (!isActive(from) || !isActive(to)) {
12206
+ return false;
12432
12207
  }
12433
- .o-calendar-day-current {
12434
- ${borderColor('darker')}
12435
- ${borderWidth('2px')}
12436
- ${borderStyle('solid')}
12437
- ${fontWeight('medium')}
12208
+ const fromDate = new Date(`${from.year}-${String(from.month ?? 0 + 1).padStart(2, '0')}-${String(from.day).padStart(2, '0')}`);
12209
+ const toDate = new Date(`${to.year}-${String(to.month ?? 0 + 1).padStart(2, '0')}-${String(to.day).padStart(2, '0')}`);
12210
+ return fromDate > toDate;
12211
+ };
12212
+ function getMonth(candidate, defaultValue) {
12213
+ if (typeof candidate === 'string') {
12214
+ candidate = parseInt(candidate) - 1;
12438
12215
  }
12439
-
12440
- .o-calendar-day-in-range {
12441
- ${backgroundColor('lightblue')}
12442
- ${borderRadius('none')}
12443
- ${color('white')}
12216
+ if (candidate === undefined || isNaN(candidate) || candidate < 0 || candidate > 11) {
12217
+ return defaultValue;
12444
12218
  }
12445
-
12446
- .o-calendar-day-in-range-transient {
12447
- ${backgroundColor('dark')}
12448
- ${borderRadius('none')}
12449
- ${color('white')}
12219
+ return candidate;
12220
+ }
12221
+ function getYear(candidate, min, max, defaultValue) {
12222
+ if (typeof candidate === 'string') {
12223
+ candidate = parseInt(candidate);
12450
12224
  }
12451
-
12452
- .o-calendar-day-start-range,
12453
- .o-calendar-day-start-range-transient {
12454
- ${borderTopRightRadius('none')}
12455
- ${borderBottomRightRadius('none')}
12225
+ if (candidate === undefined || isNaN(candidate) || candidate < min || candidate > max) {
12226
+ return defaultValue;
12456
12227
  }
12457
-
12458
- .o-calendar-day-end-range,
12459
- .o-calendar-day-end-range-transient {
12460
- ${borderTopLeftRadius('none')}
12461
- ${borderBottomLeftRadius('none')}
12228
+ return candidate;
12229
+ }
12230
+ const defaultMinDate = new Date();
12231
+ defaultMinDate.setFullYear(1900);
12232
+ const defaultMaxDate = new Date();
12233
+ defaultMaxDate.setFullYear(2100);
12234
+ const CalendarComponent = ({ from, to, type, minDate = defaultMinDate, maxDate = defaultMaxDate, nextSelectEdge, className, onChange, }) => {
12235
+ const maxYear = maxDate.getFullYear();
12236
+ const minYear = minDate.getFullYear();
12237
+ const years = useRef([...Array(maxYear).keys()].slice(minYear));
12238
+ const d = new Date();
12239
+ const lastExternalFromMonth = useRef(from['month']);
12240
+ const lastExternalFromYear = useRef(from['year']);
12241
+ const lastExternalToMonth = useRef(to['month']);
12242
+ const lastExternalToYear = useRef(to['year']);
12243
+ const fromMonth = getMonth(from['month']);
12244
+ const fromYear = getYear(from['year'], minYear, maxYear);
12245
+ const fromDay = from['day'] === undefined ? undefined : parseInt(`${from['day']}`);
12246
+ const [internalTo, setInternalTo] = useState({});
12247
+ let transientTo = false;
12248
+ let toMonth, toYear, toDay;
12249
+ let isInversed = false;
12250
+ if (to.year !== undefined && to.month !== undefined && to.day !== undefined) {
12251
+ toMonth = getMonth(to.month);
12252
+ toYear = getYear(to.year, minYear, maxYear);
12253
+ toDay = parseInt(`${to.day}`);
12462
12254
  }
12463
-
12464
- .o-datepicker-dropdown-content {
12465
- ${borderRadius('sm')}
12466
- ${borderTopLeftRadius(0)}
12467
- ${borderTopRightRadius(0)}
12468
- ${boxShadow('lg')}
12469
- ${zIndex(2000)}
12470
- ${backgroundColor('white')}
12471
- ${borderWidth(1)}
12472
- ${borderColor('light')}
12473
- ${marginTop('-1px')}
12474
- ${padding('lg')}
12475
- ${userSelect('none')}
12476
- ${display('flex')}
12255
+ else {
12256
+ toMonth = getMonth(internalTo.month);
12257
+ toYear = getYear(internalTo.year, minYear, maxYear);
12258
+ toDay = parseInt(`${internalTo.day}`);
12259
+ transientTo = true;
12260
+ isInversed = isInversedDate(from, internalTo);
12477
12261
  }
12478
-
12479
- .o-datepicker-active {
12480
- .o-calendar-day-active {
12481
- ${color('white')}
12482
- ${backgroundColor('primary')}
12483
- ${fontWeight('medium')}
12484
- &.o-calendar-day-end-range-transient {
12485
- ${backgroundColor('darkest')}
12486
- &.o-calendar-day-start-range {
12487
- ${backgroundColor('primary')}
12488
- }
12489
- }
12490
- &.o-calendar-day-start-range-transient {
12491
- ${backgroundColor('darkest')}
12262
+ const [currentMonth, setCurrentMonth] = useState(getMonth(from['month'], d.getMonth()));
12263
+ const [currentYear, setCurrentYear] = useState(getYear(from['year'], minYear, maxYear, d.getFullYear()));
12264
+ const firstDayOfExternalFromMonth = fromMonth && fromYear ? new Date(`${fromYear}-${String(getMonth(fromMonth + 1)).padStart(2, '0')}-01`) : undefined;
12265
+ const firstDayOfExternalToMonth = toMonth && toYear ? new Date(`${toYear}-${String(toMonth + 1).padStart(2, '0')}-01`) : undefined;
12266
+ const firstDayOfCurrentMonth = new Date(`${currentYear}-${String(currentMonth + 1).padStart(2, '0')}-01`);
12267
+ const lastDayOfPreviousMonth = new Date(firstDayOfCurrentMonth);
12268
+ lastDayOfPreviousMonth.setDate(lastDayOfPreviousMonth.getDate() - 1);
12269
+ const lastDayOfCurrentMonth = new Date(firstDayOfCurrentMonth);
12270
+ lastDayOfCurrentMonth.setMonth(lastDayOfCurrentMonth.getMonth() + 1);
12271
+ lastDayOfCurrentMonth.setDate(lastDayOfCurrentMonth.getDate() - 1);
12272
+ const firstDayOfNextMonth = new Date(firstDayOfCurrentMonth);
12273
+ firstDayOfNextMonth.setMonth(firstDayOfNextMonth.getMonth() + 1);
12274
+ let calendarDays = firstDayOfCurrentMonth.getDate() === 0 || firstDayOfCurrentMonth.getDay() === 0
12275
+ ? []
12276
+ : [...Array(lastDayOfPreviousMonth.getDate() + 1).keys()].slice(-firstDayOfCurrentMonth.getDay()).map((n) => {
12277
+ const startRange = fromDay === n &&
12278
+ lastDayOfPreviousMonth.getMonth() === firstDayOfExternalFromMonth?.getMonth() &&
12279
+ lastDayOfPreviousMonth.getFullYear() === firstDayOfExternalFromMonth?.getFullYear();
12280
+ const endRange = toDay === n &&
12281
+ lastDayOfPreviousMonth.getMonth() === firstDayOfExternalToMonth?.getMonth() &&
12282
+ lastDayOfPreviousMonth.getFullYear() === firstDayOfExternalToMonth?.getFullYear();
12283
+ return {
12284
+ day: n,
12285
+ active: startRange || endRange,
12286
+ current: isCurrent(d, lastDayOfPreviousMonth.getFullYear(), lastDayOfPreviousMonth.getMonth(), n),
12287
+ month: lastDayOfPreviousMonth.getMonth(),
12288
+ year: lastDayOfPreviousMonth.getFullYear(),
12289
+ startRange: startRange && type.range,
12290
+ endRange: isActive(from) && endRange && type.range,
12291
+ inRange: type.range &&
12292
+ inRange(lastDayOfPreviousMonth.getFullYear(), lastDayOfPreviousMonth.getMonth(), n, from, transientTo ? internalTo : to),
12293
+ };
12294
+ });
12295
+ calendarDays = calendarDays.concat([...Array(lastDayOfCurrentMonth.getDate() + 1).keys()].slice(1).map((n) => {
12296
+ const startRange = fromDay === n &&
12297
+ lastDayOfCurrentMonth.getMonth() === firstDayOfExternalFromMonth?.getMonth() &&
12298
+ lastDayOfCurrentMonth.getFullYear() === firstDayOfExternalFromMonth?.getFullYear();
12299
+ const endRange = toDay === n &&
12300
+ lastDayOfCurrentMonth.getMonth() === firstDayOfExternalToMonth?.getMonth() &&
12301
+ lastDayOfCurrentMonth.getFullYear() === firstDayOfExternalToMonth?.getFullYear();
12302
+ return {
12303
+ day: n,
12304
+ active: startRange || endRange,
12305
+ current: isCurrent(d, lastDayOfCurrentMonth.getFullYear(), lastDayOfCurrentMonth.getMonth(), n),
12306
+ month: lastDayOfCurrentMonth.getMonth(),
12307
+ year: lastDayOfCurrentMonth.getFullYear(),
12308
+ startRange: startRange && type.range,
12309
+ endRange: isActive(from) && endRange && type.range,
12310
+ inRange: type.range &&
12311
+ inRange(lastDayOfCurrentMonth.getFullYear(), lastDayOfCurrentMonth.getMonth(), n, from, transientTo ? internalTo : to),
12312
+ };
12313
+ }));
12314
+ calendarDays = calendarDays.concat(lastDayOfCurrentMonth.getDay() === 6
12315
+ ? []
12316
+ : [...Array(6 - lastDayOfCurrentMonth.getDay() + 1).keys()].slice(1).map((n) => {
12317
+ const startRange = fromDay === n &&
12318
+ firstDayOfNextMonth.getMonth() === firstDayOfExternalFromMonth?.getMonth() &&
12319
+ firstDayOfNextMonth.getFullYear() === firstDayOfExternalFromMonth?.getFullYear();
12320
+ const endRange = toDay === n &&
12321
+ firstDayOfNextMonth.getMonth() === firstDayOfExternalToMonth?.getMonth() &&
12322
+ firstDayOfNextMonth.getFullYear() === firstDayOfExternalToMonth?.getFullYear();
12323
+ return {
12324
+ day: n,
12325
+ active: startRange || endRange,
12326
+ current: isCurrent(d, firstDayOfNextMonth.getFullYear(), firstDayOfNextMonth.getMonth(), n),
12327
+ month: firstDayOfNextMonth.getMonth(),
12328
+ year: firstDayOfNextMonth.getFullYear(),
12329
+ startRange: startRange && type.range,
12330
+ endRange: isActive(from) && endRange && type.range,
12331
+ inRange: type.range &&
12332
+ inRange(firstDayOfNextMonth.getFullYear(), firstDayOfNextMonth.getMonth(), n, from, transientTo ? internalTo : to),
12333
+ };
12334
+ }));
12335
+ useEffect(() => {
12336
+ if (type.range && to['month'] !== lastExternalToMonth.current) {
12337
+ // the user has changed the toMonth from the input field
12338
+ // we move the calendar to this month if it's a valid month
12339
+ lastExternalToMonth.current = to['month'];
12340
+ setCurrentMonth(getMonth(to['month'], currentMonth));
12492
12341
  }
12493
- }
12494
- }
12495
-
12496
- .o-datepicker-input {
12497
- input:read-only {
12498
- ${cursor('pointer')}
12499
- }
12500
- }
12501
-
12502
- .o-datepicker-icon {
12503
- ${cursor('pointer')}
12504
- ${display('flex')}
12505
- ${alignItems('center')}
12506
- }
12342
+ if (type.range && to['year'] !== lastExternalToYear.current) {
12343
+ // the user has changed the toYear from the input field
12344
+ // we move the calendar to this year if it's a valid year
12345
+ lastExternalToYear.current = to['year'];
12346
+ setCurrentYear(getYear(to['year'], minYear, maxYear, currentYear));
12347
+ }
12348
+ if (from['month'] !== lastExternalFromMonth.current) {
12349
+ // the user has changed the fromMonth from the input field
12350
+ // we move the calendar to this month if it's a valid month
12351
+ lastExternalFromMonth.current = from['month'];
12352
+ setCurrentMonth(getMonth(from['month'], currentMonth));
12353
+ }
12354
+ if (from['year'] !== lastExternalFromYear.current) {
12355
+ // the user has changed the fromYear from the input field
12356
+ // we move the calendar to this year if it's a valid year
12357
+ lastExternalFromYear.current = from['year'];
12358
+ setCurrentYear(getYear(from['year'], minYear, maxYear, currentYear));
12359
+ }
12360
+ });
12361
+ return (jsxRuntimeExports.jsxs("div", { className: addClassname('o-calendar-container', className), children: [jsxRuntimeExports.jsxs("div", { className: "o-calendar-month", children: [jsxRuntimeExports.jsx(TogglerIcon, { width: "20px", closeArrowPosition: "w", onClick: () => {
12362
+ if (fromMonth === 0) {
12363
+ setCurrentMonth(11);
12364
+ setCurrentYear(currentYear - 1);
12365
+ }
12366
+ else {
12367
+ setCurrentMonth(currentMonth - 1);
12368
+ }
12369
+ } }, "previous"), jsxRuntimeExports.jsx(Select, { dataSource: months, nullable: false, value: months[currentMonth], className: "o-calendar-select-month", size: "small", onChange: (value) => setCurrentMonth(months.indexOf(`${value}`)) }, "month"), jsxRuntimeExports.jsx(Select, { dataSource: years.current, value: currentYear, nullable: false, className: "o-calendar-select-year", size: "small", onChange: (value) => setCurrentYear(parseInt(`${value}`)) }, "year"), jsxRuntimeExports.jsx(TogglerIcon, { width: "20px", closeArrowPosition: "e", onClick: () => {
12370
+ if (fromMonth === 11) {
12371
+ setCurrentMonth(0);
12372
+ setCurrentYear(currentYear + 1);
12373
+ }
12374
+ else {
12375
+ setCurrentMonth(currentMonth + 1);
12376
+ }
12377
+ } }, "next")] }), jsxRuntimeExports.jsxs("div", { className: "o-calendar-day-container", children: [days.map((day) => (jsxRuntimeExports.jsx("div", { className: "o-calendar-day-title", children: day.substring(0, 2) }, `${day}`))), calendarDays.map((calendarDay, index) => (jsxRuntimeExports.jsx("div", { className: `o-calendar-day${calendarDay.endRange
12378
+ ? ` o-calendar-day-${isInversed ? 'start' : 'end'}-range${transientTo ? '-transient' : ''}`
12379
+ : ''}${calendarDay.startRange ? ` o-calendar-day-${isInversed ? 'end' : 'start'}-range` : ''}${calendarDay.active ? ' o-calendar-day-active' : ''}${calendarDay.inRange ? ` o-calendar-day-in-range${transientTo ? '-transient' : ''}` : ''}${calendarDay.month === currentMonth ? ' o-calendar-day-in-month' : ''}${calendarDay.current ? ' o-calendar-day-current' : ''}`, onClick: () => {
12380
+ const nextDateString = `${calendarDay.year}-${String(calendarDay.month + 1).padStart(2, '0')}-${String(calendarDay.day).padStart(2, '0')}`;
12381
+ if (type.range && from.year !== undefined && from.month !== undefined && from.day !== undefined) {
12382
+ // It's a date range and not the first selection
12383
+ // We must determine if it's a change for the from or the to
12384
+ const fromDateString = `${from.year}-${from.month.padStart(2, '0')}-${String(from.day).padStart(2, '0')}`;
12385
+ const fromDate = new Date(fromDateString);
12386
+ let endDate = undefined;
12387
+ let endDateString = undefined;
12388
+ if (to.year !== undefined && to.month !== undefined && to.day !== undefined) {
12389
+ // it's not the second click
12390
+ endDateString = `${to.year}-${to.month.padStart(2, '0')}-${String(to.day).padStart(2, '0')}`;
12391
+ endDate = new Date(endDateString);
12392
+ }
12393
+ const nextDate = new Date(nextDateString);
12394
+ if (endDate) {
12395
+ // case when we click on the same day than the fromDate
12396
+ if (isSameDay(fromDate, nextDate)) {
12397
+ if (nextDate <= fromDate) {
12398
+ onChange(nextDateString, fromDateString);
12399
+ }
12400
+ else {
12401
+ onChange(fromDateString, nextDateString);
12402
+ }
12403
+ }
12404
+ // case when we click on the same day than the endDate
12405
+ else if (isSameDay(endDate, nextDate)) {
12406
+ if (nextDate <= endDate) {
12407
+ onChange(nextDateString, endDateString);
12408
+ }
12409
+ else {
12410
+ onChange(endDateString, nextDateString);
12411
+ }
12412
+ }
12413
+ else if (nextDate <= fromDate) {
12414
+ onChange(nextDateString, endDateString);
12415
+ }
12416
+ else if (nextDate >= endDate) {
12417
+ onChange(fromDateString, nextDateString);
12418
+ }
12419
+ else if (nextSelectEdge === 'from') {
12420
+ onChange(nextDateString, endDateString);
12421
+ }
12422
+ else {
12423
+ onChange(fromDateString, nextDateString);
12424
+ }
12425
+ }
12426
+ else if (nextDate <= fromDate) {
12427
+ onChange(nextDateString, fromDateString);
12428
+ }
12429
+ else {
12430
+ onChange(fromDateString, nextDateString);
12431
+ }
12432
+ }
12433
+ else {
12434
+ // we assume that it's not a range or the first selection of the range
12435
+ onChange(nextDateString);
12436
+ }
12437
+ }, onMouseEnter: () => {
12438
+ if (transientTo) {
12439
+ setInternalTo({
12440
+ year: `${calendarDay.year}`,
12441
+ month: String(calendarDay.month + 1).padStart(2, '0'),
12442
+ day: String(calendarDay.day).padStart(2, '0'),
12443
+ });
12444
+ }
12445
+ }, children: calendarDay.day }, `${fromDay}-${index}`)))] })] }));
12446
+ };
12507
12447
 
12508
- .o-datepicker-remover {
12509
- ${cursor('pointer')}
12510
- ${color('light')}
12511
- ${fontFamily('Arial')}
12512
- ${paddingX('sm')}
12513
- ${userSelect('none')}
12514
- }
12448
+ const QuickTimeRangeComponent = ({ quickRanges, onChange, currentQuickRangeLabel, }) => {
12449
+ return (jsxRuntimeExports.jsxs("div", { className: "o-quick-time-range-container", children: [jsxRuntimeExports.jsx("div", { className: "o-quick-time-range-title", children: "Quick select" }), Object.keys(quickRanges).map((quickRangeLabel, index) => {
12450
+ return (jsxRuntimeExports.jsx("div", { className: `o-quick-time-range${currentQuickRangeLabel === quickRangeLabel ? ' o-quick-time-range-selected' : ''}`, onClick: () => onChange(quickRangeLabel), children: quickRangeLabel }, `qr-${index}`));
12451
+ })] }));
12452
+ };
12515
12453
 
12516
- .o-toggler-icon {
12517
- ${cursor('pointer')}
12518
- ${color('primary')}
12454
+ const getNextValue = (value, max, type) => {
12455
+ const valueInt = parseInt(`${value}`);
12456
+ let result = 0;
12457
+ if (type === 'next') {
12458
+ if (isNaN(valueInt) || valueInt === max) {
12459
+ result = 0;
12460
+ }
12461
+ else {
12462
+ result = valueInt + 1;
12463
+ }
12519
12464
  }
12520
-
12521
- .o-time-selector-part-icon-disabled {
12522
- .o-toggler-icon {
12523
- ${cursor('not-allowed')}
12524
- ${color('light')}
12525
- }
12465
+ else if (type === 'previous') {
12466
+ if (isNaN(valueInt)) {
12467
+ result = 0;
12468
+ }
12469
+ else if (valueInt === 0) {
12470
+ result = max;
12471
+ }
12472
+ else {
12473
+ result = valueInt - 1;
12474
+ }
12526
12475
  }
12527
-
12528
- .o-time-container {
12529
- ${marginLeft('xl')}
12530
- .o-time-separator {
12531
- ${marginX('lg')}
12532
- }
12533
- }
12534
-
12535
- .o-time-selector {
12536
- ${display('flex')}
12537
- ${alignItems('center')}
12476
+ return String(result).padStart(2, '0');
12477
+ };
12478
+ const isMin = (value, _type) => {
12479
+ return parseInt(`${value}`) === 0;
12480
+ };
12481
+ const isMax = (value, type) => {
12482
+ return type === 'hour' ? parseInt(`${value}`) === 23 : parseInt(`${value}`) === 59;
12483
+ };
12484
+ const headerValue = (type) => {
12485
+ switch (type) {
12486
+ case 'hour':
12487
+ return 'HH';
12488
+ case 'minute':
12489
+ return 'MM';
12490
+ case 'second':
12491
+ return 'SS';
12492
+ default:
12493
+ return '';
12538
12494
  }
12495
+ };
12496
+ const TimeSelectorPartComponent = ({ onChange, type, value, size = 'large', displayHeaders = false, }) => {
12497
+ const onValueChange = (e) => {
12498
+ let value = e.target.value;
12499
+ if (type === 'minute' && (value === '' || isValidMinuteOrSecond(value))) {
12500
+ onChange(value);
12501
+ }
12502
+ else if (type === 'second' && (value === '' || isValidMinuteOrSecond(value))) {
12503
+ onChange(value);
12504
+ }
12505
+ else if (type === 'hour' && (value === '' || isValidHour(value))) {
12506
+ onChange(value);
12507
+ }
12508
+ };
12509
+ return (jsxRuntimeExports.jsxs("div", { className: `o-time-selector-part o-time-selector-part-${size} o-time-${type}`, children: [displayHeaders && jsxRuntimeExports.jsx("div", { className: "o-time-selector-part-header", children: headerValue(type) }), jsxRuntimeExports.jsx(TogglerIcon, { className: isMin(value) ? 'o-time-selector-part-icon-disabled' : undefined, width: "20px", closeArrowPosition: "n", onClick: () => {
12510
+ if (!isMin(value)) {
12511
+ onChange(getNextValue(value, type === 'hour' ? 23 : 59, 'previous'));
12512
+ }
12513
+ } }, "previous"), jsxRuntimeExports.jsx(Input, { className: "o-time-input", value: value, size: size, selectOnFocus: true, onChange: onValueChange }, "value"), jsxRuntimeExports.jsx(TogglerIcon, { className: isMax(value, type) ? 'o-time-selector-part-icon-disabled' : undefined, width: "20px", closeArrowPosition: "s", onClick: () => {
12514
+ if (!isMax(value, type)) {
12515
+ onChange(getNextValue(value, type === 'hour' ? 23 : 59, 'next'));
12516
+ }
12517
+ } }, "next")] }));
12518
+ };
12539
12519
 
12540
- .o-time-edge-title {
12541
- ${fontWeight('bold')}
12542
- ${marginBottom('xs')}
12543
- ${borderBottomWidth('1px')}
12544
- ${borderBottomColor('lighter')}
12545
- ${borderBottomStyle('solid')}
12546
- ${textTransform('uppercase')}
12547
- ${color('primary')}
12520
+ const getValue = (candidate, max, defaultValue) => {
12521
+ if (typeof candidate === 'string') {
12522
+ candidate = parseInt(candidate);
12548
12523
  }
12549
-
12550
- .o-time-edge-empty {
12551
- ${color('dark')}
12552
- ${fontStyle('italic')}
12553
- ${marginTop('md')}
12524
+ if (candidate === undefined || isNaN(candidate) || candidate < 0 || candidate > max) {
12525
+ return defaultValue;
12554
12526
  }
12527
+ return candidate;
12528
+ };
12529
+ const TimeSelectorComponent = ({ value, onChange, size, edge, displayHours, displayMinutes, displaySeconds, displayHeaders, }) => {
12530
+ const d = new Date();
12531
+ const hourInt = getValue(value.hour, 23, displayHours ? d.getHours() : 0);
12532
+ const minuteInt = getValue(value.minute, 59, displayMinutes ? d.getMinutes() : 0);
12533
+ const secondInt = getValue(value.second, 59, displaySeconds ? d.getSeconds() : 0);
12534
+ const [internalHour, setInternalHour] = useState(String(hourInt).padStart(2, '0'));
12535
+ const [internalMinute, setInternalMinute] = useState(String(minuteInt).padStart(2, '0'));
12536
+ const [internalSecond, setInternalSecond] = useState(String(secondInt).padStart(2, '0'));
12537
+ const hour = internalHour === '' ? '' : parseInt(internalHour) === hourInt ? internalHour : hourInt;
12538
+ const minute = internalMinute === '' ? '' : parseInt(internalMinute) === minuteInt ? internalMinute : minuteInt;
12539
+ const second = internalSecond === '' ? '' : parseInt(internalSecond) === secondInt ? internalSecond : secondInt;
12540
+ const onChangeHour = useCallback((value) => {
12541
+ setInternalHour(value);
12542
+ if (value !== '') {
12543
+ onChange(`${String(value || 0).padStart(2, '0')}:${String(minute || 0).padStart(2, '0')}:${String(second || 0).padStart(2, '0')}`, edge);
12544
+ }
12545
+ }, [minute, second, onChange]);
12546
+ const onChangeMinute = useCallback((value) => {
12547
+ setInternalMinute(value);
12548
+ if (value !== '') {
12549
+ onChange(`${String(hour || 0).padStart(2, '0')}:${String(value || 0).padStart(2, '0')}:${String(second || 0).padStart(2, '0')}`, edge);
12550
+ }
12551
+ }, [hour, second, onChange]);
12552
+ const onChangeSecond = useCallback((value) => {
12553
+ setInternalSecond(value);
12554
+ if (value !== '') {
12555
+ onChange(`${String(hour || 0).padStart(2, '0')}:${String(minute || 0).padStart(2, '0')}:${String(value || 0).padStart(2, '0')}`, edge);
12556
+ }
12557
+ }, [hour, minute, onChange]);
12558
+ return (jsxRuntimeExports.jsxs("div", { className: "o-time-selector", children: [displayHours && (jsxRuntimeExports.jsx(TimeSelectorPartComponent, { type: "hour", value: hour, onChange: onChangeHour, size: size, displayHeaders: displayHeaders }, "hour")), displayHours && (displayMinutes || displaySeconds) && (jsxRuntimeExports.jsx("span", { className: "o-time-separator", children: ":" }, "sep1")), displayMinutes && (jsxRuntimeExports.jsx(TimeSelectorPartComponent, { type: "minute", value: minute, onChange: onChangeMinute, size: size, displayHeaders: displayHeaders }, "minute")), displaySeconds && (displayHours || displayMinutes) && (jsxRuntimeExports.jsx("span", { className: "o-time-separator", children: ":" }, "sep2")), displaySeconds && (jsxRuntimeExports.jsx(TimeSelectorPartComponent, { type: "second", value: second, onChange: onChangeSecond, size: size, displayHeaders: displayHeaders }, "second"))] }));
12559
+ };
12555
12560
 
12556
- .o-time-edge-date-container {
12557
- ${width('150px')}
12561
+ const TimeRangeComponent = ({ edge, onChange, value, displayHours, displayMinutes, displaySeconds, displayHeaders, }) => {
12562
+ const valid = isValidDate(`${value.day}-${value.month}-${value.year}`);
12563
+ let d;
12564
+ if (valid) {
12565
+ d = new Date(`${value.year}-${value.month}-${value.day}`);
12558
12566
  }
12567
+ const label = edge === 'to' ? 'an end' : 'a start';
12568
+ return (jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("div", { className: "o-time-edge-title", children: ucfirst(edge) }, "title"), !valid && (jsxRuntimeExports.jsxs("div", { className: "o-time-edge-empty", children: ["Please select ", label, " date for the period"] }, "empty")), valid && d && (jsxRuntimeExports.jsxs("div", { className: "o-time-edge-content", children: [jsxRuntimeExports.jsx("div", { className: "o-time-edge-date-container", children: jsxRuntimeExports.jsx("span", { className: "o-time-edge-date", children: d.toUTCString().split(' ', 4).join(' ') }) }, "date"), jsxRuntimeExports.jsx(TimeSelectorComponent, { value: value, onChange: onChange, size: "small", edge: edge, displayHours: displayHours, displayMinutes: displayMinutes, displaySeconds: displaySeconds, displayHeaders: displayHeaders }, "selector")] }, "content"))] }));
12569
+ };
12559
12570
 
12560
- .o-time-edge-date {
12561
- ${fontWeight('medium')}
12562
- ${backgroundColor('lightest')}
12563
- ${paddingX('sm')}
12564
- ${marginRight('md')}
12565
- ${whiteSpace('nowrap')}
12571
+ const TimeComponent = ({ from, to, type, className, onChange, displayHours, displayMinutes, displaySeconds, }) => {
12572
+ if (type['range'] && type['date']) {
12573
+ return (jsxRuntimeExports.jsxs("div", { className: addClassname('o-time-container-range', className), children: [jsxRuntimeExports.jsx(TimeRangeComponent, { type: type, value: from, edge: "from", onChange: onChange, displayHours: displayHours, displayMinutes: displayMinutes, displaySeconds: displaySeconds, displayHeaders: false }), jsxRuntimeExports.jsx(TimeRangeComponent, { type: type, value: to, edge: "to", onChange: onChange, displayHours: displayHours, displayMinutes: displayMinutes, displaySeconds: displaySeconds, displayHeaders: false })] }));
12566
12574
  }
12575
+ return (jsxRuntimeExports.jsx("div", { className: addClassname('o-time-container', className), children: jsxRuntimeExports.jsx(TimeSelectorComponent, { value: from, onChange: onChange, size: "large", edge: "from", displayHours: displayHours, displayMinutes: displayMinutes, displaySeconds: displaySeconds, displayHeaders: true }, "selector") }));
12576
+ };
12567
12577
 
12568
- .o-time-container-range {
12569
- ${marginLeft('3xl')}
12570
- ${marginTop('2xl')}
12571
- ${display('flex')}
12572
- ${flexDirection('column')}
12573
- ${gap('xl')}
12574
- .o-time-separator {
12575
- ${marginX('sm')}
12576
- }
12578
+ const IconComponent = () => {
12579
+ const { nullable, setOpen, onChange, open } = useDatePickerContext();
12580
+ return (jsxRuntimeExports.jsxs("span", { className: "o-datepicker-icon", children: [nullable && (jsxRuntimeExports.jsx("div", { className: "o-datepicker-remover", onClick: () => {
12581
+ onChange(null);
12582
+ setOpen(false);
12583
+ }, children: "\u2716" })), jsxRuntimeExports.jsx(CalendarIcon, { width: "20px", height: "20px", color: "primary", marginRight: "sm", onClick: () => setOpen(!open) })] }));
12584
+ };
12585
+ const parseDate = (value) => {
12586
+ let date, time, year, month, day, hour, minute, second = undefined;
12587
+ if (value) {
12588
+ [date, time] = value.trim().split(' ');
12589
+ [year, month, day] = date ? date.split('-') : [undefined, undefined, undefined];
12590
+ [hour, minute, second] = time ? time.split(':') : [undefined, undefined, undefined];
12577
12591
  }
12578
-
12579
- .o-time-edge-content {
12580
- ${display('flex')}
12581
- ${alignItems('center')}
12592
+ return { date, time, year, month, day, hour, minute, second };
12593
+ };
12594
+ const isValidValue = (value, type) => {
12595
+ const isValidDate = (value) => {
12596
+ const d = new Date(value);
12597
+ return !isNaN(d);
12598
+ };
12599
+ if (!value)
12600
+ return true;
12601
+ if (type.range) {
12602
+ const [from, to] = value.split(' to ');
12603
+ if (!from || !to)
12604
+ return false;
12605
+ return isValidDate(from) && isValidDate(to);
12582
12606
  }
12583
-
12584
- .o-time-separator {
12585
- ${fontWeight('bold')}
12607
+ else {
12608
+ return isValidDate(value);
12586
12609
  }
12587
-
12588
- .o-time-input {
12589
- ${width(10)}
12590
- .o-input-field {
12591
- ${textAlign('center')}
12592
- }
12610
+ };
12611
+ const isSameDate = (d1, d2, type) => {
12612
+ const isSameDate = (d1, d2) => {
12613
+ if (!d1 && !d2)
12614
+ return true;
12615
+ if (!d1 || !d2)
12616
+ return false;
12617
+ const date1 = new Date(`${d1}`);
12618
+ const date2 = new Date(`${d2}`);
12619
+ if (isNaN(date1) || isNaN(date2)) {
12620
+ return false;
12621
+ }
12622
+ return date1.toString() === date2.toString();
12623
+ };
12624
+ if (d1 === null && d2 === null)
12625
+ return true;
12626
+ if (!d1 || !d2)
12627
+ return false;
12628
+ if (type.range) {
12629
+ const [from1, to1] = d1.split(' to ');
12630
+ const [from2, to2] = d2.split(' to ');
12631
+ return isSameDate(from1, from2) && isSameDate(to1, to2);
12593
12632
  }
12594
-
12595
- .o-time-selector-part {
12596
- ${display('flex')}
12597
- ${flexDirection('column')}
12598
- ${alignItems('center')}
12633
+ else {
12634
+ return isSameDate(d1, d2);
12599
12635
  }
12600
-
12601
- .o-time-selector-part-large.o-toggler-icon-container {
12602
- ${marginY('md')}
12636
+ };
12637
+ const formatDate = (type, fromDate, fromTime, toDate, toTime) => {
12638
+ const format = (date, time) => {
12639
+ let result = '';
12640
+ if (type.date) {
12641
+ result += `${date || ''}`;
12642
+ }
12643
+ if (type.time) {
12644
+ if (type.date && date) {
12645
+ result += ` ${time || '00:00:00'}`;
12646
+ }
12647
+ else if (type.date && time) {
12648
+ result += ` ${time}`;
12649
+ }
12650
+ else if (time) {
12651
+ result += time;
12652
+ }
12653
+ }
12654
+ return result;
12655
+ };
12656
+ let result = format(fromDate, fromTime);
12657
+ if (type.range) {
12658
+ result += ` to ${format(toDate, toTime)}`;
12603
12659
  }
12604
-
12605
- .o-quick-time-range-container {
12606
- ${paddingRight('2xl')}
12607
- ${marginTop('2xl')}
12608
- ${marginX('md')}
12660
+ return result;
12661
+ };
12662
+ const PickerComponent = ({ animationMs = 100, attachDropdownToBody = true, autoFocus, className, closeOnQuickSelect = true, combo = false, disabled, dropdownWidthModifier = 'min', label, nullable = false, onBlur: forwardBlur, onChange: forwardChange, onFocus: forwardFocus, openOnFocus = false, placeholder, placement = 'bottom-start', quickRanges, type, displayHours = true, displayMinutes = true, displaySeconds = true, value: externalValue, }) => {
12663
+ const containerRef = useRef(null);
12664
+ const stateRef = useRef({});
12665
+ const dropdownRef = useRef(null);
12666
+ const lastExternalValueRef = useRef(undefined);
12667
+ const currentValueRef = useRef(null);
12668
+ const [open, setOpen] = useState(false);
12669
+ const [focus, setFocus] = useState(false);
12670
+ const [Dropdown, triggerRef] = useDropdown();
12671
+ const [internalValue, setInternalValue] = useState(null);
12672
+ let value = internalValue ? internalValue : externalValue;
12673
+ if (currentValueRef.current !== value && isSameDate(currentValueRef.current, value, type)) {
12674
+ value = currentValueRef.current;
12609
12675
  }
12610
-
12611
- .o-quick-time-range-title {
12612
- ${fontWeight('bold')}
12676
+ const [fromString, toString] = value ? value.split(/ to\s*/) : [];
12677
+ const validFromRef = useRef(undefined);
12678
+ const validToRef = useRef(undefined);
12679
+ if (!fromString || /\s*/.test(fromString)) {
12680
+ validFromRef.current = undefined;
12613
12681
  }
12614
-
12615
- .o-quick-time-range {
12616
- ${cursor('pointer')}
12617
- ${fontWeight('medium')}
12618
- ${color('primary')}
12619
- &.o-quick-time-range-selected {
12620
- ${cursor('auto')}
12621
- ${fontWeight('bold')}
12622
- ${color('pink')}
12623
- }
12682
+ if (!toString || /\s*/.test(toString)) {
12683
+ validToRef.current = undefined;
12624
12684
  }
12625
- `;
12626
- };
12627
-
12628
- const months = [
12629
- 'January',
12630
- 'February',
12631
- 'March',
12632
- 'April',
12633
- 'May',
12634
- 'June',
12635
- 'July',
12636
- 'August',
12637
- 'September',
12638
- 'October',
12639
- 'November',
12640
- 'December',
12641
- ];
12642
- const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
12643
- const isValidDate = (value) => {
12644
- if (!value)
12645
- return false;
12646
- return /^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[13-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{4})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{4})$/.test(value);
12647
- };
12648
- const isValidTime = (value) => {
12649
- if (!value)
12650
- return false;
12651
- return /^(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])$/.test(value);
12652
- };
12653
- const isValidMinuteOrSecond = (value) => {
12654
- if (!value)
12655
- return false;
12656
- return /^(0?|[1-5])[0-9]$/.test(value);
12657
- };
12658
- const isValidHour = (value) => {
12659
- if (!value)
12660
- return false;
12661
- return /^(2[0-3]|0?[0-9]|1[0-9])$/.test(value);
12685
+ // this setting is used to detect if the user changes the from or the to
12686
+ const nextSelectEdgeRef = useRef('to');
12687
+ const from = parseDate(fromString?.trim());
12688
+ const previousFrom = parseDate(validFromRef.current);
12689
+ if (!type['date'] || !isValidDate(`${from['day']}-${from['month']}-${from['year']}`)) {
12690
+ from.year = previousFrom.year;
12691
+ from.month = previousFrom.month;
12692
+ from.day = previousFrom.day;
12693
+ from.date = previousFrom.date;
12694
+ }
12695
+ if (type['date'] && isValidDate(`${from['day']}-${from['month']}-${from['year']}`)) {
12696
+ validFromRef.current = `${from['year']}-${from['month']}-${from['day']}`;
12697
+ }
12698
+ if (!type['time'] || !isValidTime(from['time'])) {
12699
+ from.hour = previousFrom.hour;
12700
+ from.minute = previousFrom.minute;
12701
+ from.second = previousFrom.second;
12702
+ from.time = previousFrom.time;
12703
+ }
12704
+ if (type['time'] && isValidTime(`${from['time']}`)) {
12705
+ if (validFromRef.current === undefined) {
12706
+ validFromRef.current = '';
12707
+ }
12708
+ if (type['date']) {
12709
+ validFromRef.current += ' ';
12710
+ }
12711
+ validFromRef.current += `${from['time']}`;
12712
+ }
12713
+ const to = parseDate(toString?.trim());
12714
+ const previousTo = parseDate(validToRef.current);
12715
+ if (!type['date'] || !isValidDate(`${to['day']}-${to['month']}-${to['year']}`)) {
12716
+ to.year = previousTo.year;
12717
+ to.month = previousTo.month;
12718
+ to.day = previousTo.day;
12719
+ to.date = previousTo.date;
12720
+ }
12721
+ if (type['date'] && isValidDate(`${to['day']}-${to['month']}-${to['year']}`)) {
12722
+ validToRef.current = `${to['year']}-${to['month']}-${to['day']}`;
12723
+ }
12724
+ if (!type['time'] || !isValidTime(to['time'])) {
12725
+ to.hour = previousTo.hour;
12726
+ to.minute = previousTo.minute;
12727
+ to.second = previousTo.second;
12728
+ to.time = previousTo.time;
12729
+ }
12730
+ if (type['time'] && isValidTime(`${to['time']}`)) {
12731
+ if (validToRef.current === undefined) {
12732
+ validToRef.current = '';
12733
+ }
12734
+ if (type['date']) {
12735
+ validToRef.current += ' ';
12736
+ }
12737
+ validToRef.current += `${to['time']}`;
12738
+ }
12739
+ const id = useId();
12740
+ const onFocus = useCallback(() => {
12741
+ if (!focus) {
12742
+ setFocus(true);
12743
+ if (openOnFocus && !open) {
12744
+ setOpen(true);
12745
+ }
12746
+ if (forwardFocus) {
12747
+ forwardFocus();
12748
+ }
12749
+ }
12750
+ }, [focus, forwardFocus, openOnFocus, open]);
12751
+ const onBlur = useCallback(() => {
12752
+ if (!stateRef.current.keepFocus) {
12753
+ if (open) {
12754
+ setOpen(false);
12755
+ }
12756
+ if (focus) {
12757
+ setFocus(false);
12758
+ if (forwardBlur) {
12759
+ forwardBlur();
12760
+ }
12761
+ }
12762
+ }
12763
+ }, [open, forwardBlur, setOpen, focus]);
12764
+ const onChange = useCallback((nextValue, label) => {
12765
+ currentValueRef.current = nextValue;
12766
+ // check if the nextValue is a valid value
12767
+ // if it's not a valid value, we keep it internally
12768
+ if (forwardChange && isValidValue(nextValue, type)) {
12769
+ setInternalValue(null);
12770
+ forwardChange(nextValue, label);
12771
+ }
12772
+ else {
12773
+ setInternalValue(nextValue);
12774
+ }
12775
+ }, [forwardChange, setInternalValue, type]);
12776
+ const onChangeDate = (fromDate, toDate) => {
12777
+ if (fromDate === undefined) {
12778
+ fromDate = from['date'];
12779
+ }
12780
+ if (toDate === undefined) {
12781
+ toDate = to['date'];
12782
+ }
12783
+ if (fromDate !== from['date']) {
12784
+ nextSelectEdgeRef.current = 'to';
12785
+ }
12786
+ else {
12787
+ nextSelectEdgeRef.current = 'from';
12788
+ }
12789
+ onChange(formatDate(type, fromDate, from['time'], toDate, to['time']));
12790
+ };
12791
+ const removeLabel = () => {
12792
+ onChangeDate();
12793
+ };
12794
+ const onChangeTime = (nextTime, edge) => {
12795
+ if (edge === 'from') {
12796
+ onChange(formatDate(type, from['date'], nextTime, to['date'], to['time']));
12797
+ }
12798
+ else {
12799
+ onChange(formatDate(type, from['date'], from['time'], to['date'], nextTime));
12800
+ }
12801
+ };
12802
+ const onChangeQuickRange = (quickRangeLabel) => {
12803
+ if (quickRanges) {
12804
+ const quickRange = quickRanges[quickRangeLabel];
12805
+ if (quickRange) {
12806
+ onChange(`${quickRange.from} to ${quickRange.to}`, quickRangeLabel);
12807
+ }
12808
+ if (closeOnQuickSelect) {
12809
+ setOpen(false);
12810
+ }
12811
+ }
12812
+ };
12813
+ const onOpen = useCallback(() => {
12814
+ eventLocks.lock('escape', id);
12815
+ }, [id]);
12816
+ const onClosed = useCallback(() => {
12817
+ eventLocks.unlock('escape', id);
12818
+ if (lastExternalValueRef.current !== undefined) {
12819
+ setInternalValue(null);
12820
+ }
12821
+ }, [id]);
12822
+ useClickOutside([containerRef, dropdownRef], onBlur);
12823
+ useFocusOutside([containerRef, dropdownRef], onBlur);
12824
+ const context = useMemo(() => {
12825
+ return {
12826
+ open,
12827
+ setOpen,
12828
+ triggerRef,
12829
+ nullable,
12830
+ onChange,
12831
+ };
12832
+ }, [open, setOpen, triggerRef, nullable, onChange]);
12833
+ useEffect(() => {
12834
+ if (forwardChange &&
12835
+ lastExternalValueRef.current !== undefined &&
12836
+ externalValue !== undefined &&
12837
+ externalValue !== lastExternalValueRef.current) {
12838
+ // case when we block the onChange due to a wrong internal value
12839
+ // and the value is changed from the exterior (not due to change done internally)
12840
+ setInternalValue(null);
12841
+ }
12842
+ lastExternalValueRef.current = externalValue;
12843
+ });
12844
+ return (jsxRuntimeExports.jsx(DefaultDatePickerContext.Provider, { value: context, children: jsxRuntimeExports.jsxs("div", { className: addClassname('o-datepicker', className), ref: containerRef, onMouseDown: () => (stateRef.current.keepFocus = true), onMouseUp: () => (stateRef.current.keepFocus = false), children: [jsxRuntimeExports.jsx(Dropdown, { attachToBody: attachDropdownToBody, open: open, distance: 0, animationTimeout: animationMs, onDropStart: onOpen, onCollapseDone: onClosed, placement: placement, widthModifier: dropdownWidthModifier, className: className, zIndex: attachDropdownToBody ? 2000 : undefined, children: jsxRuntimeExports.jsxs("div", { ref: dropdownRef, className: `o-datepicker-dropdown-content${type['range'] ? ' o-datepicker-range' : ''}${validFromRef.current !== undefined ? ' o-datepicker-active' : ''}`, children: [type['range'] && quickRanges && Object.keys(quickRanges).length > 0 && (jsxRuntimeExports.jsx(QuickTimeRangeComponent, { quickRanges: quickRanges, onChange: onChangeQuickRange, currentQuickRangeLabel: label }, "quick_range")), type['date'] && (jsxRuntimeExports.jsx("div", { className: "o-calendar", children: jsxRuntimeExports.jsx(CalendarComponent, { from: from, to: to, type: type, onChange: onChangeDate, nextSelectEdge: nextSelectEdgeRef.current }) }, "calendar")), type['time'] && (jsxRuntimeExports.jsx("div", { className: "o-time", children: jsxRuntimeExports.jsx(TimeComponent, { from: from, to: to, type: type, onChange: onChangeTime, displayHours: displayHours, displayMinutes: displayMinutes, displaySeconds: displaySeconds }) }, "time"))] }) }), jsxRuntimeExports.jsx("span", { ref: triggerRef, children: jsxRuntimeExports.jsx(Input, { className: "o-datepicker-input", placeholder: placeholder, onChange: (e) => onChange(e.target.value), value: label ? label : !value ? '' : value, onFocus: onFocus, onBlur: onBlur, autoFocus: autoFocus, disabled: disabled, SuffixComponent: IconComponent, readOnly: !combo, onClick: () => {
12845
+ if (!open) {
12846
+ setOpen(true);
12847
+ }
12848
+ else if (combo) {
12849
+ removeLabel();
12850
+ }
12851
+ else {
12852
+ setOpen(false);
12853
+ }
12854
+ } }) }, "input")] }) }));
12662
12855
  };
12663
12856
 
12664
- const IconComponent$1 = ({ className, onClick }) => {
12665
- return (jsxRuntimeExports.jsx("div", { className: className, onClick: onClick, children: jsxRuntimeExports.jsxs("svg", { className: "o-icon-calendar-svg", viewBox: "0 0 512 512", children: [jsxRuntimeExports.jsx("rect", { x: "48", y: "80", width: "416", height: "384", rx: "48", fill: "none", stroke: "currentColor", strokeLinejoin: "round", strokeWidth: "32" }), jsxRuntimeExports.jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "32", d: "M128 48v32M384 48v32M464 160H48M304 260l43.42-32H352v168M191.87 306.63c9.11 0 25.79-4.28 36.72-15.47a37.9 37.9 0 0011.13-27.26c0-26.12-22.59-39.9-47.89-39.9-21.4 0-33.52 11.61-37.85 18.93M149 374.16c4.88 8.27 19.71 25.84 43.88 25.84 28.59 0 52.12-15.94 52.12-43.82 0-12.62-3.66-24-11.58-32.07-12.36-12.64-31.25-17.48-41.55-17.48" })] }) }));
12857
+ const toTimestamp = (date, format) => {
12858
+ if (!date)
12859
+ return null;
12860
+ const d = new Date(date);
12861
+ if (isNaN(d))
12862
+ return null;
12863
+ const timestamp = d.getTime();
12864
+ return format === 'milliseconds' ? timestamp : Math.floor(timestamp / 1000);
12666
12865
  };
12667
- var CalendarIcon = styled(IconComponent$1) `
12668
- ${({ width, height, color: cssColor = 'inherit', marginLeft: ml = '0', marginRight: mr = '0' }) => css `
12669
- width: ${width};
12670
- height: ${height};
12671
- ${marginLeft(ml)}
12672
- ${marginRight(mr)}
12673
- ${display('flex')};
12674
- ${alignItems('center')};
12675
- ${color(cssColor)}
12676
- .o-icon-calendar-svg {
12677
- display: inline-block;
12678
- stroke-width: 0;
12679
- stroke: currentColor;
12680
- fill: currentColor;
12866
+ const fromTimestamp = (timestamp, format) => {
12867
+ if (timestamp === null || timestamp === undefined)
12868
+ return null;
12869
+ if (format === 'seconds') {
12870
+ timestamp = timestamp * 1000;
12681
12871
  }
12682
- `}
12683
- `;
12872
+ const d = new Date(timestamp);
12873
+ if (isNaN(d))
12874
+ return null;
12875
+ return dateToString(d);
12876
+ };
12877
+ const timestampAdapter = (format = 'milliseconds') => ({
12878
+ fromDate: (date) => toTimestamp(date, format),
12879
+ toDate: (value) => fromTimestamp(value, format),
12880
+ });
12881
+ const timestampMilliSecondAdapter = timestampAdapter('milliseconds');
12684
12882
 
12685
- const DefaultDatePickerContext = React.createContext(null);
12686
- const useDatePickerContext = () => {
12687
- return useContext(DefaultDatePickerContext);
12883
+ const dateAdapter = {
12884
+ fromDate: (date) => date === null ? null : new Date(date),
12885
+ toDate: (value) => !value ? null : dateToString(value),
12688
12886
  };
12689
12887
 
12690
- const dateToString = (d) => {
12691
- if (typeof d === 'function') {
12692
- d = d();
12693
- }
12694
- if (typeof d === 'string') {
12695
- d = new Date(d);
12696
- }
12697
- return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}:${String(d.getSeconds()).padStart(2, '0')}`;
12888
+ const type$5 = {
12889
+ date: true,
12890
+ time: false,
12891
+ range: false,
12698
12892
  };
12699
- const toDateRange = (value, label) => {
12700
- if (value) {
12701
- const [from, to] = value.trim().split(/ to\s*/);
12893
+ const DatePickerComponent = (props) => {
12894
+ const { onChange: forwardChange, value: externalValue, adapter, ...datePickerProps } = props;
12895
+ const _adapter = adapter === 'timestamp' ? timestampMilliSecondAdapter : adapter === 'date' ? dateAdapter : adapter;
12896
+ const onChange = forwardChange
12897
+ ? (value) => {
12898
+ if (value === null || !_adapter) {
12899
+ forwardChange(value);
12900
+ }
12901
+ else {
12902
+ forwardChange(_adapter.fromDate(value));
12903
+ }
12904
+ }
12905
+ : undefined;
12906
+ let value = externalValue
12907
+ ? _adapter
12908
+ ? _adapter.toDate(externalValue)
12909
+ : externalValue
12910
+ : null;
12911
+ return jsxRuntimeExports.jsx(PickerComponent, { ...datePickerProps, value: value, onChange: onChange, type: type$5 });
12912
+ };
12913
+
12914
+ const timestampRangeAdapter = (format = 'milliseconds') => ({
12915
+ fromDateRange: (range) => {
12702
12916
  return {
12703
- from: from && from.trim() ? from.trim() : null,
12704
- to: to && to.trim() ? to.trim() : null,
12705
- label,
12917
+ from: toTimestamp(range.from, format),
12918
+ to: toTimestamp(range.to, format),
12919
+ label: range.label,
12706
12920
  };
12707
- }
12708
- else {
12709
- return null;
12710
- }
12711
- };
12712
- const qr = (quickRange) => {
12713
- return {
12714
- label: quickRange,
12715
- from: () => {
12716
- const d = new Date();
12717
- switch (quickRange) {
12718
- case 'Last hour':
12719
- d.setHours(d.getHours() - 1);
12720
- break;
12721
- case 'Last day':
12722
- d.setDate(d.getDate() - 1);
12723
- break;
12724
- case 'Last week':
12725
- d.setDate(d.getDate() - 7);
12726
- break;
12727
- case 'Last month':
12728
- d.setMonth(d.getMonth() - 1);
12729
- break;
12730
- case 'Last year':
12731
- d.setFullYear(d.getFullYear() - 1);
12732
- break;
12921
+ },
12922
+ toDateRange: (value) => {
12923
+ return {
12924
+ from: fromTimestamp(value.from, format),
12925
+ to: fromTimestamp(value.to, format),
12926
+ label: value.label,
12927
+ };
12928
+ },
12929
+ });
12930
+ const timestampSecondRangeAdapter = timestampRangeAdapter('seconds');
12931
+ const timestampMilliSecondRangeAdapter = timestampRangeAdapter('milliseconds');
12932
+ const useTimestampRangeAdapter = (format = 'milliseconds') => {
12933
+ const ref = useRef(timestampRangeAdapter(format));
12934
+ return ref.current;
12935
+ };
12936
+
12937
+ const dateRangeAdapter = {
12938
+ fromDateRange: (range) => {
12939
+ return {
12940
+ from: range?.from === null ? null : new Date(range.from),
12941
+ to: range?.to === null ? null : new Date(range.to),
12942
+ label: range?.label,
12943
+ };
12944
+ },
12945
+ toDateRange: (value) => {
12946
+ return {
12947
+ from: !value?.from ? null : dateToString(value.from),
12948
+ to: !value?.to ? null : dateToString(value.to),
12949
+ label: value?.label,
12950
+ };
12951
+ },
12952
+ };
12953
+ const useDateRangeAdapter = () => {
12954
+ return dateRangeAdapter;
12955
+ };
12956
+
12957
+ const type$4 = {
12958
+ date: true,
12959
+ time: false,
12960
+ range: true,
12961
+ };
12962
+ const DateRangePickerComponent = (props) => {
12963
+ const { onChange: forwardChange, value: externalValue, adapter, ...datePickerProps } = props;
12964
+ const _adapter = adapter === 'timestamp' ? timestampMilliSecondRangeAdapter : adapter === 'date' ? dateRangeAdapter : adapter;
12965
+ const onChange = forwardChange
12966
+ ? (value, label) => {
12967
+ const dateRange = toDateRange(value, label);
12968
+ if (dateRange === null || !_adapter) {
12969
+ forwardChange(dateRange);
12733
12970
  }
12734
- return d;
12735
- },
12736
- to: () => new Date(),
12737
- };
12971
+ else {
12972
+ forwardChange(_adapter.fromDateRange(dateRange));
12973
+ }
12974
+ }
12975
+ : undefined;
12976
+ let value = null;
12977
+ let valueLabel;
12978
+ if (externalValue) {
12979
+ if (_adapter) {
12980
+ const { from, to, label } = _adapter.toDateRange(externalValue);
12981
+ value = `${from || ''} to ${to || ''}`;
12982
+ valueLabel = label;
12983
+ }
12984
+ else {
12985
+ value = `${externalValue.from || ''} to ${externalValue.to || ''}`;
12986
+ valueLabel = externalValue.label;
12987
+ }
12988
+ }
12989
+ return jsxRuntimeExports.jsx(PickerComponent, { ...datePickerProps, value: value, onChange: onChange, type: type$4, label: valueLabel });
12738
12990
  };
12739
- const defaultQuickRanges = () => {
12740
- return ['Last hour', 'Last day', 'Last week', 'Last month', 'Last year'].reduce((accumulator, label) => {
12741
- const quickRange = qr(label);
12742
- if (quickRange) {
12743
- accumulator[label] = quickRange;
12991
+
12992
+ const type$3 = {
12993
+ date: true,
12994
+ time: true,
12995
+ range: false,
12996
+ };
12997
+ const DateTimePickerComponent = (props) => {
12998
+ const { onChange: forwardChange, value: externalValue, adapter, ...datePickerProps } = props;
12999
+ const _adapter = adapter === 'timestamp' ? timestampMilliSecondAdapter : adapter === 'date' ? dateAdapter : adapter;
13000
+ const onChange = forwardChange
13001
+ ? (value) => {
13002
+ if (value === null || !_adapter) {
13003
+ forwardChange(value);
13004
+ }
13005
+ else {
13006
+ forwardChange(_adapter.fromDate(value));
13007
+ }
12744
13008
  }
12745
- return accumulator;
12746
- }, {});
13009
+ : undefined;
13010
+ let value = externalValue
13011
+ ? _adapter
13012
+ ? _adapter.toDate(externalValue)
13013
+ : externalValue
13014
+ : null;
13015
+ return jsxRuntimeExports.jsx(PickerComponent, { ...datePickerProps, value: value, onChange: onChange, type: type$3 });
12747
13016
  };
12748
- const findQuickRangeLabel = (quickRanges, dateRange) => {
12749
- if (!quickRanges || !dateRange)
12750
- return;
12751
- const dr = typeof dateRange === 'string' ? toDateRange(dateRange) : dateRange;
12752
- if (dr === null)
12753
- return;
12754
- if (!dr.from || !dr.to)
12755
- return;
12756
- return Object.keys(quickRanges).find((label) => {
12757
- return dr.from === quickRanges[label].from && dr.to === quickRanges[label].to;
12758
- });
13017
+
13018
+ const type$2 = {
13019
+ date: true,
13020
+ time: true,
13021
+ range: true,
12759
13022
  };
12760
- const isSameDay = (date1, date2) => {
12761
- return (date1.getFullYear() === date2.getFullYear() &&
12762
- date1.getMonth() === date2.getMonth() &&
12763
- date1.getDate() === date2.getDate());
13023
+ const DateTimeRangePickerComponent = (props) => {
13024
+ const { onChange: forwardChange, value: externalValue, adapter, ...datePickerProps } = props;
13025
+ const _adapter = adapter === 'timestamp' ? timestampMilliSecondRangeAdapter : adapter === 'date' ? dateRangeAdapter : adapter;
13026
+ const onChange = forwardChange
13027
+ ? (value, label) => {
13028
+ const dateRange = toDateRange(value, label);
13029
+ if (dateRange === null || !_adapter) {
13030
+ forwardChange(dateRange);
13031
+ }
13032
+ else {
13033
+ forwardChange(_adapter.fromDateRange(dateRange));
13034
+ }
13035
+ }
13036
+ : undefined;
13037
+ let value = null;
13038
+ let valueLabel;
13039
+ if (externalValue) {
13040
+ if (_adapter) {
13041
+ const { from, to, label } = _adapter.toDateRange(externalValue);
13042
+ value = `${from || ''} to ${to || ''}`;
13043
+ valueLabel = label;
13044
+ }
13045
+ else {
13046
+ value = `${externalValue.from || ''} to ${externalValue.to || ''}`;
13047
+ valueLabel = externalValue.label;
13048
+ }
13049
+ }
13050
+ return jsxRuntimeExports.jsx(PickerComponent, { ...datePickerProps, value: value, onChange: onChange, type: type$2, label: valueLabel });
12764
13051
  };
12765
13052
 
12766
- const isCurrent = (d, year, month, day) => {
12767
- return d.getFullYear() === year && d.getMonth() === month && d.getDate() === day;
13053
+ const type$1 = {
13054
+ date: false,
13055
+ time: true,
13056
+ range: false,
12768
13057
  };
12769
- const isActive = (date) => {
12770
- return date.year !== undefined && date.month !== undefined && date.year !== undefined;
13058
+ const TimePickerComponent = (props) => {
13059
+ return jsxRuntimeExports.jsx(PickerComponent, { ...props, type: type$1 });
12771
13060
  };
12772
- const inRange = (year, month, day, from, to) => {
12773
- let fromDate;
12774
- if (from.year !== undefined && from.month !== undefined && from.day !== undefined) {
12775
- fromDate = new Date(`${from.year}-${from.month.padStart(2, '0')}-${String(from.day).padStart(2, '0')}`);
12776
- }
12777
- else {
12778
- return false;
12779
- }
12780
- let toDate;
12781
- if (to.year !== undefined && to.month !== undefined && to.day !== undefined) {
12782
- toDate = new Date(`${to.year}-${to.month.padStart(2, '0')}-${String(to.day).padStart(2, '0')}`);
12783
- }
12784
- else {
12785
- return false;
12786
- }
12787
- let currentDate = new Date(`${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`);
12788
- return (currentDate > fromDate && currentDate < toDate) || (currentDate < fromDate && currentDate > toDate);
13061
+
13062
+ const type = {
13063
+ date: false,
13064
+ time: true,
13065
+ range: true,
12789
13066
  };
12790
- const isInversedDate = (from, to) => {
12791
- if (!isActive(from) || !isActive(to)) {
12792
- return false;
12793
- }
12794
- const fromDate = new Date(`${from.year}-${String(from.month ?? 0 + 1).padStart(2, '0')}-${String(from.day).padStart(2, '0')}`);
12795
- const toDate = new Date(`${to.year}-${String(to.month ?? 0 + 1).padStart(2, '0')}-${String(to.day).padStart(2, '0')}`);
12796
- return fromDate > toDate;
13067
+ const TimeRangePickerComponent = (props) => {
13068
+ return jsxRuntimeExports.jsx(PickerComponent, { ...props, type: type });
12797
13069
  };
12798
- function getMonth(candidate, defaultValue) {
12799
- if (typeof candidate === 'string') {
12800
- candidate = parseInt(candidate) - 1;
12801
- }
12802
- if (candidate === undefined || isNaN(candidate) || candidate < 0 || candidate > 11) {
12803
- return defaultValue;
12804
- }
12805
- return candidate;
12806
- }
12807
- function getYear(candidate, min, max, defaultValue) {
12808
- if (typeof candidate === 'string') {
12809
- candidate = parseInt(candidate);
12810
- }
12811
- if (candidate === undefined || isNaN(candidate) || candidate < min || candidate > max) {
12812
- return defaultValue;
12813
- }
12814
- return candidate;
12815
- }
12816
- const defaultMinDate = new Date();
12817
- defaultMinDate.setFullYear(1900);
12818
- const defaultMaxDate = new Date();
12819
- defaultMaxDate.setFullYear(2100);
12820
- const CalendarComponent = ({ from, to, type, minDate = defaultMinDate, maxDate = defaultMaxDate, nextSelectEdge, className, onChange, }) => {
12821
- const maxYear = maxDate.getFullYear();
12822
- const minYear = minDate.getFullYear();
12823
- const years = useRef([...Array(maxYear).keys()].slice(minYear));
12824
- const d = new Date();
12825
- const lastExternalFromMonth = useRef(from['month']);
12826
- const lastExternalFromYear = useRef(from['year']);
12827
- const lastExternalToMonth = useRef(to['month']);
12828
- const lastExternalToYear = useRef(to['year']);
12829
- const fromMonth = getMonth(from['month']);
12830
- const fromYear = getYear(from['year'], minYear, maxYear);
12831
- const fromDay = from['day'] === undefined ? undefined : parseInt(`${from['day']}`);
12832
- const [internalTo, setInternalTo] = useState({});
12833
- let transientTo = false;
12834
- let toMonth, toYear, toDay;
12835
- let isInversed = false;
12836
- if (to.year !== undefined && to.month !== undefined && to.day !== undefined) {
12837
- toMonth = getMonth(to.month);
12838
- toYear = getYear(to.year, minYear, maxYear);
12839
- toDay = parseInt(`${to.day}`);
12840
- }
12841
- else {
12842
- toMonth = getMonth(internalTo.month);
12843
- toYear = getYear(internalTo.year, minYear, maxYear);
12844
- toDay = parseInt(`${internalTo.day}`);
12845
- transientTo = true;
12846
- isInversed = isInversedDate(from, internalTo);
12847
- }
12848
- const [currentMonth, setCurrentMonth] = useState(getMonth(from['month'], d.getMonth()));
12849
- const [currentYear, setCurrentYear] = useState(getYear(from['year'], minYear, maxYear, d.getFullYear()));
12850
- const firstDayOfExternalFromMonth = fromMonth && fromYear ? new Date(`${fromYear}-${String(getMonth(fromMonth + 1)).padStart(2, '0')}-01`) : undefined;
12851
- const firstDayOfExternalToMonth = toMonth && toYear ? new Date(`${toYear}-${String(toMonth + 1).padStart(2, '0')}-01`) : undefined;
12852
- const firstDayOfCurrentMonth = new Date(`${currentYear}-${String(currentMonth + 1).padStart(2, '0')}-01`);
12853
- const lastDayOfPreviousMonth = new Date(firstDayOfCurrentMonth);
12854
- lastDayOfPreviousMonth.setDate(lastDayOfPreviousMonth.getDate() - 1);
12855
- const lastDayOfCurrentMonth = new Date(firstDayOfCurrentMonth);
12856
- lastDayOfCurrentMonth.setMonth(lastDayOfCurrentMonth.getMonth() + 1);
12857
- lastDayOfCurrentMonth.setDate(lastDayOfCurrentMonth.getDate() - 1);
12858
- const firstDayOfNextMonth = new Date(firstDayOfCurrentMonth);
12859
- firstDayOfNextMonth.setMonth(firstDayOfNextMonth.getMonth() + 1);
12860
- let calendarDays = firstDayOfCurrentMonth.getDate() === 0 || firstDayOfCurrentMonth.getDay() === 0
12861
- ? []
12862
- : [...Array(lastDayOfPreviousMonth.getDate() + 1).keys()].slice(-firstDayOfCurrentMonth.getDay()).map((n) => {
12863
- const startRange = fromDay === n &&
12864
- lastDayOfPreviousMonth.getMonth() === firstDayOfExternalFromMonth?.getMonth() &&
12865
- lastDayOfPreviousMonth.getFullYear() === firstDayOfExternalFromMonth?.getFullYear();
12866
- const endRange = toDay === n &&
12867
- lastDayOfPreviousMonth.getMonth() === firstDayOfExternalToMonth?.getMonth() &&
12868
- lastDayOfPreviousMonth.getFullYear() === firstDayOfExternalToMonth?.getFullYear();
12869
- return {
12870
- day: n,
12871
- active: startRange || endRange,
12872
- current: isCurrent(d, lastDayOfPreviousMonth.getFullYear(), lastDayOfPreviousMonth.getMonth(), n),
12873
- month: lastDayOfPreviousMonth.getMonth(),
12874
- year: lastDayOfPreviousMonth.getFullYear(),
12875
- startRange: startRange && type.range,
12876
- endRange: isActive(from) && endRange && type.range,
12877
- inRange: type.range &&
12878
- inRange(lastDayOfPreviousMonth.getFullYear(), lastDayOfPreviousMonth.getMonth(), n, from, transientTo ? internalTo : to),
13070
+
13071
+ const DatePicker = styled(DatePickerComponent) `
13072
+ ${datePickerStyle}
13073
+ `;
13074
+ const DateRangePicker = styled(DateRangePickerComponent) `
13075
+ ${datePickerStyle}
13076
+ `;
13077
+ const DateTimePicker = styled(DateTimePickerComponent) `
13078
+ ${datePickerStyle}
13079
+ `;
13080
+ const DateTimeRangePicker = styled(DateTimeRangePickerComponent) `
13081
+ ${datePickerStyle}
13082
+ `;
13083
+ const TimePicker = styled(TimePickerComponent) `
13084
+ ${datePickerStyle}
13085
+ `;
13086
+ const TimeRangePicker = styled(TimeRangePickerComponent) `
13087
+ ${datePickerStyle}
13088
+ `;
13089
+
13090
+ const FormDateValueDisplayer = ({ value }) => {
13091
+ return jsxRuntimeExports.jsx("span", { className: "o-date-picker-displayer-value", children: value ?? '' });
13092
+ };
13093
+ const formDateDisplayerProps = (props) => ({
13094
+ defaultValue: props.defaultValue === undefined ? null : props.defaultValue,
13095
+ isUndefined: props.isUndefined === undefined ? (value) => value === undefined || value === null : props.isUndefined,
13096
+ Displayer: props.Displayer === undefined
13097
+ ? (displayerProps) => {
13098
+ const form = useForm();
13099
+ let value = form.getValue(displayerProps.name) ?? null;
13100
+ const ValueDisplayer = props.ValueDisplayer ?? FormDateValueDisplayer;
13101
+ const adapter = props.adapter === 'timestamp'
13102
+ ? timestampMilliSecondAdapter
13103
+ : props.adapter === 'date'
13104
+ ? dateAdapter
13105
+ : props.adapter;
13106
+ if (adapter) {
13107
+ value = adapter.toDate(value);
13108
+ }
13109
+ return (jsxRuntimeExports.jsx(FieldDisplayer, { label: displayerProps.label ?? titlelize(displayerProps.name), help: props.help, first: displayerProps.first, last: displayerProps.last, value: jsxRuntimeExports.jsx(ValueDisplayer, { value: value }), format: displayerProps.format }));
13110
+ }
13111
+ : props.Displayer,
13112
+ });
13113
+ /**
13114
+ * `<FormDatePicker/>` is a DataPicker component designed to be managed by a Form.
13115
+ * It must therefore be a nested component of a Form
13116
+ *
13117
+ * Some properties are handled entirely by a form controller.
13118
+ * * value
13119
+ * * onChange
13120
+ * * onFocus
13121
+ * * onBlur
13122
+ * * validations
13123
+ * * visibility
13124
+ * * disabled
13125
+ * The value is synchronized in both directions (it can be modified manually by the user or by the controller).
13126
+ *
13127
+ * @group Form
13128
+ * @category Components
13129
+ */
13130
+ const FormDatePicker = React.memo((props) => {
13131
+ const [fieldLayoutProps, fieldComponentProps] = useFieldLayout(Object.assign({}, props, formDateDisplayerProps(props)));
13132
+ return (jsxRuntimeExports.jsx(FieldLayout, { ...fieldLayoutProps, required: props.required, children: jsxRuntimeExports.jsx(DatePicker, { ...fieldComponentProps }) }));
13133
+ });
13134
+ FormDatePicker.displayName = 'FormDatePicker';
13135
+
13136
+ const FormDateRangeValueDisplayer = ({ value }) => {
13137
+ return jsxRuntimeExports.jsx("span", { className: "o-date-picker-range-displayer-value", children: value ? `${value.from} - ${value.to}` : '' });
13138
+ };
13139
+ const formDateRangeDisplayerProps = (props) => ({
13140
+ defaultValue: props.defaultValue === undefined ? null : props.defaultValue,
13141
+ isUndefined: props.isUndefined === undefined ? (value) => value === undefined || value === null : props.isUndefined,
13142
+ Displayer: props.Displayer === undefined
13143
+ ? (displayerProps) => {
13144
+ const form = useForm();
13145
+ let value = form.getValue(displayerProps.name) ?? null;
13146
+ const ValueDisplayer = props.ValueDisplayer ?? FormDateRangeValueDisplayer;
13147
+ const adapter = props.adapter === 'timestamp'
13148
+ ? timestampMilliSecondRangeAdapter
13149
+ : props.adapter === 'date'
13150
+ ? dateRangeAdapter
13151
+ : props.adapter;
13152
+ if (adapter) {
13153
+ value = adapter.toDateRange(value);
13154
+ }
13155
+ return (jsxRuntimeExports.jsx(FieldDisplayer, { label: displayerProps.label ?? titlelize(displayerProps.name), help: props.help, first: displayerProps.first, last: displayerProps.last, value: jsxRuntimeExports.jsx(ValueDisplayer, { value: value }), format: displayerProps.format }));
13156
+ }
13157
+ : props.Displayer,
13158
+ });
13159
+ /**
13160
+ * `<FormDateRangePicker/>` is a DataPicker component designed to be managed by a Form.
13161
+ * It must therefore be a nested component of a Form
13162
+ *
13163
+ * Some properties are handled entirely by a form controller.
13164
+ * * value
13165
+ * * onChange
13166
+ * * onFocus
13167
+ * * onBlur
13168
+ * * validations
13169
+ * * visibility
13170
+ * * disabled
13171
+ * The value is synchronized in both directions (it can be modified manually by the user or by the controller).
13172
+ *
13173
+ * @group Form
13174
+ * @category Components
13175
+ */
13176
+ const FormDateRangePicker = React.memo((props) => {
13177
+ const [fieldLayoutProps, fieldComponentProps] = useFieldLayout(Object.assign({}, props, formDateRangeDisplayerProps(props)));
13178
+ return (jsxRuntimeExports.jsx(FieldLayout, { ...fieldLayoutProps, required: props.required, children: jsxRuntimeExports.jsx(DateRangePicker, { ...fieldComponentProps }) }));
13179
+ });
13180
+ FormDateRangePicker.displayName = 'FormDateRangePicker';
13181
+
13182
+ /**
13183
+ * `<FormDateTimePicker/>` is a DataTimePicker component designed to be managed by a Form.
13184
+ * It must therefore be a nested component of a Form
13185
+ *
13186
+ * Some properties are handled entirely by a form controller.
13187
+ * * value
13188
+ * * onChange
13189
+ * * onFocus
13190
+ * * onBlur
13191
+ * * validations
13192
+ * * visibility
13193
+ * * disabled
13194
+ * The value is synchronized in both directions (it can be modified manually by the user or by the controller).
13195
+ *
13196
+ * @group Form
13197
+ * @category Components
13198
+ */
13199
+ const FormDateTimePicker = React.memo((props) => {
13200
+ const [fieldLayoutProps, fieldComponentProps] = useFieldLayout(Object.assign({}, props, formDateDisplayerProps(props)));
13201
+ return (jsxRuntimeExports.jsx(FieldLayout, { ...fieldLayoutProps, required: props.required, children: jsxRuntimeExports.jsx(DateTimePicker, { ...fieldComponentProps }) }));
13202
+ });
13203
+ FormDateTimePicker.displayName = 'FormDateTimePicker';
13204
+
13205
+ /**
13206
+ * `<FormDateTimeRangePicker/>` is a DataTimeRangePicker component designed to be managed by a Form.
13207
+ * It must therefore be a nested component of a Form
13208
+ *
13209
+ * Some properties are handled entirely by a form controller.
13210
+ * * value
13211
+ * * onChange
13212
+ * * onFocus
13213
+ * * onBlur
13214
+ * * validations
13215
+ * * visibility
13216
+ * * disabled
13217
+ * The value is synchronized in both directions (it can be modified manually by the user or by the controller).
13218
+ *
13219
+ * @group Form
13220
+ * @category Components
13221
+ */
13222
+ const FormDateTimeRangePicker = React.memo((props) => {
13223
+ const [fieldLayoutProps, fieldComponentProps] = useFieldLayout(Object.assign({}, props, formDateRangeDisplayerProps(props)));
13224
+ return (jsxRuntimeExports.jsx(FieldLayout, { ...fieldLayoutProps, required: props.required, children: jsxRuntimeExports.jsx(DateTimeRangePicker, { ...fieldComponentProps }) }));
13225
+ });
13226
+ FormDateTimeRangePicker.displayName = 'FormDateTimeRangePicker';
13227
+
13228
+ const useQuickRanges = (ranges) => {
13229
+ const result = useLazyRef(() => {
13230
+ if (!Array.isArray(ranges)) {
13231
+ ranges = [ranges];
13232
+ }
13233
+ const quickRanges = ranges.reduce((accumulator, range) => {
13234
+ if (typeof range === 'string') {
13235
+ if (range === 'all') {
13236
+ accumulator = Object.assign(accumulator, defaultQuickRanges());
13237
+ }
13238
+ else {
13239
+ const dateRange = qr(range);
13240
+ if (dateRange !== null) {
13241
+ accumulator[range] = dateRange;
13242
+ }
13243
+ }
13244
+ }
13245
+ else {
13246
+ accumulator[range.label] = range;
13247
+ }
13248
+ return accumulator;
13249
+ }, {});
13250
+ const target = Object.keys(quickRanges).reduce((accumulator, label) => {
13251
+ accumulator[label] = {
13252
+ from: null,
13253
+ to: null,
13254
+ label,
12879
13255
  };
12880
- });
12881
- calendarDays = calendarDays.concat([...Array(lastDayOfCurrentMonth.getDate() + 1).keys()].slice(1).map((n) => {
12882
- const startRange = fromDay === n &&
12883
- lastDayOfCurrentMonth.getMonth() === firstDayOfExternalFromMonth?.getMonth() &&
12884
- lastDayOfCurrentMonth.getFullYear() === firstDayOfExternalFromMonth?.getFullYear();
12885
- const endRange = toDay === n &&
12886
- lastDayOfCurrentMonth.getMonth() === firstDayOfExternalToMonth?.getMonth() &&
12887
- lastDayOfCurrentMonth.getFullYear() === firstDayOfExternalToMonth?.getFullYear();
12888
- return {
12889
- day: n,
12890
- active: startRange || endRange,
12891
- current: isCurrent(d, lastDayOfCurrentMonth.getFullYear(), lastDayOfCurrentMonth.getMonth(), n),
12892
- month: lastDayOfCurrentMonth.getMonth(),
12893
- year: lastDayOfCurrentMonth.getFullYear(),
12894
- startRange: startRange && type.range,
12895
- endRange: isActive(from) && endRange && type.range,
12896
- inRange: type.range &&
12897
- inRange(lastDayOfCurrentMonth.getFullYear(), lastDayOfCurrentMonth.getMonth(), n, from, transientTo ? internalTo : to),
13256
+ return accumulator;
13257
+ }, {});
13258
+ const handler = {
13259
+ get: function (_, prop) {
13260
+ if (typeof prop === 'string') {
13261
+ const quickRange = quickRanges[prop];
13262
+ if (quickRange) {
13263
+ return {
13264
+ from: dateToString(quickRange.from),
13265
+ to: dateToString(quickRange.to),
13266
+ label: quickRange.label,
13267
+ };
13268
+ }
13269
+ }
13270
+ return undefined;
13271
+ },
12898
13272
  };
12899
- }));
12900
- calendarDays = calendarDays.concat(lastDayOfCurrentMonth.getDay() === 6
12901
- ? []
12902
- : [...Array(6 - lastDayOfCurrentMonth.getDay() + 1).keys()].slice(1).map((n) => {
12903
- const startRange = fromDay === n &&
12904
- firstDayOfNextMonth.getMonth() === firstDayOfExternalFromMonth?.getMonth() &&
12905
- firstDayOfNextMonth.getFullYear() === firstDayOfExternalFromMonth?.getFullYear();
12906
- const endRange = toDay === n &&
12907
- firstDayOfNextMonth.getMonth() === firstDayOfExternalToMonth?.getMonth() &&
12908
- firstDayOfNextMonth.getFullYear() === firstDayOfExternalToMonth?.getFullYear();
12909
- return {
12910
- day: n,
12911
- active: startRange || endRange,
12912
- current: isCurrent(d, firstDayOfNextMonth.getFullYear(), firstDayOfNextMonth.getMonth(), n),
12913
- month: firstDayOfNextMonth.getMonth(),
12914
- year: firstDayOfNextMonth.getFullYear(),
12915
- startRange: startRange && type.range,
12916
- endRange: isActive(from) && endRange && type.range,
12917
- inRange: type.range &&
12918
- inRange(firstDayOfNextMonth.getFullYear(), firstDayOfNextMonth.getMonth(), n, from, transientTo ? internalTo : to),
12919
- };
12920
- }));
12921
- useEffect(() => {
12922
- if (type.range && to['month'] !== lastExternalToMonth.current) {
12923
- // the user has changed the toMonth from the input field
12924
- // we move the calendar to this month if it's a valid month
12925
- lastExternalToMonth.current = to['month'];
12926
- setCurrentMonth(getMonth(to['month'], currentMonth));
12927
- }
12928
- if (type.range && to['year'] !== lastExternalToYear.current) {
12929
- // the user has changed the toYear from the input field
12930
- // we move the calendar to this year if it's a valid year
12931
- lastExternalToYear.current = to['year'];
12932
- setCurrentYear(getYear(to['year'], minYear, maxYear, currentYear));
12933
- }
12934
- if (from['month'] !== lastExternalFromMonth.current) {
12935
- // the user has changed the fromMonth from the input field
12936
- // we move the calendar to this month if it's a valid month
12937
- lastExternalFromMonth.current = from['month'];
12938
- setCurrentMonth(getMonth(from['month'], currentMonth));
12939
- }
12940
- if (from['year'] !== lastExternalFromYear.current) {
12941
- // the user has changed the fromYear from the input field
12942
- // we move the calendar to this year if it's a valid year
12943
- lastExternalFromYear.current = from['year'];
12944
- setCurrentYear(getYear(from['year'], minYear, maxYear, currentYear));
12945
- }
13273
+ return new Proxy(target, handler);
12946
13274
  });
12947
- return (jsxRuntimeExports.jsxs("div", { className: addClassname('o-calendar-container', className), children: [jsxRuntimeExports.jsxs("div", { className: "o-calendar-month", children: [jsxRuntimeExports.jsx(TogglerIcon, { width: "20px", closeArrowPosition: "w", onClick: () => {
12948
- if (fromMonth === 0) {
12949
- setCurrentMonth(11);
12950
- setCurrentYear(currentYear - 1);
12951
- }
12952
- else {
12953
- setCurrentMonth(currentMonth - 1);
12954
- }
12955
- } }, "previous"), jsxRuntimeExports.jsx(Select, { dataSource: months, nullable: false, value: months[currentMonth], className: "o-calendar-select-month", size: "small", onChange: (value) => setCurrentMonth(months.indexOf(`${value}`)) }, "month"), jsxRuntimeExports.jsx(Select, { dataSource: years.current, value: currentYear, nullable: false, className: "o-calendar-select-year", size: "small", onChange: (value) => setCurrentYear(parseInt(`${value}`)) }, "year"), jsxRuntimeExports.jsx(TogglerIcon, { width: "20px", closeArrowPosition: "e", onClick: () => {
12956
- if (fromMonth === 11) {
12957
- setCurrentMonth(0);
12958
- setCurrentYear(currentYear + 1);
12959
- }
12960
- else {
12961
- setCurrentMonth(currentMonth + 1);
12962
- }
12963
- } }, "next")] }), jsxRuntimeExports.jsxs("div", { className: "o-calendar-day-container", children: [days.map((day) => (jsxRuntimeExports.jsx("div", { className: "o-calendar-day-title", children: day.substring(0, 2) }, `${day}`))), calendarDays.map((calendarDay, index) => (jsxRuntimeExports.jsx("div", { className: `o-calendar-day${calendarDay.endRange
12964
- ? ` o-calendar-day-${isInversed ? 'start' : 'end'}-range${transientTo ? '-transient' : ''}`
12965
- : ''}${calendarDay.startRange ? ` o-calendar-day-${isInversed ? 'end' : 'start'}-range` : ''}${calendarDay.active ? ' o-calendar-day-active' : ''}${calendarDay.inRange ? ` o-calendar-day-in-range${transientTo ? '-transient' : ''}` : ''}${calendarDay.month === currentMonth ? ' o-calendar-day-in-month' : ''}${calendarDay.current ? ' o-calendar-day-current' : ''}`, onClick: () => {
12966
- const nextDateString = `${calendarDay.year}-${String(calendarDay.month + 1).padStart(2, '0')}-${String(calendarDay.day).padStart(2, '0')}`;
12967
- if (type.range && from.year !== undefined && from.month !== undefined && from.day !== undefined) {
12968
- // It's a date range and not the first selection
12969
- // We must determine if it's a change for the from or the to
12970
- const fromDateString = `${from.year}-${from.month.padStart(2, '0')}-${String(from.day).padStart(2, '0')}`;
12971
- const fromDate = new Date(fromDateString);
12972
- let endDate = undefined;
12973
- let endDateString = undefined;
12974
- if (to.year !== undefined && to.month !== undefined && to.day !== undefined) {
12975
- // it's not the second click
12976
- endDateString = `${to.year}-${to.month.padStart(2, '0')}-${String(to.day).padStart(2, '0')}`;
12977
- endDate = new Date(endDateString);
12978
- }
12979
- const nextDate = new Date(nextDateString);
12980
- if (endDate) {
12981
- // case when we click on the same day than the fromDate
12982
- if (isSameDay(fromDate, nextDate)) {
12983
- if (nextDate <= fromDate) {
12984
- onChange(nextDateString, fromDateString);
12985
- }
12986
- else {
12987
- onChange(fromDateString, nextDateString);
12988
- }
12989
- }
12990
- // case when we click on the same day than the endDate
12991
- else if (isSameDay(endDate, nextDate)) {
12992
- if (nextDate <= endDate) {
12993
- onChange(nextDateString, endDateString);
12994
- }
12995
- else {
12996
- onChange(endDateString, nextDateString);
12997
- }
12998
- }
12999
- else if (nextDate <= fromDate) {
13000
- onChange(nextDateString, endDateString);
13001
- }
13002
- else if (nextDate >= endDate) {
13003
- onChange(fromDateString, nextDateString);
13004
- }
13005
- else if (nextSelectEdge === 'from') {
13006
- onChange(nextDateString, endDateString);
13007
- }
13008
- else {
13009
- onChange(fromDateString, nextDateString);
13010
- }
13011
- }
13012
- else if (nextDate <= fromDate) {
13013
- onChange(nextDateString, fromDateString);
13014
- }
13015
- else {
13016
- onChange(fromDateString, nextDateString);
13017
- }
13018
- }
13019
- else {
13020
- // we assume that it's not a range or the first selection of the range
13021
- onChange(nextDateString);
13022
- }
13023
- }, onMouseEnter: () => {
13024
- if (transientTo) {
13025
- setInternalTo({
13026
- year: `${calendarDay.year}`,
13027
- month: String(calendarDay.month + 1).padStart(2, '0'),
13028
- day: String(calendarDay.day).padStart(2, '0'),
13029
- });
13030
- }
13031
- }, children: calendarDay.day }, `${fromDay}-${index}`)))] })] }));
13275
+ return result.current;
13276
+ };
13277
+
13278
+ const SliderComponent = () => {
13279
+ return null;
13280
+ };
13281
+
13282
+ const sliderStyle = () => {
13283
+ return css ``;
13284
+ };
13285
+
13286
+ const Resizer = styled(SliderComponent) `
13287
+ ${sliderStyle}
13288
+ `;
13289
+
13290
+ const TagComponent = ({ className, children, onClick, icon }) => {
13291
+ return (jsxRuntimeExports.jsxs("div", { className: addClassname('o-tag', className), onClick: onClick, children: [icon && jsxRuntimeExports.jsx("span", { className: "o-tag-icon", children: icon }), children] }));
13292
+ };
13293
+
13294
+ const tagStyle = ({ theme, kind, bgColor = 'primary', fontColor = 'white', size = 'small', onClick, marginBottom: mb = 0, marginLeft: ml = 0, marginRight: mr = 0, marginTop: mt = 0, }) => {
13295
+ let fSize = 'sm';
13296
+ let lHeight = 'md';
13297
+ let pX = 'md';
13298
+ let radius = 'sm';
13299
+ const pt = '2xs';
13300
+ if (size === 'small') {
13301
+ fSize = 'xs';
13302
+ lHeight = 'xs';
13303
+ radius = 'xs';
13304
+ pX = 'sm';
13305
+ }
13306
+ if (size === 'large') {
13307
+ fSize = 'md';
13308
+ lHeight = 'lg';
13309
+ }
13310
+ return css `
13311
+ ${display('inline-flex')}
13312
+ ${alignItems('center')}
13313
+ ${backgroundColor(kind ? theme.buttons[kind].bgColor : bgColor)}
13314
+ ${marginLeft(ml)}
13315
+ ${marginRight(mr)}
13316
+ ${marginBottom(mb)}
13317
+ ${marginTop(mt)}
13318
+ ${lineHeight(lHeight)}
13319
+ ${paddingX(pX)}
13320
+ ${paddingTop(pt)}
13321
+ ${color(kind ? theme.buttons[kind].color : fontColor)}
13322
+ ${fontSize(fSize)}
13323
+ ${cursor(onClick ? 'pointer' : 'inherit')}
13324
+ ${borderRadius(radius)}
13325
+ .o-tag-icon {
13326
+ ${marginRight('xs')}
13327
+ ${display('inline-flex')}
13328
+ ${alignItems('center')}
13329
+ }
13330
+ `;
13032
13331
  };
13033
13332
 
13034
- const QuickTimeRangeComponent = ({ quickRanges, onChange, currentQuickRangeLabel, }) => {
13035
- return (jsxRuntimeExports.jsxs("div", { className: "o-quick-time-range-container", children: [jsxRuntimeExports.jsx("div", { className: "o-quick-time-range-title", children: "Quick select" }), Object.keys(quickRanges).map((quickRangeLabel, index) => {
13036
- return (jsxRuntimeExports.jsx("div", { className: `o-quick-time-range${currentQuickRangeLabel === quickRangeLabel ? ' o-quick-time-range-selected' : ''}`, onClick: () => onChange(quickRangeLabel), children: quickRangeLabel }, `qr-${index}`));
13037
- })] }));
13333
+ const Tag = styled(TagComponent) `
13334
+ ${tagStyle}
13335
+ `;
13336
+
13337
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
13338
+ const WizardServiceContext = React.createContext(null);
13339
+ const useWizardService = () => {
13340
+ return useContext(WizardServiceContext);
13038
13341
  };
13039
13342
 
13040
- const getNextValue = (value, max, type) => {
13041
- const valueInt = parseInt(`${value}`);
13042
- let result = 0;
13043
- if (type === 'next') {
13044
- if (isNaN(valueInt) || valueInt === max) {
13045
- result = 0;
13343
+ const WizardStateContext = React.createContext(null);
13344
+ const useWizardState = () => {
13345
+ return useContext(WizardStateContext);
13346
+ };
13347
+
13348
+ const StepTitleContent = ({ member, index }) => {
13349
+ return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [member.icon, jsxRuntimeExports.jsxs("span", { className: "o-step-title", children: [index, ". ", `${member.title}`] })] }));
13350
+ };
13351
+
13352
+ const StepTitle = (props) => {
13353
+ const { member, onActivate, TitleContentComponent = StepTitleContent } = props;
13354
+ return (jsxRuntimeExports.jsx("div", { className: `o-step${member.active ? ' o-step-active' : ' o-step-inactive'}${member.disabled ? ' o-step-disabled' : ' o-step-enabled'}${member.visible ? ' o-step-visible' : ' o-step-hidden'}${member.touched || member.touching ? ' o-step-touched' : ' o-step-untouched'}${member.success ? ' o-step-success' : ''}${member.touchingWarning || (member.touched && member.warning) ? ' o-step-warning' : ''}${member.touchingError || (member.touched && member.error) ? ' o-step-error' : ''}${member.loading ? ' o-step-loading' : ''}`, onClick: () => onActivate(member), children: jsxRuntimeExports.jsx(TitleContentComponent, { ...props }) }));
13355
+ };
13356
+
13357
+ const WizardContainer = ({ cancelLabel = 'Cancel', className, children, doneLabel = 'Submit', nextLabel = 'Next', onCancel, onDone, previousLabel = 'Previous', title, stepSize = 3, TitleComponent = StepTitle, TitleContentComponent, forwardOnly = true, hasSummaryStep = false, reviewLabel = 'Review and Submit', }) => {
13358
+ const classNames = addClassname('o-wizard', className);
13359
+ const state = useWizardState();
13360
+ const service = useWizardService();
13361
+ const lastStepUid = service.getLastStep()?.uid;
13362
+ const activate = useCallback((step) => {
13363
+ if (!step || step.disabled || (!step.touched && !step.touching))
13364
+ return;
13365
+ if (!step.active) {
13366
+ service.activate(step.uid);
13046
13367
  }
13047
- else {
13048
- result = valueInt + 1;
13368
+ }, [service]);
13369
+ const errorRef = useRef([]);
13370
+ errorRef.current = [];
13371
+ const indexRef = useRef(0);
13372
+ indexRef.current = 0;
13373
+ return (jsxRuntimeExports.jsxs(Row, { className: classNames, children: [jsxRuntimeExports.jsxs(Col, { size: stepSize, className: "o-wizard-step-panel", children: [title && jsxRuntimeExports.jsx("div", { className: "o-wizard-title", children: title }), state.members.map((step) => {
13374
+ if (step.visible) {
13375
+ indexRef.current++;
13376
+ }
13377
+ else {
13378
+ return null;
13379
+ }
13380
+ if (step.error !== undefined) {
13381
+ errorRef.current.push({
13382
+ stepIndex: indexRef.current,
13383
+ stepTitle: step.title,
13384
+ errorMessage: step.error,
13385
+ });
13386
+ }
13387
+ return (jsxRuntimeExports.jsx(TitleComponent, { member: step, onActivate: activate, index: indexRef.current, TitleContentComponent: TitleContentComponent }, `step-title-${step.uid}`));
13388
+ })] }), jsxRuntimeExports.jsxs(Col, { size: (12 - stepSize), className: "o-wizard-content-panel", children: [jsxRuntimeExports.jsx("div", { className: "o-wizard-content", children: children }), jsxRuntimeExports.jsxs("div", { className: "o-wizard-control", children: [onCancel && (jsxRuntimeExports.jsx(Button, { kind: "primary", pattern: "flat", className: "o-wizard-control-button", type: "button", onClick: () => onCancel(), children: cancelLabel })), !service.isFirstStep() && (jsxRuntimeExports.jsx(Button, { kind: "primary", pattern: "outline", className: "o-wizard-control-button", onClick: () => service.previous(), type: "button", children: previousLabel })), !service.isLastStep() && (jsxRuntimeExports.jsx(Button, { kind: service.isCurrentStepInVisibleError() ? 'danger' : 'primary', pattern: "solid", className: "o-wizard-control-button", disabled: service.isCurrentStepInVisibleError(), onClick: () => service.next(), type: "button", children: nextLabel })), (service.isLastStep() || !forwardOnly) && (jsxRuntimeExports.jsx(SubmitButton, { kind: errorRef.current.length > 0 ? 'danger' : 'success', pattern: "solid", className: "o-wizard-control-button", disabled: errorRef.current.length > 0, onClick: hasSummaryStep && !service.isLastStep() && lastStepUid ? () => service.activate(lastStepUid) : onDone, type: "button", showErrors: true, children: hasSummaryStep && !service.isLastStep() ? reviewLabel : doneLabel }))] })] })] }));
13389
+ };
13390
+
13391
+ const ControlledWizardComponent = ({ Component = WizardContainer, controller, ...props }) => {
13392
+ return (jsxRuntimeExports.jsx(WizardServiceContext.Provider, { value: controller, children: jsxRuntimeExports.jsx(WizardStateContext.Provider, { value: controller.state, children: jsxRuntimeExports.jsx(Component, { ...props }) }) }));
13393
+ };
13394
+
13395
+ let WizardService = class WizardService extends TabsService {
13396
+ activateNext() {
13397
+ const nextStep = this.getNextStep();
13398
+ if (nextStep) {
13399
+ this.activate(nextStep.uid);
13049
13400
  }
13050
13401
  }
13051
- else if (type === 'previous') {
13052
- if (isNaN(valueInt)) {
13053
- result = 0;
13402
+ activatePrevious() {
13403
+ const previousStep = this.getPreviousStep();
13404
+ if (previousStep) {
13405
+ this.activate(previousStep.uid);
13054
13406
  }
13055
- else if (valueInt === 0) {
13056
- result = max;
13407
+ }
13408
+ getCurrentStep() {
13409
+ return this.state.members[this.getCurrentActiveIndex()];
13410
+ }
13411
+ getNextStep() {
13412
+ for (let i = this.getCurrentActiveIndex() + 1; i < this.state.members.length; i++) {
13413
+ const step = this.state.members[i];
13414
+ if (step && step.visible && !step.disabled) {
13415
+ return step;
13416
+ }
13057
13417
  }
13058
- else {
13059
- result = valueInt - 1;
13418
+ return undefined;
13419
+ }
13420
+ getLastStep() {
13421
+ return this.state.members.filter((m) => m.visible && !m.disabled).slice(-1)[0];
13422
+ }
13423
+ getPreviousStep() {
13424
+ for (let i = this.getCurrentActiveIndex() - 1; i >= 0; i--) {
13425
+ const step = this.state.members[i];
13426
+ if (step && step.visible && !step.disabled) {
13427
+ return step;
13428
+ }
13060
13429
  }
13430
+ return undefined;
13061
13431
  }
13062
- return String(result).padStart(2, '0');
13063
- };
13064
- const isMin = (value, _type) => {
13065
- return parseInt(`${value}`) === 0;
13066
- };
13067
- const isMax = (value, type) => {
13068
- return type === 'hour' ? parseInt(`${value}`) === 23 : parseInt(`${value}`) === 59;
13069
- };
13070
- const TimeSelectorPartComponent = ({ onChange, type, value, size = 'large', }) => {
13071
- const onValueChange = (e) => {
13072
- let value = e.target.value;
13073
- if (type === 'minute' && (value === '' || isValidMinuteOrSecond(value))) {
13074
- onChange(value);
13432
+ isFirstStep() {
13433
+ if (this.state.active) {
13434
+ return this.state.members.filter((m) => m.visible)[0]?.uid === this.state.active;
13075
13435
  }
13076
- else if (type === 'second' && (value === '' || isValidMinuteOrSecond(value))) {
13077
- onChange(value);
13436
+ return false;
13437
+ }
13438
+ isLastStep() {
13439
+ if (this.state.active) {
13440
+ return this.state.members.filter((m) => m.visible && !m.disabled).slice(-1)[0]?.uid === this.state.active;
13078
13441
  }
13079
- else if (type === 'hour' && (value === '' || isValidHour(value))) {
13080
- onChange(value);
13442
+ return false;
13443
+ }
13444
+ isCurrentStepInError() {
13445
+ if (this.state.active) {
13446
+ const currentStep = this.getMember(this.state.active);
13447
+ return currentStep?.error !== undefined;
13081
13448
  }
13082
- };
13083
- return (jsxRuntimeExports.jsxs("div", { className: `o-time-selector-part o-time-selector-part-${size} o-time-${type}`, children: [jsxRuntimeExports.jsx(TogglerIcon, { className: isMin(value) ? 'o-time-selector-part-icon-disabled' : undefined, width: "20px", closeArrowPosition: "n", onClick: () => {
13084
- if (!isMin(value)) {
13085
- onChange(getNextValue(value, type === 'hour' ? 23 : 59, 'previous'));
13086
- }
13087
- } }, "previous"), jsxRuntimeExports.jsx(Input, { className: "o-time-input", value: value, size: size, selectOnFocus: true, onChange: onValueChange }, "value"), jsxRuntimeExports.jsx(TogglerIcon, { className: isMax(value, type) ? 'o-time-selector-part-icon-disabled' : undefined, width: "20px", closeArrowPosition: "s", onClick: () => {
13088
- if (!isMax(value, type)) {
13089
- onChange(getNextValue(value, type === 'hour' ? 23 : 59, 'next'));
13090
- }
13091
- } }, "next")] }));
13092
- };
13093
-
13094
- const getValue = (candidate, max, defaultValue) => {
13095
- if (typeof candidate === 'string') {
13096
- candidate = parseInt(candidate);
13449
+ return false;
13097
13450
  }
13098
- if (candidate === undefined || isNaN(candidate) || candidate < 0 || candidate > max) {
13099
- return defaultValue;
13451
+ isCurrentStepInVisibleError() {
13452
+ if (this.state.active) {
13453
+ const currentStep = this.getMember(this.state.active);
13454
+ return currentStep?.touchingError !== undefined;
13455
+ }
13456
+ return false;
13100
13457
  }
13101
- return candidate;
13102
- };
13103
- const TimeSelectorComponent = ({ value, onChange, size, edge, displayHours, displayMinutes, displaySeconds, }) => {
13104
- const d = new Date();
13105
- const hourInt = getValue(value.hour, 23, displayHours ? d.getHours() : 0);
13106
- const minuteInt = getValue(value.minute, 59, displayMinutes ? d.getMinutes() : 0);
13107
- const secondInt = getValue(value.second, 59, displaySeconds ? d.getSeconds() : 0);
13108
- const [internalHour, setInternalHour] = useState(String(hourInt).padStart(2, '0'));
13109
- const [internalMinute, setInternalMinute] = useState(String(minuteInt).padStart(2, '0'));
13110
- const [internalSecond, setInternalSecond] = useState(String(secondInt).padStart(2, '0'));
13111
- const hour = internalHour === '' ? '' : parseInt(internalHour) === hourInt ? internalHour : hourInt;
13112
- const minute = internalMinute === '' ? '' : parseInt(internalMinute) === minuteInt ? internalMinute : minuteInt;
13113
- const second = internalSecond === '' ? '' : parseInt(internalSecond) === secondInt ? internalSecond : secondInt;
13114
- const onChangeHour = useCallback((value) => {
13115
- setInternalHour(value);
13116
- if (value !== '') {
13117
- onChange(`${String(value || 0).padStart(2, '0')}:${String(minute || 0).padStart(2, '0')}:${String(second || 0).padStart(2, '0')}`, edge);
13458
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
13459
+ *done() {
13460
+ yield this.setSubmitting(true);
13461
+ if (this.state.onDone) {
13462
+ yield this.state.onDone();
13118
13463
  }
13119
- }, [minute, second, onChange]);
13120
- const onChangeMinute = useCallback((value) => {
13121
- setInternalMinute(value);
13122
- if (value !== '') {
13123
- onChange(`${String(hour || 0).padStart(2, '0')}:${String(value || 0).padStart(2, '0')}:${String(second || 0).padStart(2, '0')}`, edge);
13464
+ yield this.setSubmitting(false);
13465
+ }
13466
+ next() {
13467
+ if (this.isCurrentStepInError()) {
13468
+ const currentStep = this.getCurrentStep();
13469
+ if (currentStep) {
13470
+ this.touched(currentStep.uid);
13471
+ }
13124
13472
  }
13125
- }, [hour, second, onChange]);
13126
- const onChangeSecond = useCallback((value) => {
13127
- setInternalSecond(value);
13128
- if (value !== '') {
13129
- onChange(`${String(hour || 0).padStart(2, '0')}:${String(minute || 0).padStart(2, '0')}:${String(value || 0).padStart(2, '0')}`, edge);
13473
+ else {
13474
+ let result = true;
13475
+ if (this.state.onNext) {
13476
+ result = this.state.onNext(this.getCurrentStep(), this.getNextStep());
13477
+ }
13478
+ if (result) {
13479
+ this.activateNext();
13480
+ }
13130
13481
  }
13131
- }, [hour, minute, onChange]);
13132
- return (jsxRuntimeExports.jsxs("div", { className: "o-time-selector", children: [displayHours && (jsxRuntimeExports.jsx(TimeSelectorPartComponent, { type: "hour", value: hour, onChange: onChangeHour, size: size }, "hour")), displayHours && (displayMinutes || displaySeconds) && (jsxRuntimeExports.jsx("span", { className: "o-time-separator", children: ":" }, "sep1")), displayMinutes && (jsxRuntimeExports.jsx(TimeSelectorPartComponent, { type: "minute", value: minute, onChange: onChangeMinute, size: size }, "minute")), displaySeconds && (displayHours || displayMinutes) && (jsxRuntimeExports.jsx("span", { className: "o-time-separator", children: ":" }, "sep2")), displaySeconds && (jsxRuntimeExports.jsx(TimeSelectorPartComponent, { type: "second", value: second, onChange: onChangeSecond, size: size }, "second"))] }));
13482
+ }
13483
+ previous() {
13484
+ let result = true;
13485
+ if (this.state.onPrevious) {
13486
+ result = this.state.onPrevious(this.getCurrentStep(), this.getPreviousStep());
13487
+ }
13488
+ if (result) {
13489
+ this.activatePrevious();
13490
+ }
13491
+ }
13492
+ setSubmitting(submitting) {
13493
+ this.state.submitting = submitting;
13494
+ }
13133
13495
  };
13496
+ __decorate([
13497
+ reducer,
13498
+ __metadata("design:type", Function),
13499
+ __metadata("design:paramtypes", []),
13500
+ __metadata("design:returntype", void 0)
13501
+ ], WizardService.prototype, "activateNext", null);
13502
+ __decorate([
13503
+ reducer,
13504
+ __metadata("design:type", Function),
13505
+ __metadata("design:paramtypes", []),
13506
+ __metadata("design:returntype", void 0)
13507
+ ], WizardService.prototype, "activatePrevious", null);
13508
+ __decorate([
13509
+ saga(SagaEffect.Leading)
13510
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
13511
+ ,
13512
+ __metadata("design:type", Function),
13513
+ __metadata("design:paramtypes", []),
13514
+ __metadata("design:returntype", void 0)
13515
+ ], WizardService.prototype, "done", null);
13516
+ __decorate([
13517
+ reducer,
13518
+ __metadata("design:type", Function),
13519
+ __metadata("design:paramtypes", []),
13520
+ __metadata("design:returntype", void 0)
13521
+ ], WizardService.prototype, "next", null);
13522
+ __decorate([
13523
+ reducer,
13524
+ __metadata("design:type", Function),
13525
+ __metadata("design:paramtypes", []),
13526
+ __metadata("design:returntype", void 0)
13527
+ ], WizardService.prototype, "previous", null);
13528
+ __decorate([
13529
+ reducer,
13530
+ __metadata("design:type", Function),
13531
+ __metadata("design:paramtypes", [Boolean]),
13532
+ __metadata("design:returntype", void 0)
13533
+ ], WizardService.prototype, "setSubmitting", null);
13534
+ WizardService = __decorate([
13535
+ service
13536
+ ], WizardService);
13134
13537
 
13135
- const TimeRangeComponent = ({ edge, onChange, value, displayHours, displayMinutes, displaySeconds, }) => {
13136
- const valid = isValidDate(`${value.day}-${value.month}-${value.year}`);
13137
- let d;
13138
- if (valid) {
13139
- d = new Date(`${value.year}-${value.month}-${value.day}`);
13140
- }
13141
- const label = edge === 'to' ? 'an end' : 'a start';
13142
- return (jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("div", { className: "o-time-edge-title", children: ucfirst(edge) }, "title"), !valid && (jsxRuntimeExports.jsxs("div", { className: "o-time-edge-empty", children: ["Please select ", label, " date for the period"] }, "empty")), valid && d && (jsxRuntimeExports.jsxs("div", { className: "o-time-edge-content", children: [jsxRuntimeExports.jsx("div", { className: "o-time-edge-date-container", children: jsxRuntimeExports.jsx("span", { className: "o-time-edge-date", children: d.toUTCString().split(' ', 4).join(' ') }) }, "date"), jsxRuntimeExports.jsx(TimeSelectorComponent, { value: value, onChange: onChange, size: "small", edge: edge, displayHours: displayHours, displayMinutes: displayMinutes, displaySeconds: displaySeconds }, "selector")] }, "content"))] }));
13538
+ const useWizardController = ({ animate = 300, forwardOnly = true, onCancel, onDone, onNext, onPrevious, }) => {
13539
+ const [_, service] = useService(WizardService, {
13540
+ members: [],
13541
+ membersIndex: {},
13542
+ animate,
13543
+ forwardOnly,
13544
+ onCancel,
13545
+ onDone,
13546
+ onNext,
13547
+ onPrevious,
13548
+ });
13549
+ return service;
13143
13550
  };
13144
13551
 
13145
- const TimeComponent = ({ from, to, type, className, onChange, displayHours, displayMinutes, displaySeconds, }) => {
13146
- if (type['range'] && type['date']) {
13147
- return (jsxRuntimeExports.jsxs("div", { className: addClassname('o-time-container-range', className), children: [jsxRuntimeExports.jsx(TimeRangeComponent, { type: type, value: from, edge: "from", onChange: onChange, displayHours: displayHours, displayMinutes: displayMinutes, displaySeconds: displaySeconds }), jsxRuntimeExports.jsx(TimeRangeComponent, { type: type, value: to, edge: "to", onChange: onChange, displayHours: displayHours, displayMinutes: displayMinutes, displaySeconds: displaySeconds })] }));
13148
- }
13149
- return (jsxRuntimeExports.jsx("div", { className: addClassname('o-time-container', className), children: jsxRuntimeExports.jsx(TimeSelectorComponent, { value: from, onChange: onChange, size: "large", edge: "from", displayHours: displayHours, displayMinutes: displayMinutes, displaySeconds: displaySeconds }, "selector") }));
13552
+ const UncontrolledWizardComponent = (props) => {
13553
+ const controller = useWizardController(props);
13554
+ return jsxRuntimeExports.jsx(ControlledWizardComponent, { ...props, controller: controller });
13150
13555
  };
13151
13556
 
13152
- const IconComponent = () => {
13153
- const { nullable, setOpen, onChange, open } = useDatePickerContext();
13154
- return (jsxRuntimeExports.jsxs("span", { className: "o-datepicker-icon", children: [nullable && (jsxRuntimeExports.jsx("div", { className: "o-datepicker-remover", onClick: () => {
13155
- onChange(null);
13156
- setOpen(false);
13157
- }, children: "\u2716" })), jsxRuntimeExports.jsx(CalendarIcon, { width: "20px", height: "20px", color: "primary", marginRight: "sm", onClick: () => setOpen(!open) })] }));
13158
- };
13159
- const parseDate = (value) => {
13160
- let date, time, year, month, day, hour, minute, second = undefined;
13161
- if (value) {
13162
- [date, time] = value.trim().split(' ');
13163
- [year, month, day] = date ? date.split('-') : [undefined, undefined, undefined];
13164
- [hour, minute, second] = time ? time.split(':') : [undefined, undefined, undefined];
13165
- }
13166
- return { date, time, year, month, day, hour, minute, second };
13167
- };
13168
- const isValidValue = (value, type) => {
13169
- const isValidDate = (value) => {
13170
- const d = new Date(value);
13171
- return !isNaN(d);
13172
- };
13173
- if (!value)
13174
- return true;
13175
- if (type.range) {
13176
- const [from, to] = value.split(' to ');
13177
- if (!from || !to)
13178
- return false;
13179
- return isValidDate(from) && isValidDate(to);
13557
+ const WizardComponent = (props) => {
13558
+ if (props.controller) {
13559
+ return jsxRuntimeExports.jsx(ControlledWizardComponent, { ...props, controller: props.controller });
13180
13560
  }
13181
13561
  else {
13182
- return isValidDate(value);
13562
+ return jsxRuntimeExports.jsx(UncontrolledWizardComponent, { ...props });
13183
13563
  }
13184
13564
  };
13185
- const isSameDate = (d1, d2, type) => {
13186
- const isSameDate = (d1, d2) => {
13187
- if (!d1 && !d2)
13188
- return true;
13189
- if (!d1 || !d2)
13190
- return false;
13191
- const date1 = new Date(`${d1}`);
13192
- const date2 = new Date(`${d2}`);
13193
- if (isNaN(date1) || isNaN(date2)) {
13194
- return false;
13195
- }
13196
- return date1.toString() === date2.toString();
13197
- };
13198
- if (d1 === null && d2 === null)
13199
- return true;
13200
- if (!d1 || !d2)
13201
- return false;
13202
- if (type.range) {
13203
- const [from1, to1] = d1.split(' to ');
13204
- const [from2, to2] = d2.split(' to ');
13205
- return isSameDate(from1, from2) && isSameDate(to1, to2);
13565
+
13566
+ const wizardStyle = ({ layout = 'vertical', theme, inModal }) => {
13567
+ const t = theme.wizard;
13568
+ const stepBorderWidthFn = layout === 'horizontal' ? borderBottomWidth : borderLeftWidth;
13569
+ const stepBorderStyleFn = layout === 'horizontal' ? borderBottomStyle : borderLeftStyle;
13570
+ const stepBorderColorFn = layout === 'horizontal' ? borderBottomColor : borderLeftColor;
13571
+ const wizardBorderWidthFn = layout === 'horizontal' ? borderBottomWidth : borderRightWidth;
13572
+ const wizardBorderStyleFn = layout === 'horizontal' ? borderBottomStyle : borderRightStyle;
13573
+ const wizardBorderColorFn = layout === 'horizontal' ? borderBottomColor : borderRightColor;
13574
+ return css `
13575
+ ${display('flex')}
13576
+ ${flexDirection(layout === 'horizontal' ? 'column' : 'row')}
13577
+ .o-wizard-step-panel {
13578
+ ${display('flex')}
13579
+ ${flexDirection(layout === 'horizontal' ? 'row' : 'column')}
13580
+ ${alignItems(layout === 'horizontal' ? 'flex-end' : 'stretch')}
13581
+ ${wizardBorderStyleFn(inModal ? t.modalStepsBorderStyle : t.stepsBorderStyle)}
13582
+ ${wizardBorderWidthFn(inModal ? t.modalStepsBorderWidth : t.stepsBorderWidth)}
13583
+ ${wizardBorderColorFn(inModal ? t.modalStepsBorderColor : t.stepsBorderColor)}
13584
+ ${paddingRight(t.stepsPaddingRight)}
13585
+ ${paddingTop(t.stepsPaddingTop)}
13586
+ ${paddingLeft(t.stepsPaddingLeft)}
13587
+ ${paddingBottom(t.stepsPaddingBottom)}
13588
+ ${backgroundColor(inModal ? t.modalStepsBgColor : t.stepsBgColor)}
13206
13589
  }
13207
- else {
13208
- return isSameDate(d1, d2);
13590
+
13591
+ .o-step {
13592
+ ${paddingRight(t.paddingRight)}
13593
+ ${paddingTop(t.paddingTop)}
13594
+ ${paddingLeft(t.paddingLeft)}
13595
+ ${paddingBottom(t.paddingBottom)}
13596
+ ${stepBorderStyleFn(t.borderStyle)}
13597
+ ${stepBorderWidthFn(t.borderWidth)}
13598
+ ${stepBorderColorFn(t.borderColor)}
13599
+ ${fontWeight(t.fontWeight)}
13600
+ ${fontSize(t.fontSize)}
13601
+ ${color(t.fontColor)}
13209
13602
  }
13210
- };
13211
- const formatDate = (type, fromDate, fromTime, toDate, toTime) => {
13212
- const format = (date, time) => {
13213
- let result = '';
13214
- if (type.date) {
13215
- result += `${date || ''}`;
13216
- }
13217
- if (type.time) {
13218
- if (type.date && date) {
13219
- result += ` ${time || '00:00:00'}`;
13220
- }
13221
- else if (type.date && time) {
13222
- result += ` ${time}`;
13223
- }
13224
- else if (time) {
13225
- result += time;
13226
- }
13227
- }
13228
- return result;
13229
- };
13230
- let result = format(fromDate, fromTime);
13231
- if (type.range) {
13232
- result += ` to ${format(toDate, toTime)}`;
13603
+
13604
+ .o-step-active {
13605
+ ${stepBorderColorFn(t.activeBorderColor)}
13606
+ ${color(t.activeFontColor)}
13607
+ ${fontWeight(t.activeFontWeight)}
13608
+ ${fontSize(t.activeFontSize)}
13609
+ ${backgroundColor(t.activeBgColor)}
13610
+ &.o-step-enabled {
13611
+ ${cursor('default')}
13612
+ }
13613
+
13614
+ &.o-step-warning {
13615
+ ${stepBorderColorFn(t.warningBorderColor)}
13616
+ ${color(t.warningFontColor)}
13617
+ ${backgroundColor(t.warningBgColor)}
13618
+ }
13619
+ &.o-step-error {
13620
+ ${stepBorderColorFn(t.errorBorderColor)}
13621
+ ${color(t.errorFontColor)}
13622
+ ${backgroundColor(t.errorBgColor)}
13623
+ }
13233
13624
  }
13234
- return result;
13235
- };
13236
- const PickerComponent = ({ animationMs = 100, attachDropdownToBody = true, autoFocus, className, closeOnQuickSelect = true, combo = false, disabled, dropdownWidthModifier = 'min', label, nullable = false, onBlur: forwardBlur, onChange: forwardChange, onFocus: forwardFocus, openOnFocus = false, placeholder, placement = 'bottom-start', quickRanges, type, displayHours = true, displayMinutes = true, displaySeconds = true, value: externalValue, }) => {
13237
- const containerRef = useRef(null);
13238
- const stateRef = useRef({});
13239
- const dropdownRef = useRef(null);
13240
- const lastExternalValueRef = useRef(undefined);
13241
- const currentValueRef = useRef(null);
13242
- const [open, setOpen] = useState(false);
13243
- const [focus, setFocus] = useState(false);
13244
- const [Dropdown, triggerRef] = useDropdown();
13245
- const [internalValue, setInternalValue] = useState(null);
13246
- let value = internalValue ? internalValue : externalValue;
13247
- if (currentValueRef.current !== value && isSameDate(currentValueRef.current, value, type)) {
13248
- value = currentValueRef.current;
13625
+
13626
+ .o-step-inactive {
13627
+ &.o-step-success,
13628
+ &.o-step-touched {
13629
+ ${stepBorderColorFn(t.successBorderColor)}
13630
+ ${color(t.successFontColor)}
13631
+ }
13632
+ &.o-step-warning {
13633
+ ${stepBorderColorFn(t.warningBorderColor)}
13634
+ ${color(t.warningFontColor)}
13635
+ }
13636
+ &.o-step-error {
13637
+ ${stepBorderColorFn(t.errorBorderColor)}
13638
+ ${color(t.errorFontColor)}
13639
+ }
13249
13640
  }
13250
- const [fromString, toString] = value ? value.split(/ to\s*/) : [];
13251
- const validFromRef = useRef(undefined);
13252
- const validToRef = useRef(undefined);
13253
- if (!fromString || /\s*/.test(fromString)) {
13254
- validFromRef.current = undefined;
13641
+
13642
+ .o-step-enabled {
13643
+ ${cursor(t.cursor)}
13255
13644
  }
13256
- if (!toString || /\s*/.test(toString)) {
13257
- validToRef.current = undefined;
13645
+
13646
+ .o-step-disabled,
13647
+ .o-step-untouched {
13648
+ ${cursor('default')}
13649
+ ${stepBorderColorFn(t.disabledBorderColor)}
13650
+ ${color(t.disabledFontColor)}
13651
+ ${fontWeight(t.disabledFontWeight)}
13652
+ ${fontSize(t.disabledFontSize)}
13653
+ ${backgroundColor(t.disabledBgColor)}
13258
13654
  }
13259
- // this setting is used to detect if the user changes the from or the to
13260
- const nextSelectEdgeRef = useRef('to');
13261
- const from = parseDate(fromString?.trim());
13262
- const previousFrom = parseDate(validFromRef.current);
13263
- if (!type['date'] || !isValidDate(`${from['day']}-${from['month']}-${from['year']}`)) {
13264
- from.year = previousFrom.year;
13265
- from.month = previousFrom.month;
13266
- from.day = previousFrom.day;
13267
- from.date = previousFrom.date;
13655
+
13656
+ .o-step-disabled {
13657
+ ${cursor('not-allowed')}
13658
+ ${textDecoration('line-through')}
13268
13659
  }
13269
- if (type['date'] && isValidDate(`${from['day']}-${from['month']}-${from['year']}`)) {
13270
- validFromRef.current = `${from['year']}-${from['month']}-${from['day']}`;
13660
+
13661
+ .o-wizard-content-panel {
13662
+ ${display('flex')}
13663
+ ${flexDirection('column')}
13664
+ }
13665
+
13666
+ .o-wizard-content {
13667
+ ${flexGrow(1)}
13668
+ ${padding('lg')}
13669
+ ${paddingBottom(0)}
13670
+ ${paddingRight('3xl')}
13671
+ }
13672
+
13673
+ .o-wizard-control {
13674
+ ${display('flex')}
13675
+ ${justifyContent('flex-end')}
13676
+ ${padding('lg')}
13271
13677
  }
13272
- if (!type['time'] || !isValidTime(from['time'])) {
13273
- from.hour = previousFrom.hour;
13274
- from.minute = previousFrom.minute;
13275
- from.second = previousFrom.second;
13276
- from.time = previousFrom.time;
13678
+
13679
+ .o-wizard-control-button {
13680
+ ${marginLeft('sm')}
13277
13681
  }
13278
- if (type['time'] && isValidTime(`${from['time']}`)) {
13279
- if (validFromRef.current === undefined) {
13280
- validFromRef.current = '';
13281
- }
13282
- if (type['date']) {
13283
- validFromRef.current += ' ';
13284
- }
13285
- validFromRef.current += `${from['time']}`;
13682
+
13683
+ .o-wizard-title {
13684
+ ${fontSize('2xl')}
13685
+ ${fontWeight('light')}
13686
+ ${color('black')}
13687
+ ${lineHeight('4xl')}
13688
+ ${paddingBottom('md')}
13286
13689
  }
13287
- const to = parseDate(toString?.trim());
13288
- const previousTo = parseDate(validToRef.current);
13289
- if (!type['date'] || !isValidDate(`${to['day']}-${to['month']}-${to['year']}`)) {
13290
- to.year = previousTo.year;
13291
- to.month = previousTo.month;
13292
- to.day = previousTo.day;
13293
- to.date = previousTo.date;
13690
+
13691
+ .o-step-content-title {
13692
+ ${fontSize('2xl')}
13693
+ ${fontWeight('light')}
13694
+ ${color('black')}
13695
+ ${lineHeight('4xl')}
13696
+ ${paddingBottom('md')}
13294
13697
  }
13295
- if (type['date'] && isValidDate(`${to['day']}-${to['month']}-${to['year']}`)) {
13296
- validToRef.current = `${to['year']}-${to['month']}-${to['day']}`;
13698
+ `;
13699
+ };
13700
+ const wizardModalStyle = () => {
13701
+ return css ``;
13702
+ };
13703
+ const wizardSummaryStyle = () => {
13704
+ return css `
13705
+ .o-accordion-panel {
13706
+ ${paddingBottom('md')}
13297
13707
  }
13298
- if (!type['time'] || !isValidTime(to['time'])) {
13299
- to.hour = previousTo.hour;
13300
- to.minute = previousTo.minute;
13301
- to.second = previousTo.second;
13302
- to.time = previousTo.time;
13708
+ .o-accordion-panel-title {
13709
+ ${backgroundColor('lighter')}
13303
13710
  }
13304
- if (type['time'] && isValidTime(`${to['time']}`)) {
13305
- if (validToRef.current === undefined) {
13306
- validToRef.current = '';
13307
- }
13308
- if (type['date']) {
13309
- validToRef.current += ' ';
13310
- }
13311
- validToRef.current += `${to['time']}`;
13711
+ .o-accordion-content {
13712
+ ${paddingX('sm')}
13713
+ ${paddingBottom('sm')}
13312
13714
  }
13313
- const id = useId();
13314
- const onFocus = useCallback(() => {
13315
- if (!focus) {
13316
- setFocus(true);
13317
- if (openOnFocus && !open) {
13318
- setOpen(true);
13319
- }
13320
- if (forwardFocus) {
13321
- forwardFocus();
13322
- }
13323
- }
13324
- }, [focus, forwardFocus, openOnFocus, open]);
13325
- const onBlur = useCallback(() => {
13326
- if (!stateRef.current.keepFocus) {
13327
- if (open) {
13328
- setOpen(false);
13329
- }
13330
- if (focus) {
13331
- setFocus(false);
13332
- if (forwardBlur) {
13333
- forwardBlur();
13334
- }
13335
- }
13336
- }
13337
- }, [open, forwardBlur, setOpen, focus]);
13338
- const onChange = useCallback((nextValue, label) => {
13339
- currentValueRef.current = nextValue;
13340
- // check if the nextValue is a valid value
13341
- // if it's not a valid value, we keep it internally
13342
- if (forwardChange && isValidValue(nextValue, type)) {
13343
- setInternalValue(null);
13344
- forwardChange(nextValue, label);
13345
- }
13346
- else {
13347
- setInternalValue(nextValue);
13348
- }
13349
- }, [forwardChange, setInternalValue, type]);
13350
- const onChangeDate = (fromDate, toDate) => {
13351
- if (fromDate === undefined) {
13352
- fromDate = from['date'];
13353
- }
13354
- if (toDate === undefined) {
13355
- toDate = to['date'];
13356
- }
13357
- if (fromDate !== from['date']) {
13358
- nextSelectEdgeRef.current = 'to';
13359
- }
13360
- else {
13361
- nextSelectEdgeRef.current = 'from';
13362
- }
13363
- onChange(formatDate(type, fromDate, from['time'], toDate, to['time']));
13364
- };
13365
- const removeLabel = () => {
13366
- onChangeDate();
13367
- };
13368
- const onChangeTime = (nextTime, edge) => {
13369
- if (edge === 'from') {
13370
- onChange(formatDate(type, from['date'], nextTime, to['date'], to['time']));
13371
- }
13372
- else {
13373
- onChange(formatDate(type, from['date'], from['time'], to['date'], nextTime));
13374
- }
13375
- };
13376
- const onChangeQuickRange = (quickRangeLabel) => {
13377
- if (quickRanges) {
13378
- const quickRange = quickRanges[quickRangeLabel];
13379
- if (quickRange) {
13380
- onChange(`${quickRange.from} to ${quickRange.to}`, quickRangeLabel);
13381
- }
13382
- if (closeOnQuickSelect) {
13383
- setOpen(false);
13384
- }
13385
- }
13386
- };
13387
- const onOpen = useCallback(() => {
13388
- eventLocks.lock('escape', id);
13389
- }, [id]);
13390
- const onClosed = useCallback(() => {
13391
- eventLocks.unlock('escape', id);
13392
- if (lastExternalValueRef.current !== undefined) {
13393
- setInternalValue(null);
13394
- }
13395
- }, [id]);
13396
- useClickOutside([containerRef, dropdownRef], onBlur);
13397
- useFocusOutside([containerRef, dropdownRef], onBlur);
13398
- const context = useMemo(() => {
13399
- return {
13400
- open,
13401
- setOpen,
13402
- triggerRef,
13403
- nullable,
13404
- onChange,
13405
- };
13406
- }, [open, setOpen, triggerRef, nullable, onChange]);
13407
- useEffect(() => {
13408
- if (forwardChange &&
13409
- lastExternalValueRef.current !== undefined &&
13410
- externalValue !== undefined &&
13411
- externalValue !== lastExternalValueRef.current) {
13412
- // case when we block the onChange due to a wrong internal value
13413
- // and the value is changed from the exterior (not due to change done internally)
13414
- setInternalValue(null);
13415
- }
13416
- lastExternalValueRef.current = externalValue;
13417
- });
13418
- return (jsxRuntimeExports.jsx(DefaultDatePickerContext.Provider, { value: context, children: jsxRuntimeExports.jsxs("div", { className: addClassname('o-datepicker', className), ref: containerRef, onMouseDown: () => (stateRef.current.keepFocus = true), onMouseUp: () => (stateRef.current.keepFocus = false), children: [jsxRuntimeExports.jsx(Dropdown, { attachToBody: attachDropdownToBody, open: open, distance: 0, animationTimeout: animationMs, onDropStart: onOpen, onCollapseDone: onClosed, placement: placement, widthModifier: dropdownWidthModifier, className: className, zIndex: attachDropdownToBody ? 2000 : undefined, children: jsxRuntimeExports.jsxs("div", { ref: dropdownRef, className: `o-datepicker-dropdown-content${type['range'] ? ' o-datepicker-range' : ''}${validFromRef.current !== undefined ? ' o-datepicker-active' : ''}`, children: [type['range'] && quickRanges && Object.keys(quickRanges).length > 0 && (jsxRuntimeExports.jsx(QuickTimeRangeComponent, { quickRanges: quickRanges, onChange: onChangeQuickRange, currentQuickRangeLabel: label }, "quick_range")), type['date'] && (jsxRuntimeExports.jsx("div", { className: "o-calendar", children: jsxRuntimeExports.jsx(CalendarComponent, { from: from, to: to, type: type, onChange: onChangeDate, nextSelectEdge: nextSelectEdgeRef.current }) }, "calendar")), type['time'] && (jsxRuntimeExports.jsx("div", { className: "o-time", children: jsxRuntimeExports.jsx(TimeComponent, { from: from, to: to, type: type, onChange: onChangeTime, displayHours: displayHours, displayMinutes: displayMinutes, displaySeconds: displaySeconds }) }, "time"))] }) }), jsxRuntimeExports.jsx("span", { ref: triggerRef, children: jsxRuntimeExports.jsx(Input, { className: "o-datepicker-input", placeholder: placeholder, onChange: (e) => onChange(e.target.value), value: label ? label : !value ? '' : value, onFocus: onFocus, onBlur: onBlur, autoFocus: autoFocus, disabled: disabled, SuffixComponent: IconComponent, readOnly: !combo, onClick: () => {
13419
- if (!open) {
13420
- setOpen(true);
13421
- }
13422
- else if (combo) {
13423
- removeLabel();
13424
- }
13425
- else {
13426
- setOpen(false);
13427
- }
13428
- } }) }, "input")] }) }));
13715
+ `;
13429
13716
  };
13430
13717
 
13431
- const type$5 = {
13432
- date: true,
13433
- time: false,
13434
- range: false,
13435
- };
13436
- const DatePickerComponent = (props) => {
13437
- const { onChange: forwardChange, value: externalValue, adapter, ...datePickerProps } = props;
13438
- const onChange = forwardChange
13439
- ? (value) => {
13440
- if (value === null || !adapter) {
13441
- forwardChange(value);
13442
- }
13443
- else {
13444
- forwardChange(adapter.fromDate(value));
13445
- }
13718
+ const Wizard = styled(WizardComponent) `
13719
+ ${wizardStyle}
13720
+ `;
13721
+
13722
+ const useStep = (props) => {
13723
+ const service = useWizardService();
13724
+ const state = useWizardState();
13725
+ const step = state.members[state.membersIndex[props.uid]];
13726
+ useEffect(() => {
13727
+ if (step === undefined) {
13728
+ service.initMember(Object.assign({ uid: props.uid }, props));
13446
13729
  }
13447
- : undefined;
13448
- let value = externalValue
13449
- ? adapter
13450
- ? adapter.toDate(externalValue)
13451
- : externalValue
13452
- : null;
13453
- return jsxRuntimeExports.jsx(PickerComponent, { ...datePickerProps, value: value, onChange: onChange, type: type$5 });
13730
+ }, [props, service, step]);
13731
+ return step;
13454
13732
  };
13455
13733
 
13456
- const type$4 = {
13457
- date: true,
13458
- time: false,
13459
- range: true,
13460
- };
13461
- const DateRangePickerComponent = (props) => {
13462
- const { onChange: forwardChange, value: externalValue, adapter, ...datePickerProps } = props;
13463
- const onChange = forwardChange
13464
- ? (value, label) => {
13465
- const dateRange = toDateRange(value, label);
13466
- if (dateRange === null || !adapter) {
13467
- forwardChange(dateRange);
13468
- }
13469
- else {
13470
- forwardChange(adapter.fromDateRange(dateRange));
13471
- }
13472
- }
13473
- : undefined;
13474
- let value = null;
13475
- let valueLabel;
13476
- if (externalValue) {
13477
- if (adapter) {
13478
- const { from, to, label } = adapter.toDateRange(externalValue);
13479
- value = `${from || ''} to ${to || ''}`;
13480
- valueLabel = label;
13481
- }
13482
- else {
13483
- value = `${externalValue.from || ''} to ${externalValue.to || ''}`;
13484
- valueLabel = externalValue.label;
13734
+ const Step = ({ title, active = false, disabled = false, visible = true, closable = false, children, icon, uid, optional = false, showTitle = true, className, onTouch, help, }) => {
13735
+ const { animate, forwardOnly } = useWizardState();
13736
+ const stepRef = useRef(null);
13737
+ const step = useStep({
13738
+ title,
13739
+ active,
13740
+ disabled,
13741
+ visible,
13742
+ closable,
13743
+ icon,
13744
+ loading: false,
13745
+ optional,
13746
+ touched: !forwardOnly,
13747
+ touching: !forwardOnly,
13748
+ uid: uid === undefined ? title : uid,
13749
+ });
13750
+ const touched = step?.touched;
13751
+ const onEnter = () => {
13752
+ const node = stepRef.current;
13753
+ if (!node)
13754
+ return;
13755
+ node.style.opacity = '0';
13756
+ };
13757
+ const onEntering = () => {
13758
+ const node = stepRef.current;
13759
+ if (!node)
13760
+ return;
13761
+ setTimeout(() => {
13762
+ node.style.opacity = '1';
13763
+ node.style.transition = `opacity ${animate}ms ease-in-out`;
13764
+ }, 0);
13765
+ };
13766
+ useEffect(() => {
13767
+ if (touched && onTouch) {
13768
+ onTouch();
13485
13769
  }
13770
+ }, [touched, onTouch]);
13771
+ if (!step || !step.active) {
13772
+ return null;
13486
13773
  }
13487
- return jsxRuntimeExports.jsx(PickerComponent, { ...datePickerProps, value: value, onChange: onChange, type: type$4, label: valueLabel });
13774
+ return (jsxRuntimeExports.jsx(CSSTransition, { in: true, nodeRef: stepRef, timeout: animate, appear: true, onEnter: onEnter, onEntering: onEntering, children: jsxRuntimeExports.jsxs("div", { ref: stepRef, className: addClassname('o-step-content', className), children: [showTitle && jsxRuntimeExports.jsx("div", { className: "o-step-content-title", children: title }), help && (jsxRuntimeExports.jsx(Alert, { kind: "info", marginBottom: "lg", children: help })), children] }) }));
13488
13775
  };
13489
13776
 
13490
- const type$3 = {
13491
- date: true,
13492
- time: true,
13493
- range: false,
13494
- };
13495
- const DateTimePickerComponent = (props) => {
13496
- const { onChange: forwardChange, value: externalValue, adapter, ...datePickerProps } = props;
13497
- const onChange = forwardChange
13498
- ? (value) => {
13499
- if (value === null || !adapter) {
13500
- forwardChange(value);
13777
+ const FormStep = ({ name, disabled = false, visible = true, ...stepProps }) => {
13778
+ const decorator = useFormDecorator(name, {
13779
+ Displayer: (displayerProps) => {
13780
+ const total = Object.values(displayerProps.children ?? {}).length;
13781
+ return (jsxRuntimeExports.jsx(AccordionPanel, { title: stepProps.title, initialActive: displayerProps.index === 0, initialExpand: displayerProps.index === 0, children: Object.values(displayerProps.children ?? {}).map((field, index) => {
13782
+ const Displayer = field.Displayer ?? DefaultDisplayer;
13783
+ return (createElement(Displayer, { ...field, index: index, key: `field-${index}`, first: index === 0, last: index === total - 1, format: displayerProps.format }));
13784
+ }) }));
13785
+ },
13786
+ });
13787
+ const metadata = useFormMetadata(decorator.name);
13788
+ const service = useWizardService();
13789
+ const fieldContainer = useFieldContainer({
13790
+ container: name,
13791
+ onValidationChange: (touchedValidation, allValidation) => {
13792
+ service.onValidationChange(name, touchedValidation, allValidation);
13793
+ },
13794
+ });
13795
+ const { touchAllFields, hide, show, disable, enable } = fieldContainer;
13796
+ const initializedRef = useRef(false);
13797
+ useEffect(() => {
13798
+ const visible = metadata.visible ?? true;
13799
+ const disabled = metadata.disabled ?? false;
13800
+ if (!visible) {
13801
+ if (disabled) {
13802
+ service.disable(name);
13803
+ disable();
13501
13804
  }
13502
13805
  else {
13503
- forwardChange(adapter.fromDate(value));
13806
+ service.enable(name);
13807
+ if (initializedRef.current === true) {
13808
+ // we only use the enable method if this is a change and not a initialization
13809
+ enable();
13810
+ }
13504
13811
  }
13812
+ service.hide(name);
13813
+ hide();
13505
13814
  }
13506
- : undefined;
13507
- let value = externalValue
13508
- ? adapter
13509
- ? adapter.toDate(externalValue)
13510
- : externalValue
13511
- : null;
13512
- return jsxRuntimeExports.jsx(PickerComponent, { ...datePickerProps, value: value, onChange: onChange, type: type$3 });
13513
- };
13514
-
13515
- const type$2 = {
13516
- date: true,
13517
- time: true,
13518
- range: true,
13519
- };
13520
- const DateTimeRangePickerComponent = (props) => {
13521
- const { onChange: forwardChange, value: externalValue, adapter, ...datePickerProps } = props;
13522
- const onChange = forwardChange
13523
- ? (value, label) => {
13524
- const dateRange = toDateRange(value, label);
13525
- if (dateRange === null || !adapter) {
13526
- forwardChange(dateRange);
13815
+ else {
13816
+ service.show(name);
13817
+ if (initializedRef.current === true) {
13818
+ // we only use the show method if this is a change and not a initialization
13819
+ show();
13820
+ }
13821
+ if (disabled) {
13822
+ service.disable(name);
13823
+ disable();
13527
13824
  }
13528
13825
  else {
13529
- forwardChange(adapter.fromDateRange(dateRange));
13826
+ service.enable(name);
13827
+ if (initializedRef.current === true) {
13828
+ // we only use the enable method if this is a change and not a initialization
13829
+ enable();
13830
+ }
13530
13831
  }
13531
13832
  }
13532
- : undefined;
13533
- let value = null;
13534
- let valueLabel;
13535
- if (externalValue) {
13536
- if (adapter) {
13537
- const { from, to, label } = adapter.toDateRange(externalValue);
13538
- value = `${from || ''} to ${to || ''}`;
13539
- valueLabel = label;
13540
- }
13541
- else {
13542
- value = `${externalValue.from || ''} to ${externalValue.to || ''}`;
13543
- valueLabel = externalValue.label;
13544
- }
13545
- }
13546
- return jsxRuntimeExports.jsx(PickerComponent, { ...datePickerProps, value: value, onChange: onChange, type: type$2, label: valueLabel });
13833
+ initializedRef.current = true;
13834
+ }, [name, metadata.visible, metadata.disabled]);
13835
+ // useEffect(() => {
13836
+ // if (!visible) {
13837
+ // if (disabled) {
13838
+ // disable();
13839
+ // } else {
13840
+ // enable();
13841
+ // }
13842
+ // hide();
13843
+ // } else {
13844
+ // show();
13845
+ // if (disabled) {
13846
+ // disable();
13847
+ // } else {
13848
+ // enable();
13849
+ // }
13850
+ // }
13851
+ // }, [visible, disabled, hide, show, disable, enable]);
13852
+ return (jsxRuntimeExports.jsx(FormContext.Provider, { value: fieldContainer.context, children: jsxRuntimeExports.jsx(Step, { ...stepProps, uid: name, onTouch: touchAllFields }) }));
13547
13853
  };
13548
13854
 
13549
- const type$1 = {
13550
- date: false,
13551
- time: true,
13552
- range: false,
13553
- };
13554
- const TimePickerComponent = (props) => {
13555
- return jsxRuntimeExports.jsx(PickerComponent, { ...props, type: type$1 });
13855
+ const WizardModalComponent = ({ title, doneLabel = 'Submit', ...props }) => {
13856
+ return (jsxRuntimeExports.jsx(Modal, { ...props, children: jsxRuntimeExports.jsx(Wizard, { ...props, title: title, doneLabel: doneLabel, inModal: true }) }));
13556
13857
  };
13557
13858
 
13558
- const type = {
13559
- date: false,
13560
- time: true,
13561
- range: true,
13562
- };
13563
- const TimeRangePickerComponent = (props) => {
13564
- return jsxRuntimeExports.jsx(PickerComponent, { ...props, type: type });
13859
+ const WizardSummaryComponent = ({ className }) => {
13860
+ const form = useForm();
13861
+ const tree = Object.values(form.getDisplayerTree());
13862
+ return (jsxRuntimeExports.jsx(Accordion, { className: className, children: tree.map((field, index) => {
13863
+ const Displayer = field.Displayer || DefaultDisplayer;
13864
+ return (createElement(Displayer, { ...field, index: index, key: `field-${index}`, first: index === 0, last: index === tree.length - 1, format: "form_summary" }));
13865
+ }) }));
13565
13866
  };
13566
13867
 
13567
- const DatePicker = styled(DatePickerComponent) `
13568
- ${datePickerStyle}
13569
- `;
13570
- const DateRangePicker = styled(DateRangePickerComponent) `
13571
- ${datePickerStyle}
13572
- `;
13573
- const DateTimePicker = styled(DateTimePickerComponent) `
13574
- ${datePickerStyle}
13575
- `;
13576
- const DateTimeRangePicker = styled(DateTimeRangePickerComponent) `
13577
- ${datePickerStyle}
13578
- `;
13579
- const TimePicker = styled(TimePickerComponent) `
13580
- ${datePickerStyle}
13581
- `;
13582
- const TimeRangePicker = styled(TimeRangePickerComponent) `
13583
- ${datePickerStyle}
13868
+ const WizardModal = styled(WizardModalComponent) `
13869
+ ${wizardModalStyle}
13584
13870
  `;
13585
13871
 
13586
- const useQuickRanges = (ranges) => {
13587
- const result = useLazyRef(() => {
13588
- if (!Array.isArray(ranges)) {
13589
- ranges = [ranges];
13590
- }
13591
- const quickRanges = ranges.reduce((accumulator, range) => {
13592
- if (typeof range === 'string') {
13593
- if (range === 'all') {
13594
- accumulator = Object.assign(accumulator, defaultQuickRanges());
13595
- }
13596
- else {
13597
- const dateRange = qr(range);
13598
- if (dateRange !== null) {
13599
- accumulator[range] = dateRange;
13600
- }
13601
- }
13602
- }
13603
- else {
13604
- accumulator[range.label] = range;
13605
- }
13606
- return accumulator;
13607
- }, {});
13608
- const target = Object.keys(quickRanges).reduce((accumulator, label) => {
13609
- accumulator[label] = {
13610
- from: null,
13611
- to: null,
13612
- label,
13613
- };
13614
- return accumulator;
13615
- }, {});
13616
- const handler = {
13617
- get: function (_, prop) {
13618
- if (typeof prop === 'string') {
13619
- const quickRange = quickRanges[prop];
13620
- if (quickRange) {
13621
- return {
13622
- from: dateToString(quickRange.from),
13623
- to: dateToString(quickRange.to),
13624
- label: quickRange.label,
13625
- };
13626
- }
13627
- }
13628
- return undefined;
13629
- },
13630
- };
13631
- return new Proxy(target, handler);
13632
- });
13633
- return result.current;
13634
- };
13635
-
13636
- const useDateRangeAdapter = () => {
13637
- const ref = useRef({
13638
- fromDateRange: (range) => {
13639
- return {
13640
- from: range.from === null ? null : new Date(range.from),
13641
- to: range.to === null ? null : new Date(range.to),
13642
- label: range.label,
13643
- };
13644
- },
13645
- toDateRange: (value) => {
13646
- return {
13647
- from: !value.from ? null : dateToString(value.from),
13648
- to: !value.to ? null : dateToString(value.to),
13649
- label: value.label,
13650
- };
13651
- },
13652
- });
13653
- return ref.current;
13654
- };
13655
-
13656
- const useTimestampRangeAdapter = (format = 'milliseconds') => {
13657
- const toTimestamp = (date) => {
13658
- if (!date)
13659
- return null;
13660
- const d = new Date(date);
13661
- if (isNaN(d))
13662
- return null;
13663
- const timestamp = d.getTime();
13664
- return format === 'milliseconds' ? timestamp : Math.floor(timestamp / 1000);
13665
- };
13666
- const fromTimestamp = (timestamp) => {
13667
- if (timestamp === null || timestamp === undefined)
13668
- return null;
13669
- if (format === 'seconds') {
13670
- timestamp = timestamp * 1000;
13671
- }
13672
- const d = new Date(timestamp);
13673
- if (isNaN(d))
13674
- return null;
13675
- return dateToString(d);
13676
- };
13677
- const ref = useRef({
13678
- fromDateRange: (range) => {
13679
- return {
13680
- from: toTimestamp(range.from),
13681
- to: toTimestamp(range.to),
13682
- label: range.label,
13683
- };
13684
- },
13685
- toDateRange: (value) => {
13686
- return {
13687
- from: fromTimestamp(value.from),
13688
- to: fromTimestamp(value.to),
13689
- label: value.label,
13690
- };
13691
- },
13692
- });
13693
- return ref.current;
13694
- };
13872
+ const WizardSummary = styled(WizardSummaryComponent) `
13873
+ ${wizardSummaryStyle}
13874
+ `;
13695
13875
 
13696
13876
  const animation = cssProperty('animation');
13697
13877
  const animationDelay = cssProperty('animation-delay');
@@ -14573,5 +14753,5 @@ const sameWidthPopperModifier = refWidth('width');
14573
14753
  const minWidthPopperModifier = refWidth('minWidth');
14574
14754
  const maxWidthPopperModifier = refWidth('maxWidth');
14575
14755
 
14576
- export { Accordion, AccordionComponent, AccordionContainer, AccordionPanel, Alert, AlertComponent, ArraySelectComponent, ArrayTreeComponent, ArrayTreeSelectComponent, AutoComplete, BaseTheme, BreakpointKeys, Button, CalendarComponent, Card, CardComponent, CardTitle, Checkbox, CheckboxCellComponent, CheckboxComponent, CloseAllIcon, Col, ColorKeys, ContextMenu, ContextMenuComponent, ControlledSelectComponent, ControlledTimerComponent, ControlledWizardComponent, ControllerTreeComponent, CrossIcon, Dashboard, DashboardBody, DashboardContainer, DashboardFooter, DashboardHeader, DashboardKeys, DashboardLeft, DashboardOverlay, DashboardRight, DashboardService, DashboardServiceContext, DashboardStateContext, DashboardToggler, DatePicker, DatePickerComponent, DateRangePicker, DateRangePickerComponent, DateTimePicker, DateTimePickerComponent, DateTimeRangePicker, DateTimeRangePickerComponent, DefaultCellComponent, DefaultFormCellDisplayer as DefaultCellDisplayer, DefaultDatePickerContext, DefaultSelectBroker, Dropdown, DropdownButton, DropdownComponent, DropdownList, ErrorIcon, ExpandedCellComponent, FieldDescription, FieldDescriptionComponent, FieldDisplayer, FieldHelp, FieldHelpComponent, FieldLayout, FieldLayoutComponent, FileIcon, FolderIcon, FontFamiliesKeys, FontLineHeightKeys, FontSizeKeys, FontSpacingKeys, FontWeightKeys, FormAutoComplete, FormBlock, FormCard, FormCardDisplayer, FormCheckbox, FormInput, FormSelect, FormStep, FormTable, FormTableItemDisplayer, FormTableValueDisplayer, FormTextarea, HelpIcon, Input, InputCellComponent, InputComponent, Label, List, ListItemComponent, ListItemContent, ListStatus, LoadingIcon, LoadingItem, MenuIcon, Modal, ModalComponent, NotificationComponent, Notifications, NotificationsComponent, Password, PasswordComponent, PickerComponent, Properties, PropertiesComponent, Property, RadiusKeys, RefreshIcon, Row, SearchIcon, Select, SelectCellComponent, SelectComponent, SelectIconComponent, SelectInputComponent, SelectNotFoundComponent, SelectOptionComponent, SelectService, SelectTokensComponent, ShadowKeys, SizeKeys, Resizer as Slider, SliderComponent, SpacingKeys, Step, StepTitle, SubmitButton, SuccessIcon, Tab, TabTitle, Table, TableBodyRowComponent, TableFilterOperatorComponent, TableInputFilterComponent, TableNumberFilterComponent, TableTextFilterComponent, Tabs, Tag, TagComponent, TailwindTheme, Textarea, TextareaCellComponent, TextareaComponent, TimePicker, TimePickerComponent, TimeRangePicker, TimeRangePickerComponent, Timer, TimerComponent, TogglerIcon, Tooltip, Tree, TreeBodyComponent, TreeComponent, TreeConfigContext, TreeItemComponent, TreeItemContent, TreeItemToggler, TreeListComponent, TreeSelect, TreeSelectComponent, TreeService, TreeServiceContext, TreeStateContext, TshirtKeys, UncontrolledTimerComponent, UncontrolledWizardComponent, VirtualTreeBodyComponent, VirtualTreeListComponent, Wizard, WizardComponent, WizardContainer, WizardModal, WizardModalComponent, WizardService, WizardSummary, WizardSummaryComponent, accordionStyle, addClassname, addStyle, alertStyle, alignContent, alignItems, alignSelf, animation, animationDelay, animationDirection, animationDuration, animationFillMode, animationIterationCount, animationName, animationPlayState, animationTimingFunction, appearance, applyOpacity, aspectRatio, backgroundAttachment, backgroundClip, backgroundColor, backgroundImage, backgroundOpacity, backgroundOrigin, backgroundPosition, backgroundRepeat, backgroundSize, baseTheme, booleanFormatter, border, borderBottom, borderBottomColor, borderBottomLeftRadius, borderBottomOpacity, borderBottomRightRadius, borderBottomStyle, borderBottomWidth, borderCollapse, borderColor, borderImage, borderImageOutset, borderImageRepeat, borderImageSlice, borderImageSource, borderImageWidth, borderLeft, borderLeftColor, borderLeftOpacity, borderLeftStyle, borderLeftWidth, borderOpacity, borderRadius, borderRight, borderRightColor, borderRightOpacity, borderRightStyle, borderRightWidth, borderSpacing, borderStyle, borderTop, borderTopColor, borderTopLeftRadius, borderTopOpacity, borderTopRightRadius, borderTopStyle, borderTopWidth, borderWidth, bottom, boxShadow, boxSizing, breakAfter, breakBefore, breakInside, buttonStyle, captionSide, cardStyle, caretColor, checkboxColumn, checkboxStyle, clear, colStyle, color, colorFormatter, columnCount, columnFill, columnGap, columnRule, columnRuleColor, columnRuleStyle, columnRuleWidth, columnSpan, columnWidth, columns, container, contextMenuStyle, cssProperty, cursor, darken, dashboardOverlayStyle, datePickerStyle, dateToString, defaultCellSerializer, defaultQuickRanges, defaultTreeQueryEngine, deriveColor, display, dropdownButtonStyle, dropdownStyle, emptyCells, enumColumn, enumFormatter, escapeCsvValue, fieldDescriptionStyle, fieldDisplayerStyle, fieldHelpStyle, fieldStyle, fill, filterListStyle, findQuickRangeLabel, findSelectItem, findSelectItemIndex, flex, flexBasis, flexDirection, flexGrow, flexShrink, flexWrap, float, font, fontFamily, fontFeatureSettings, fontKerning, fontLanguageOverride, fontOpticalSizing, fontSize, fontSizeAdjust, fontStretch, fontStyle, fontSynthesis, fontVariant, fontVariantAlternates, fontVariantCaps, fontVariantEastAsian, fontVariantLigatures, fontVariantNumeric, fontVariantPosition, fontVariationSettings, fontWeight, gap, grid, gridAutoColumns, gridAutoFlow, gridAutoRows, gridColumn, gridColumnEnd, gridColumnGap, gridColumnStart, gridGap, gridRow, gridRowEnd, gridRowGap, gridRowStart, gridTemplate, gridTemplateAreas, gridTemplateColumns, gridTemplateRows, height, hexToRgb, hyphens, iconHeight, iconWidth, imageRendering, inputColumn, justifyContent, justifySelf, left, letterSpacing, lighten, lineHeight, lineHeightStep, linkColumn, listStyle, listStyleImage, listStylePosition, listStyleType, margin, marginBottom, marginLeft, marginRight, marginTop, marginX, marginY, maxHeight, maxWidth, maxWidthPopperModifier, minHeight, minWidth, minWidthPopperModifier, modalStyle, notifcationsStyle, numberColumn, objectFit, objectPosition, opacity, order, orphans, outline, outlineColor, outlineOffset, outlineStyle, outlineWidth, overflow, overflowBlock, overflowInline, overflowWrap, overflowX, overflowY, overscrollBehavior, overscrollBehaviorBlock, overscrollBehaviorInline, overscrollBehaviorX, overscrollBehaviorY, padding, paddingBottom, paddingLeft, paddingRight, paddingTop, paddingX, paddingY, passwordStyle, perspective, perspectiveOrigin, placeContent, placeItems, placeSelf, pointerEvents, position, preflight, propertiesStyle, pxFormatter, qr, resize, rgbToHex, right, rotate, rowGap, rowStyle, sameWidthPopperModifier, scale, selectColumn, shouldCheckSelect, sliderStyle, stroke, strokeWidth, tableLayout, tableStyle, tagStyle, tailwindPalette, tailwindTheme, textAlign, textColumn, textDecoration, textDecorationColor, textDecorationLine, textDecorationStyle, textDecorationThickness, textEmphasis, textEmphasisColor, textEmphasisPosition, textEmphasisStyle, textIdent, textJustify, textOpacity, textOverflow, textShadow, textTransform, textUnderlineOffset, textUnderlinePosition, textareaColumn, themeFormatter, timerStyle, titlelize, toCss, toDateRange, top, touchAction, transform, transformOrigin, transition, transitionDelay, transitionDuration, transitionProperty, transitionTimingFunction, useCheckboxColumn, useClickOutside, useColumns, useDashboard, useDashboardController, useDashboardHorizontalPanel, useDashboardService, useDashboardState, useDashboardVerticalPanel, useDashoardBodyPanel, useDatePickerContext, useDateRangeAdapter, useDropdown, useEnumColumn, useFieldLayout, useFocusOutside, useFormTableContext, useInputColumn$1 as useInputColumn, useLinkColumn, useListController, useInputColumn as useNumberColumn, useQuickRanges, useSelectColumn, useSelectController, useSelectService, useStep, useTab, useTableController, useTableService, useTabsController, useTabsService, useTabsState, useTextColumn, useTextareaColumn, useTimestampRangeAdapter, useTreeConfig, useTreeController, useTreeInitialState, useTreeItemContext, useTreeSelectController, useTreeService, useTreeState, useWizardController, useWizardService, useWizardState, userSelect, verticalAlign, visibility, whiteSpace, widows, width, wizardModalStyle, wizardStyle, wizardSummaryStyle, wordBreak, wordSpacing, zIndex, zoom };
14756
+ export { Accordion, AccordionComponent, AccordionContainer, AccordionPanel, Alert, AlertComponent, ArraySelectComponent, ArrayTreeComponent, ArrayTreeSelectComponent, AutoComplete, BaseTheme, BreakpointKeys, Button, CalendarComponent, Card, CardComponent, CardTitle, Checkbox, CheckboxCellComponent, CheckboxComponent, CloseAllIcon, Col, ColorKeys, ContextMenu, ContextMenuComponent, ControlledSelectComponent, ControlledTimerComponent, ControlledWizardComponent, ControllerTreeComponent, CrossIcon, Dashboard, DashboardBody, DashboardContainer, DashboardFooter, DashboardHeader, DashboardKeys, DashboardLeft, DashboardOverlay, DashboardRight, DashboardService, DashboardServiceContext, DashboardStateContext, DashboardToggler, DatePicker, DatePickerComponent, DateRangePicker, DateRangePickerComponent, DateTimePicker, DateTimePickerComponent, DateTimeRangePicker, DateTimeRangePickerComponent, DefaultCellComponent, DefaultFormCellDisplayer as DefaultCellDisplayer, DefaultDatePickerContext, DefaultSelectBroker, Dropdown, DropdownButton, DropdownComponent, DropdownList, ErrorIcon, ExpandedCellComponent, FieldDescription, FieldDescriptionComponent, FieldDisplayer, FieldHelp, FieldHelpComponent, FieldLayout, FieldLayoutComponent, FileIcon, FolderIcon, FontFamiliesKeys, FontLineHeightKeys, FontSizeKeys, FontSpacingKeys, FontWeightKeys, FormAutoComplete, FormBlock, FormCard, FormCardDisplayer, FormCheckbox, FormDatePicker, FormDateRangePicker, FormDateTimePicker, FormDateTimeRangePicker, FormInput, FormSelect, FormStep, FormTable, FormTableItemDisplayer, FormTableValueDisplayer, FormTextarea, HelpIcon, Input, InputCellComponent, InputComponent, Label, List, ListItemComponent, ListItemContent, ListStatus, LoadingIcon, LoadingItem, MenuIcon, Modal, ModalComponent, NotificationComponent, Notifications, NotificationsComponent, Password, PasswordComponent, PickerComponent, Properties, PropertiesComponent, Property, RadiusKeys, RefreshIcon, Row, SearchIcon, Select, SelectCellComponent, SelectComponent, SelectIconComponent, SelectInputComponent, SelectNotFoundComponent, SelectOptionComponent, SelectService, SelectTokensComponent, ShadowKeys, SizeKeys, Resizer as Slider, SliderComponent, SpacingKeys, Step, StepTitle, SubmitButton, SuccessIcon, Tab, TabTitle, Table, TableBodyRowComponent, TableFilterOperatorComponent, TableInputFilterComponent, TableNumberFilterComponent, TableTextFilterComponent, Tabs, Tag, TagComponent, TailwindTheme, Textarea, TextareaCellComponent, TextareaComponent, TimePicker, TimePickerComponent, TimeRangePicker, TimeRangePickerComponent, Timer, TimerComponent, TogglerIcon, Tooltip, Tree, TreeBodyComponent, TreeComponent, TreeConfigContext, TreeItemComponent, TreeItemContent, TreeItemToggler, TreeListComponent, TreeSelect, TreeSelectComponent, TreeService, TreeServiceContext, TreeStateContext, TshirtKeys, UncontrolledTimerComponent, UncontrolledWizardComponent, VirtualTreeBodyComponent, VirtualTreeListComponent, Wizard, WizardComponent, WizardContainer, WizardModal, WizardModalComponent, WizardService, WizardSummary, WizardSummaryComponent, accordionStyle, addClassname, addStyle, alertStyle, alignContent, alignItems, alignSelf, animation, animationDelay, animationDirection, animationDuration, animationFillMode, animationIterationCount, animationName, animationPlayState, animationTimingFunction, appearance, applyOpacity, aspectRatio, backgroundAttachment, backgroundClip, backgroundColor, backgroundImage, backgroundOpacity, backgroundOrigin, backgroundPosition, backgroundRepeat, backgroundSize, baseTheme, booleanFormatter, border, borderBottom, borderBottomColor, borderBottomLeftRadius, borderBottomOpacity, borderBottomRightRadius, borderBottomStyle, borderBottomWidth, borderCollapse, borderColor, borderImage, borderImageOutset, borderImageRepeat, borderImageSlice, borderImageSource, borderImageWidth, borderLeft, borderLeftColor, borderLeftOpacity, borderLeftStyle, borderLeftWidth, borderOpacity, borderRadius, borderRight, borderRightColor, borderRightOpacity, borderRightStyle, borderRightWidth, borderSpacing, borderStyle, borderTop, borderTopColor, borderTopLeftRadius, borderTopOpacity, borderTopRightRadius, borderTopStyle, borderTopWidth, borderWidth, bottom, boxShadow, boxSizing, breakAfter, breakBefore, breakInside, buttonStyle, captionSide, cardStyle, caretColor, checkboxColumn, checkboxStyle, clear, colStyle, color, colorFormatter, columnCount, columnFill, columnGap, columnRule, columnRuleColor, columnRuleStyle, columnRuleWidth, columnSpan, columnWidth, columns, container, contextMenuStyle, cssProperty, cursor, darken, dashboardOverlayStyle, datePickerStyle, dateRangeAdapter, dateToString, defaultCellSerializer, defaultQuickRanges, defaultTreeQueryEngine, deriveColor, display, dropdownButtonStyle, dropdownStyle, emptyCells, enumColumn, enumFormatter, escapeCsvValue, fieldDescriptionStyle, fieldDisplayerStyle, fieldHelpStyle, fieldStyle, fill, filterListStyle, findQuickRangeLabel, findSelectItem, findSelectItemIndex, flex, flexBasis, flexDirection, flexGrow, flexShrink, flexWrap, float, font, fontFamily, fontFeatureSettings, fontKerning, fontLanguageOverride, fontOpticalSizing, fontSize, fontSizeAdjust, fontStretch, fontStyle, fontSynthesis, fontVariant, fontVariantAlternates, fontVariantCaps, fontVariantEastAsian, fontVariantLigatures, fontVariantNumeric, fontVariantPosition, fontVariationSettings, fontWeight, gap, grid, gridAutoColumns, gridAutoFlow, gridAutoRows, gridColumn, gridColumnEnd, gridColumnGap, gridColumnStart, gridGap, gridRow, gridRowEnd, gridRowGap, gridRowStart, gridTemplate, gridTemplateAreas, gridTemplateColumns, gridTemplateRows, height, hexToRgb, hyphens, iconHeight, iconWidth, imageRendering, inputColumn, justifyContent, justifySelf, left, letterSpacing, lighten, lineHeight, lineHeightStep, linkColumn, listStyle, listStyleImage, listStylePosition, listStyleType, margin, marginBottom, marginLeft, marginRight, marginTop, marginX, marginY, maxHeight, maxWidth, maxWidthPopperModifier, minHeight, minWidth, minWidthPopperModifier, modalStyle, notifcationsStyle, numberColumn, objectFit, objectPosition, opacity, order, orphans, outline, outlineColor, outlineOffset, outlineStyle, outlineWidth, overflow, overflowBlock, overflowInline, overflowWrap, overflowX, overflowY, overscrollBehavior, overscrollBehaviorBlock, overscrollBehaviorInline, overscrollBehaviorX, overscrollBehaviorY, padding, paddingBottom, paddingLeft, paddingRight, paddingTop, paddingX, paddingY, passwordStyle, perspective, perspectiveOrigin, placeContent, placeItems, placeSelf, pointerEvents, position, preflight, propertiesStyle, pxFormatter, qr, resize, rgbToHex, right, rotate, rowGap, rowStyle, sameWidthPopperModifier, scale, selectColumn, shouldCheckSelect, sliderStyle, stroke, strokeWidth, tableLayout, tableStyle, tagStyle, tailwindPalette, tailwindTheme, textAlign, textColumn, textDecoration, textDecorationColor, textDecorationLine, textDecorationStyle, textDecorationThickness, textEmphasis, textEmphasisColor, textEmphasisPosition, textEmphasisStyle, textIdent, textJustify, textOpacity, textOverflow, textShadow, textTransform, textUnderlineOffset, textUnderlinePosition, textareaColumn, themeFormatter, timerStyle, timestampMilliSecondRangeAdapter, timestampRangeAdapter, timestampSecondRangeAdapter, titlelize, toCss, toDateRange, top, touchAction, transform, transformOrigin, transition, transitionDelay, transitionDuration, transitionProperty, transitionTimingFunction, useCheckboxColumn, useClickOutside, useColumns, useDashboard, useDashboardController, useDashboardHorizontalPanel, useDashboardService, useDashboardState, useDashboardVerticalPanel, useDashoardBodyPanel, useDatePickerContext, useDateRangeAdapter, useDropdown, useEnumColumn, useFieldLayout, useFocusOutside, useFormTableContext, useInputColumn$1 as useInputColumn, useLinkColumn, useListController, useInputColumn as useNumberColumn, useQuickRanges, useSelectColumn, useSelectController, useSelectService, useStep, useTab, useTableController, useTableService, useTabsController, useTabsService, useTabsState, useTextColumn, useTextareaColumn, useTimestampRangeAdapter, useTreeConfig, useTreeController, useTreeInitialState, useTreeItemContext, useTreeSelectController, useTreeService, useTreeState, useWizardController, useWizardService, useWizardState, userSelect, verticalAlign, visibility, whiteSpace, widows, width, wizardModalStyle, wizardStyle, wizardSummaryStyle, wordBreak, wordSpacing, zIndex, zoom };
14577
14757
  //# sourceMappingURL=index.module.js.map