onekijs-ui 0.15.2 → 0.15.3

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 (92) hide show
  1. package/dist/components/checkbox/typings.d.ts +1 -1
  2. package/dist/components/field/typings.d.ts +5 -5
  3. package/dist/components/label/typings.d.ts +3 -3
  4. package/dist/components/list/components/ListLoadingComponent.d.ts +4 -0
  5. package/dist/components/list/typings.d.ts +6 -4
  6. package/dist/components/modal/typings.d.ts +2 -2
  7. package/dist/components/select/SelectBroker.d.ts +6 -0
  8. package/dist/components/select/SelectService.d.ts +16 -2
  9. package/dist/components/select/components/SelectOptionComponent.d.ts +1 -0
  10. package/dist/components/select/hooks/useSelectController.d.ts +1 -1
  11. package/dist/components/select/hooks/useSelectService.d.ts +4 -0
  12. package/dist/components/select/typings.d.ts +32 -6
  13. package/dist/components/select/util.d.ts +6 -0
  14. package/dist/components/tab/typings.d.ts +1 -0
  15. package/dist/components/table/columns/useSelectColumn.d.ts +2 -1
  16. package/dist/components/table/columns/useTextareaColumn.d.ts +3 -0
  17. package/dist/components/table/components/cells/SelectCellComponent.d.ts +3 -4
  18. package/dist/components/table/components/cells/TextareaCellComponent.d.ts +4 -0
  19. package/dist/components/table/typings.d.ts +14 -8
  20. package/dist/components/textarea/FormTextarea.d.ts +4 -0
  21. package/dist/components/textarea/components/TextareaComponent.d.ts +4 -0
  22. package/dist/components/textarea/index.d.ts +3 -0
  23. package/dist/components/textarea/style.d.ts +4 -0
  24. package/dist/components/textarea/typings.d.ts +12 -0
  25. package/dist/components/tooltip/typings.d.ts +2 -2
  26. package/dist/components/tree/TreeService.d.ts +6 -6
  27. package/dist/components/tree/util.d.ts +3 -0
  28. package/dist/index.d.ts +18 -2
  29. package/dist/index.js +959 -281
  30. package/dist/index.js.map +1 -1
  31. package/dist/index.module.js +944 -283
  32. package/dist/index.module.js.map +1 -1
  33. package/dist/styles/flex.d.ts +1 -1
  34. package/dist/styles/size.d.ts +6 -6
  35. package/dist/styles/typings.d.ts +34 -0
  36. package/dist/styles/typography.d.ts +1 -1
  37. package/package.json +3 -3
  38. package/src/components/checkbox/components/CheckboxComponent.tsx +1 -1
  39. package/src/components/checkbox/style.ts +22 -0
  40. package/src/components/checkbox/typings.ts +4 -1
  41. package/src/components/field/components/FieldLayoutComponent.tsx +2 -2
  42. package/src/components/field/style.ts +20 -8
  43. package/src/components/field/typings.ts +5 -5
  44. package/src/components/field/util.ts +5 -0
  45. package/src/components/input/FormInput.tsx +1 -1
  46. package/src/components/label/style.ts +0 -1
  47. package/src/components/label/typings.ts +3 -3
  48. package/src/components/list/components/ListBodyComponent.tsx +37 -13
  49. package/src/components/list/components/ListLoadingComponent.tsx +22 -0
  50. package/src/components/list/components/LoadingItem.tsx +3 -1
  51. package/src/components/list/hooks/useListView.tsx +12 -10
  52. package/src/components/list/typings.ts +6 -3
  53. package/src/components/modal/components/ModalComponent.tsx +10 -7
  54. package/src/components/modal/style.ts +2 -4
  55. package/src/components/modal/typings.ts +2 -2
  56. package/src/components/select/FormSelect.tsx +1 -1
  57. package/src/components/select/SelectBroker.ts +21 -0
  58. package/src/components/select/SelectService.ts +187 -3
  59. package/src/components/select/components/ControllerSelectComponent.tsx +178 -66
  60. package/src/components/select/components/SelectInputComponent.tsx +18 -7
  61. package/src/components/select/components/SelectOptionComponent.tsx +36 -20
  62. package/src/components/select/hooks/useSelectController.ts +10 -11
  63. package/src/components/select/hooks/useSelectService.ts +7 -0
  64. package/src/components/select/style.ts +129 -84
  65. package/src/components/select/typings.ts +41 -5
  66. package/src/components/select/util.ts +53 -0
  67. package/src/components/tab/TabsService.ts +1 -0
  68. package/src/components/tab/components/Tab.tsx +3 -1
  69. package/src/components/tab/typings.ts +1 -0
  70. package/src/components/table/columns/useCheckboxColumn.ts +3 -2
  71. package/src/components/table/columns/useSelectColumn.ts +19 -9
  72. package/src/components/table/columns/useTextareaColumn.ts +24 -0
  73. package/src/components/table/components/FormTableComponent.tsx +30 -12
  74. package/src/components/table/components/TableHeaderTitleComponent.tsx +2 -0
  75. package/src/components/table/components/cells/SelectCellComponent.tsx +12 -10
  76. package/src/components/table/components/cells/TextareaCellComponent.tsx +27 -0
  77. package/src/components/table/style.ts +34 -17
  78. package/src/components/table/typings.ts +36 -16
  79. package/src/components/textarea/FormTextarea.tsx +26 -0
  80. package/src/components/textarea/components/TextareaComponent.tsx +42 -0
  81. package/src/components/textarea/index.tsx +9 -0
  82. package/src/components/textarea/style.ts +85 -0
  83. package/src/components/textarea/typings.ts +15 -0
  84. package/src/components/tooltip/style.ts +1 -0
  85. package/src/components/tooltip/typings.ts +2 -1
  86. package/src/components/tree/TreeService.ts +5 -19
  87. package/src/components/tree/util.ts +29 -0
  88. package/src/components/wizard/components/Step.tsx +4 -2
  89. package/src/index.ts +27 -0
  90. package/src/styles/typings.ts +36 -0
  91. package/src/theme/base.tsx +33 -1
  92. package/src/components/select/hooks/useSelectConfig.ts +0 -7
package/dist/index.js CHANGED
@@ -1283,6 +1283,7 @@ const tooltipStyle = ({ kind = 'secondary', theme }) => {
1283
1283
  ${cursor('pointer')}
1284
1284
  ${display('inline-flex')}
1285
1285
  .o-tooltip-container {
1286
+ ${cursor('default')}
1286
1287
  ${backgroundColor(bgColor)}
1287
1288
  ${borderRadius(t.borderRadius)}
1288
1289
  ${borderWidth(t.borderWidth)}
@@ -1546,7 +1547,7 @@ const CheckboxComponent = ({ label, className = '', onChange, value = false, bor
1546
1547
  const onChecked = (e) => {
1547
1548
  onChange && onChange(e.target.checked);
1548
1549
  };
1549
- return (React__default["default"].createElement("div", { className: addClassname(`o-checkbox${status ? ' o-checkbox-status-' + status.toLowerCase() : ''}`, className) },
1550
+ return (React__default["default"].createElement("div", { className: addClassname(`o-checkbox ${checkboxProps.disabled ? 'o-checkbox-disabled' : 'o-checkbox-enabled'}${status ? ' o-checkbox-status-' + status.toLowerCase() : ''}`, className) },
1550
1551
  React__default["default"].createElement("label", { htmlFor: id, onClick: (e) => e.stopPropagation() },
1551
1552
  React__default["default"].createElement("div", { className: "o-checkbox-container" },
1552
1553
  React__default["default"].createElement("svg", { className: "o-checkbox-svg", viewBox: "-281 373 48 48" },
@@ -1588,6 +1589,27 @@ const checkboxStyle = ({ height: cssHeight = '20px', width: cssWidth = '20px', t
1588
1589
  ${width('full')};
1589
1590
  }
1590
1591
 
1592
+ &.o-checkbox-disabled {
1593
+ .o-checkbox-container {
1594
+ ${borderColor('dark')}
1595
+ }
1596
+ .o-checkbox-svg-stroke {
1597
+ ${borderColor('dark')}
1598
+ }
1599
+ .o-checkbox-svg {
1600
+ ${backgroundColor('lighter')}
1601
+ }
1602
+ .o-checkbox-input {
1603
+ ${cursor('not-allowed')}
1604
+ }
1605
+ label {
1606
+ ${cursor('not-allowed')}
1607
+ }
1608
+ .o-checkbox-svg-stroke {
1609
+ ${stroke('dark')}
1610
+ }
1611
+ }
1612
+
1591
1613
  .o-checkbox-svg-stroke {
1592
1614
  ${stroke(checkboxColor)}
1593
1615
  ${fill('none')}
@@ -1859,7 +1881,9 @@ FieldHelpComponent.displayName = 'FieldHelpComponent';
1859
1881
 
1860
1882
  const fieldStyle = () => {
1861
1883
  return styled.css `
1862
- ${display('flex')}
1884
+ &.o-form-field {
1885
+ ${display('flex')}
1886
+ }
1863
1887
  &.o-form-field-vertical {
1864
1888
  ${flexDirection('column')}
1865
1889
  }
@@ -1875,15 +1899,25 @@ const fieldHelpStyle = ({ visible = true, theme, layout }) => {
1875
1899
  const t = theme.fieldLayout;
1876
1900
  return styled.css `
1877
1901
  ${fontSize('2xl')}
1902
+ ${marginLeft(layout === 'horizontal' ? 0 : t.helperMarginLeft)}
1903
+ ${marginRight(layout === 'horizontal' ? t.helperMarginRight : 0)}
1904
+ ${height('100%')}
1905
+ ${display('flex')}
1906
+ ${alignItems('center')}
1878
1907
  ${color(t.helperColor)}
1879
- ${marginLeft(layout === 'horizontal' ? 0 : t.helperMarginLeft)}
1880
- ${marginRight(layout === 'horizontal' ? t.helperMarginRight : 0)}
1881
- ${height('100%')}
1882
- ${display('flex')}
1883
- ${alignItems('center')}
1884
- .o-tooltip {
1908
+ .o-tooltip {
1885
1909
  ${cursor(visible ? 'pointer' : 'default')}
1886
1910
  }
1911
+ &.o-helper-icon-small {
1912
+ .o-tooltip {
1913
+ ${width(5)}
1914
+ }
1915
+ }
1916
+ &.o-helper-icon-large {
1917
+ .o-tooltip {
1918
+ ${width(8)}
1919
+ }
1920
+ }
1887
1921
  `;
1888
1922
  };
1889
1923
  const fieldDescriptionStyle = ({ theme, layout }) => {
@@ -1980,7 +2014,6 @@ const labelStyle = ({ theme }) => {
1980
2014
 
1981
2015
  .o-helper-icon {
1982
2016
  ${fontSize('xl')}
1983
- ${color(t.helperIconColor)}
1984
2017
  ${marginLeft(t.helperMarginLeft)}
1985
2018
  }
1986
2019
 
@@ -2045,7 +2078,7 @@ const FieldLayoutComponent = React__default["default"].memo(({ className, descri
2045
2078
  React__default["default"].createElement(DescriptionComponent, { layout: fieldLayout, content: message ? message : description || '', className: status !== undefined ? `o-field-description-${status}` : undefined }))));
2046
2079
  }
2047
2080
  else if (fieldLayout === 'table') {
2048
- return (React__default["default"].createElement(React__default["default"].Fragment, null,
2081
+ return (React__default["default"].createElement("div", { className: className },
2049
2082
  children,
2050
2083
  React__default["default"].createElement(DescriptionComponent, { layout: fieldLayout, content: message ? message : description || '', className: status !== undefined ? `o-field-description-${status}` : undefined })));
2051
2084
  }
@@ -2075,6 +2108,11 @@ const extractFieldLayoutProps = (props) => {
2075
2108
  'layout',
2076
2109
  'required',
2077
2110
  'size',
2111
+ 'xsLabelWidth',
2112
+ 'smLabelWidth',
2113
+ 'mdLabelWidth',
2114
+ 'lgLabelWidth',
2115
+ 'xlLabelWidth',
2078
2116
  ];
2079
2117
  const fieldOptionsKeys = ['defaultValue', 'touchedOn', 'disabled', 'visible'];
2080
2118
  Object.keys(nonValidatorProps).forEach((k) => {
@@ -2882,6 +2920,7 @@ function check(value, predicate, error) {
2882
2920
  throw new Error(error);
2883
2921
  }
2884
2922
  }
2923
+ var ALL = 'ALL';
2885
2924
  var CALL = 'CALL';
2886
2925
  var FORK = 'FORK';
2887
2926
  var CANCEL = 'CANCEL';
@@ -2893,6 +2932,11 @@ var makeEffect = function makeEffect(type, payload) {
2893
2932
 
2894
2933
  return _ref = {}, _ref[IO] = true, _ref.combinator = false, _ref.type = type, _ref.payload = payload, _ref;
2895
2934
  };
2935
+ function all(effects) {
2936
+ var eff = makeEffect(ALL, effects);
2937
+ eff.combinator = true;
2938
+ return eff;
2939
+ }
2896
2940
 
2897
2941
  var validateFnDescriptor = function validateFnDescriptor(effectName, fnDescriptor) {
2898
2942
  check(fnDescriptor, notUndef, effectName + ": argument fn is undefined or null");
@@ -3666,7 +3710,7 @@ const FormInput = React__default["default"].memo((props) => {
3666
3710
  }, props));
3667
3711
  const Component = props.FieldComponent || Input;
3668
3712
  return (React__default["default"].createElement(FieldLayout, { ...fieldLayoutProps, required: props.required },
3669
- React__default["default"].createElement(Component, { ...fieldComponentProps })));
3713
+ React__default["default"].createElement(Component, { ...fieldComponentProps, value: !fieldComponentProps.value ? '' : fieldComponentProps.value })));
3670
3714
  });
3671
3715
  FormInput.displayName = 'FormInput';
3672
3716
 
@@ -4297,20 +4341,22 @@ const useListView = ({ controller, height, itemHeight = defaultItemHeight, overs
4297
4341
  keyExtractor: forceKeyExtractor,
4298
4342
  });
4299
4343
  React.useEffect(() => {
4300
- if (isVirtual) {
4301
- if (state.status === onekijsFramework.LoadingStatus.NotInitialized) {
4302
- controller.load(preload);
4303
- }
4304
- else if (canFetchMore(controller)) {
4305
- const lastVirtualItem = virtualItems[virtualItems.length - 1];
4306
- const lastVirtualItemIndex = lastVirtualItem ? lastVirtualItem.index : 0;
4307
- if (lastVirtualItemIndex >= (state.items?.length || 0) - preload / 2) {
4308
- controller.load(increment, (state.items || []).length);
4344
+ if (controller.status !== onekijsFramework.LoadingStatus.NotReady) {
4345
+ if (isVirtual) {
4346
+ if (controller.status === onekijsFramework.LoadingStatus.NotInitialized) {
4347
+ controller.load(preload);
4348
+ }
4349
+ else if (canFetchMore(controller)) {
4350
+ const lastVirtualItem = virtualItems[virtualItems.length - 1];
4351
+ const lastVirtualItemIndex = lastVirtualItem ? lastVirtualItem.index : 0;
4352
+ if (lastVirtualItemIndex >= (state.items?.length || 0) - preload / 2) {
4353
+ controller.load(increment, (state.items || []).length);
4354
+ }
4309
4355
  }
4310
4356
  }
4311
- }
4312
- else if (controller.status === onekijsFramework.LoadingStatus.NotInitialized) {
4313
- controller.load();
4357
+ else if (controller.status === onekijsFramework.LoadingStatus.NotInitialized) {
4358
+ controller.load();
4359
+ }
4314
4360
  }
4315
4361
  }, [controller, state, preload, virtualItems, increment, isVirtual]);
4316
4362
  return {
@@ -4334,13 +4380,27 @@ const ListItemComponent = React__default["default"].memo((props) => {
4334
4380
  });
4335
4381
  ListItemComponent.displayName = 'ListItemComponent';
4336
4382
 
4383
+ const ListLoadingComponent = ({ className }) => {
4384
+ return (React__default["default"].createElement("div", { className: addClassname('o-list-loading', className) },
4385
+ React__default["default"].createElement(LoadingIcon, { width: "50px", height: "50px" })));
4386
+ };
4387
+ var ListLoadingComponent$1 = styled__default["default"](ListLoadingComponent) `
4388
+ height: 100%;
4389
+ min-height: 200px;
4390
+ width: 100%;
4391
+ display: flex;
4392
+ align-items: center;
4393
+ justify-content: center;
4394
+ `;
4395
+
4337
4396
  const LoadingItem = ({ className }) => {
4338
4397
  return React__default["default"].createElement("div", { className: addClassname('o-loading-item', className) });
4339
4398
  };
4340
4399
  var LoadingItem$1 = styled__default["default"](LoadingItem) `
4341
4400
  ${height('full')}
4342
4401
  ${width('full')}
4343
- ${minHeight('20px')}
4402
+ ${minHeight('30px')}
4403
+ ${marginY('1px')}
4344
4404
  animation: skeleton-loading 1s linear infinite alternate;
4345
4405
 
4346
4406
  @keyframes skeleton-loading {
@@ -4412,7 +4472,7 @@ const VirtualListComponent = ({ items, ItemComponent = ListItemComponent, ItemLo
4412
4472
  })));
4413
4473
  };
4414
4474
 
4415
- const findItemIndex$1 = (items, uid) => {
4475
+ const findItemIndex = (items, uid) => {
4416
4476
  if (items === undefined) {
4417
4477
  return -1;
4418
4478
  }
@@ -4426,7 +4486,7 @@ const findItemIndex$1 = (items, uid) => {
4426
4486
  return i.uid === uid;
4427
4487
  });
4428
4488
  };
4429
- const ListBodyComponent = ({ bodyRef, className, height, items, ItemComponent = ListItemComponent, ItemLoadingComponent = LoadingItem$1, ItemContentComponent = ListItemContent, NotFoundComponent, keyboardNavigable, ListComponent = StandardListComponent, multiSelect, onItemActivate, onItemDeactivate, onItemSelect, onItemUnselect, onItemHighlight, onItemUnhighlight, parentRef, scrollToIndex, service, state, style, totalSize, virtualItems, VirtualListComponent: VirtualListComponent$1 = VirtualListComponent, }) => {
4489
+ const ListBodyComponent = ({ bodyRef, className, height, items, ItemComponent = ListItemComponent, ItemLoadingComponent = LoadingItem$1, ItemContentComponent = ListItemContent, NotFoundComponent, keyboardNavigable, ListComponent = StandardListComponent, multiSelect, onItemActivate, onItemDeactivate, onItemSelect, onItemUnselect, onItemHighlight, onItemUnhighlight, parentRef, scrollToIndex, service, state, style, totalSize, virtualItems, VirtualListComponent: VirtualListComponent$1 = VirtualListComponent, LoadingComponent = ListLoadingComponent$1, }) => {
4430
4490
  const scrollAlignRef = React.useRef('center');
4431
4491
  const lastActiveItemUid = React.useRef();
4432
4492
  const virtualRef = React.useRef(null);
@@ -4480,7 +4540,7 @@ const ListBodyComponent = ({ bodyRef, className, height, items, ItemComponent =
4480
4540
  if (['ArrowDown', 'ArrowUp', 'Enter', 'Escape'].includes(e.key)) {
4481
4541
  const activeUid = onekijsFramework.last(state.active);
4482
4542
  const activeItem = activeUid !== undefined ? service.getItem(activeUid) : undefined;
4483
- const activeIndex = findItemIndex$1(state.items, activeUid);
4543
+ const activeIndex = findItemIndex(state.items, activeUid);
4484
4544
  switch (e.key) {
4485
4545
  case 'ArrowDown':
4486
4546
  case 'ArrowUp':
@@ -4531,7 +4591,7 @@ const ListBodyComponent = ({ bodyRef, className, height, items, ItemComponent =
4531
4591
  const activeUid = state.active === undefined ? undefined : state.active[0];
4532
4592
  if (activeUid !== lastActiveItemUid.current) {
4533
4593
  lastActiveItemUid.current = activeUid;
4534
- const activeIndex = findItemIndex$1(state.items, activeUid);
4594
+ const activeIndex = findItemIndex(state.items, activeUid);
4535
4595
  if (activeIndex >= 0) {
4536
4596
  scrollToIndex(activeIndex, { align: scrollAlignRef.current });
4537
4597
  }
@@ -4541,9 +4601,18 @@ const ListBodyComponent = ({ bodyRef, className, height, items, ItemComponent =
4541
4601
  onekijsFramework.useEventListener('keydown', onKeyDown, false);
4542
4602
  const overflow = parentRef && parentRef !== bodyRef ? 'visible' : 'auto';
4543
4603
  if (virtualItems !== undefined) {
4544
- if (virtualItems.length === 0 && NotFoundComponent) {
4545
- return (React__default["default"].createElement("div", { className: className },
4546
- React__default["default"].createElement(NotFoundComponent, null)));
4604
+ if (virtualItems.length === 0) {
4605
+ if (onekijsFramework.isCollectionInitializing(service) || service.status === onekijsFramework.LoadingStatus.Fetching) {
4606
+ return null;
4607
+ }
4608
+ if (service.status === onekijsFramework.LoadingStatus.Loading) {
4609
+ return (React__default["default"].createElement("div", { className: className },
4610
+ React__default["default"].createElement(LoadingComponent, null)));
4611
+ }
4612
+ else if (NotFoundComponent) {
4613
+ return (React__default["default"].createElement("div", { className: className },
4614
+ React__default["default"].createElement(NotFoundComponent, null)));
4615
+ }
4547
4616
  }
4548
4617
  return (React__default["default"].createElement("div", { ref: bodyRef, className: className, style: addStyle({
4549
4618
  maxHeight: `${typeof height === 'string' ? height : `${height}px`}`,
@@ -4557,9 +4626,18 @@ const ListBodyComponent = ({ bodyRef, className, height, items, ItemComponent =
4557
4626
  React__default["default"].createElement(VirtualListComponent$1, { items: items, ItemComponent: ItemComponent, ItemLoadingComponent: ItemLoadingComponent, ItemContentComponent: ItemContentComponent, virtualItems: virtualItems, onItemMouseEnter: onItemMouseEnter, onItemMouseLeave: onItemMouseLeave, onItemClick: onItemClick }))));
4558
4627
  }
4559
4628
  else {
4560
- if (items.length === 0 && NotFoundComponent) {
4561
- return (React__default["default"].createElement("div", { className: className },
4562
- React__default["default"].createElement(NotFoundComponent, null)));
4629
+ if (items.length === 0) {
4630
+ if (onekijsFramework.isCollectionInitializing(service) || service.status === onekijsFramework.LoadingStatus.Fetching) {
4631
+ return null;
4632
+ }
4633
+ if (service.status === onekijsFramework.LoadingStatus.Loading) {
4634
+ return (React__default["default"].createElement("div", { className: className },
4635
+ React__default["default"].createElement(LoadingComponent, null)));
4636
+ }
4637
+ else if (NotFoundComponent) {
4638
+ return (React__default["default"].createElement("div", { className: className },
4639
+ React__default["default"].createElement(NotFoundComponent, null)));
4640
+ }
4563
4641
  }
4564
4642
  if (height !== undefined) {
4565
4643
  style = addStyle({
@@ -4625,10 +4703,12 @@ exports.ListStatus = void 0;
4625
4703
  })(exports.ListStatus || (exports.ListStatus = {}));
4626
4704
 
4627
4705
  const ModalComponent = ({ attachToBody = false, className, children, open, animationDuration = 150, closeIcon = true, onClose, onClosed, title, buttons = [], closeOnClickOutside, closeOnEscape = true, }) => {
4706
+ const id = React.useId();
4628
4707
  const theme = React.useContext(styled.ThemeContext);
4629
4708
  const maskOpacity = theme.modal.maskOpacity;
4630
4709
  const ref = React.useRef(null);
4631
4710
  const onEntering = (node) => {
4711
+ onekijsFramework.eventLocks.lock('escape', id);
4632
4712
  node.style.opacity = '0';
4633
4713
  node.style.transition = `opacity ${animationDuration}ms ease-out`;
4634
4714
  if (ref.current) {
@@ -4665,6 +4745,7 @@ const ModalComponent = ({ attachToBody = false, className, children, open, anima
4665
4745
  }
4666
4746
  };
4667
4747
  const onExited = (node) => {
4748
+ onekijsFramework.eventLocks.unlock('escape', id);
4668
4749
  node.style.opacity = '';
4669
4750
  node.style.transition = '';
4670
4751
  if (ref.current) {
@@ -4677,12 +4758,12 @@ const ModalComponent = ({ attachToBody = false, className, children, open, anima
4677
4758
  };
4678
4759
  useClickOutside(ref, () => {
4679
4760
  if (closeOnClickOutside) {
4680
- onClose();
4761
+ onClose && onClose();
4681
4762
  }
4682
4763
  });
4683
- onekijsFramework.useEventListener('keyup', (e) => {
4684
- if (closeOnEscape && e.key === 'Escape') {
4685
- onClose();
4764
+ onekijsFramework.useEventListener('keydown', (e) => {
4765
+ if (closeOnEscape && e.key === 'Escape' && onekijsFramework.eventLocks.isLockedBy('escape', id)) {
4766
+ onClose && onClose();
4686
4767
  }
4687
4768
  });
4688
4769
  const element = (React__default["default"].createElement(reactTransitionGroup.CSSTransition, { in: open, classNames: "o-modal", timeout: animationDuration, unmountOnExit: true, onEntering: onEntering, onEntered: onEntered, onExiting: onExiting, onExited: onExited },
@@ -4700,13 +4781,6 @@ const ModalComponent = ({ attachToBody = false, className, children, open, anima
4700
4781
  }
4701
4782
  };
4702
4783
 
4703
- const perspective = cssProperty('perspective');
4704
- const perspectiveOrigin = cssProperty('perspective-origin');
4705
- const rotate = cssProperty('rotate');
4706
- const scale = cssProperty('scale');
4707
- const transform = cssProperty('transform');
4708
- const transformOrigin = cssProperty('transform-origin');
4709
-
4710
4784
  const modalStyle = ({ width: w, height: h, size = 'medium', theme }) => {
4711
4785
  const t = theme.modal;
4712
4786
  w = w ?? size;
@@ -4753,7 +4827,6 @@ const modalStyle = ({ width: w, height: h, size = 'medium', theme }) => {
4753
4827
  ${color('transparent')}
4754
4828
  text-shadow: 0 0 0 ${themeFontColor};
4755
4829
  ${cursor('pointer')}
4756
- ${transform('rotate(45deg)')}
4757
4830
  }
4758
4831
  .o-modal-header {
4759
4832
  ${fontSize('4xl')}
@@ -4806,7 +4879,7 @@ const modalStyle = ({ width: w, height: h, size = 'medium', theme }) => {
4806
4879
  ${overflow('auto')}
4807
4880
  ${height('100%')}
4808
4881
  scrollbar-width: thin;
4809
- scrollbar-color: ${(props) => props.theme.palette.colors[props.theme.colors.light]}
4882
+ scrollbar-color: ${(props) => props.theme.palette.colors[props.theme.colors.primary]}
4810
4883
  ${(props) => props.theme.colors[props.theme.colors.lighter]};
4811
4884
  &::-webkit-scrollbar {
4812
4885
  width: 12px;
@@ -4815,7 +4888,7 @@ const modalStyle = ({ width: w, height: h, size = 'medium', theme }) => {
4815
4888
  background: ${(props) => props.theme.palette.colors[props.theme.colors.lighter]};
4816
4889
  }
4817
4890
  &::-webkit-scrollbar-thumb {
4818
- background-color: ${(props) => props.theme.palette.colors[props.theme.colors.light]};
4891
+ background-color: ${(props) => props.theme.palette.colors[props.theme.colors.primary]};
4819
4892
  border: 3px solid ${(props) => props.theme.palette.colors[props.theme.colors.lighter]};
4820
4893
  }
4821
4894
  }
@@ -4883,8 +4956,233 @@ const Properties = styled__default["default"](PropertiesComponent) `
4883
4956
  ${propertiesStyle}
4884
4957
  `;
4885
4958
 
4959
+ const findSelectItem = (controller, pattern) => {
4960
+ let result = undefined;
4961
+ if (controller.items === undefined) {
4962
+ return undefined;
4963
+ }
4964
+ for (const item of controller.items) {
4965
+ if (item === undefined || item.text === undefined) {
4966
+ continue;
4967
+ }
4968
+ if (item.text.toLowerCase().startsWith(pattern.toLowerCase())) {
4969
+ return item;
4970
+ }
4971
+ if (result === undefined && item.text.toLowerCase().includes(pattern.toLowerCase())) {
4972
+ result = item;
4973
+ }
4974
+ }
4975
+ return result;
4976
+ };
4977
+ const findSelectItemIndex = (controller, item) => {
4978
+ if (controller.items === undefined) {
4979
+ return -1;
4980
+ }
4981
+ return controller.items.findIndex((i) => {
4982
+ if (i === undefined) {
4983
+ return false;
4984
+ }
4985
+ if (i.id === undefined) {
4986
+ return false;
4987
+ }
4988
+ return i.id === item?.id;
4989
+ });
4990
+ };
4991
+ const shouldCheckSelect = (currentQuery, lastCheckQuery) => {
4992
+ if (lastCheckQuery === undefined)
4993
+ return true;
4994
+ if (!onekijsFramework.isSameFilter(currentQuery.filter, lastCheckQuery.filter))
4995
+ return true;
4996
+ if (!onekijsFramework.shallowEqual(currentQuery.params || null, lastCheckQuery.params || null))
4997
+ return true;
4998
+ return false;
4999
+ };
5000
+ const getGroupText = (item) => {
5001
+ if (item === undefined)
5002
+ return undefined;
5003
+ if (item.group === undefined)
5004
+ return undefined;
5005
+ if (typeof item.group === 'string')
5006
+ return item.group;
5007
+ return item.group.text;
5008
+ };
5009
+
4886
5010
  let SelectService = class SelectService extends onekijsFramework.CollectionService {
5011
+ config;
5012
+ lastCheckQuery;
5013
+ get defaultValue() {
5014
+ return this.state.defaultValue ?? this.config?.defaultValue;
5015
+ }
5016
+ *check() {
5017
+ if (this.state.local && this.status !== onekijsFramework.LoadingStatus.Loaded) {
5018
+ return; // this validation will be done when the data will be loaded (can be delayed due to a fetchOnce)
5019
+ }
5020
+ let invalidItems = [];
5021
+ const defaultItems = this.defaultValue ? onekijsFramework.toArray(this.defaultValue).map((v) => this._adapt(v)) : [];
5022
+ const query = onekijsFramework.clone(this.getQuery());
5023
+ this._clearSearch(query);
5024
+ this._clearLimit(query);
5025
+ this._clearOffset(query);
5026
+ this.lastCheckQuery = query;
5027
+ const filterDefaultItems = yield all(defaultItems.map((i) => call([this, this._filterItem], i, query, true)));
5028
+ const validDefaultValue = filterDefaultItems.filter((i) => i !== undefined && i.data).map((i) => i.data);
5029
+ if (Array.isArray(this.defaultValue)) {
5030
+ this._setValidDefaultValue(validDefaultValue);
5031
+ }
5032
+ else if (validDefaultValue.length > 0) {
5033
+ this._setValidDefaultValue(validDefaultValue[0]);
5034
+ }
5035
+ else {
5036
+ this._setValidDefaultValue(this.config === undefined || this.config.nullable || !this.state.items
5037
+ ? null
5038
+ : this.config.defaultValue === undefined || this.state.defaultValue === null
5039
+ ? this.state.items[0]?.data || null
5040
+ : null);
5041
+ }
5042
+ if (this.state.selected !== undefined) {
5043
+ const item = this.getItem(this.state.selected[0]);
5044
+ const filterItems = yield all([this._filterItem(item, query, false)]);
5045
+ invalidItems = filterItems.filter((i) => i !== undefined);
5046
+ }
5047
+ yield this._setInvalidItems(invalidItems);
5048
+ }
5049
+ setData(data) {
5050
+ this.lastCheckQuery = undefined;
5051
+ super.setData(data);
5052
+ }
5053
+ *setDefaultValue(value) {
5054
+ yield this._setDefaultValue(value);
5055
+ yield this.check(); // validate the default value
5056
+ if (value !== undefined &&
5057
+ this.state.validDefaultValue &&
5058
+ (!this.config?.value || (Array.isArray(this.config.value) && this.config.value.length === 0))) {
5059
+ yield this.setValue(value);
5060
+ }
5061
+ }
5062
+ setValue(value) {
5063
+ const onChange = this.config?.onChange;
5064
+ if (onChange) {
5065
+ onChange(value);
5066
+ }
5067
+ }
5068
+ setUrl(url) {
5069
+ this.lastCheckQuery = undefined;
5070
+ super.setUrl(url);
5071
+ }
5072
+ _buildItem(data, adaptee, context) {
5073
+ context = context || {};
5074
+ const getGroup = (data) => {
5075
+ if (onekijsFramework.isNull(data)) {
5076
+ return undefined;
5077
+ }
5078
+ if (!onekijsFramework.isNull(data.group)) {
5079
+ return data.group;
5080
+ }
5081
+ else {
5082
+ return undefined;
5083
+ }
5084
+ };
5085
+ const selectAdaptee = adaptee;
5086
+ onekijsFramework.ensureFieldValue(selectAdaptee, 'group', getGroup(data));
5087
+ return super._buildItem(data, selectAdaptee, context);
5088
+ }
5089
+ *_filterItem(item, query, valid) {
5090
+ if (item === undefined)
5091
+ return item;
5092
+ let isValid = false;
5093
+ if (!this.state.items || !this.state.items.find((i) => i?.uid === item.uid)) {
5094
+ query = Object.assign({}, query, { search: item.text });
5095
+ if (this.state.local) {
5096
+ const queryEngine = this.state.queryEngine || this._execute.bind(this);
5097
+ const result = queryEngine(this.db || [], query, this.state.comparator || onekijsFramework.defaultComparator, this.state.comparators || {});
5098
+ isValid = !!result.find((i) => i.id === item.id);
5099
+ }
5100
+ else {
5101
+ const oQuery = this.serializeQuery(query);
5102
+ const sQuery = Object.keys(oQuery)
5103
+ .map((k) => `${k}=${oQuery[k]}`)
5104
+ .join('&');
5105
+ let result;
5106
+ if (this.cache[sQuery]) {
5107
+ result = this.cache[sQuery];
5108
+ }
5109
+ else {
5110
+ const options = Object.assign({}, this.state.fetchOptions, { delayLoading: 0 });
5111
+ result = yield super._executeFetch(query, options, false);
5112
+ }
5113
+ const data = Array.isArray(result) ? result : result[this.state.dataKey];
5114
+ for (const itemData of data) {
5115
+ const adaptee = this.adapt(itemData);
5116
+ if (adaptee.id === item.id) {
5117
+ isValid = true;
5118
+ break;
5119
+ }
5120
+ }
5121
+ }
5122
+ }
5123
+ else {
5124
+ isValid = true;
5125
+ }
5126
+ return valid === isValid ? item : undefined;
5127
+ }
5128
+ _setDefaultValue(value) {
5129
+ this.state.defaultValue = value;
5130
+ }
5131
+ _setValidDefaultValue(value) {
5132
+ this.state.validDefaultValue = value;
5133
+ }
5134
+ _setInvalidItems(invalidItems) {
5135
+ this.state.invalidItems = invalidItems;
5136
+ }
5137
+ _setItems(items) {
5138
+ super._setItems(items);
5139
+ if (shouldCheckSelect(this.getQuery(), this.lastCheckQuery)) {
5140
+ this.callSaga('check');
5141
+ }
5142
+ }
4887
5143
  };
5144
+ __decorate([
5145
+ onekijsFramework.saga(onekijsFramework.SagaEffect.Serial),
5146
+ __metadata("design:type", Function),
5147
+ __metadata("design:paramtypes", []),
5148
+ __metadata("design:returntype", void 0)
5149
+ ], SelectService.prototype, "check", null);
5150
+ __decorate([
5151
+ onekijsFramework.reducer,
5152
+ __metadata("design:type", Function),
5153
+ __metadata("design:paramtypes", [Array]),
5154
+ __metadata("design:returntype", void 0)
5155
+ ], SelectService.prototype, "setData", null);
5156
+ __decorate([
5157
+ onekijsFramework.saga(onekijsFramework.SagaEffect.Latest),
5158
+ __metadata("design:type", Function),
5159
+ __metadata("design:paramtypes", [Object]),
5160
+ __metadata("design:returntype", void 0)
5161
+ ], SelectService.prototype, "setDefaultValue", null);
5162
+ __decorate([
5163
+ onekijsFramework.reducer,
5164
+ __metadata("design:type", Function),
5165
+ __metadata("design:paramtypes", [String]),
5166
+ __metadata("design:returntype", void 0)
5167
+ ], SelectService.prototype, "setUrl", null);
5168
+ __decorate([
5169
+ onekijsFramework.reducer,
5170
+ __metadata("design:type", Function),
5171
+ __metadata("design:paramtypes", [Object]),
5172
+ __metadata("design:returntype", void 0)
5173
+ ], SelectService.prototype, "_setDefaultValue", null);
5174
+ __decorate([
5175
+ onekijsFramework.reducer,
5176
+ __metadata("design:type", Function),
5177
+ __metadata("design:paramtypes", [Object]),
5178
+ __metadata("design:returntype", void 0)
5179
+ ], SelectService.prototype, "_setValidDefaultValue", null);
5180
+ __decorate([
5181
+ onekijsFramework.reducer,
5182
+ __metadata("design:type", Function),
5183
+ __metadata("design:paramtypes", [Array]),
5184
+ __metadata("design:returntype", void 0)
5185
+ ], SelectService.prototype, "_setInvalidItems", null);
4888
5186
  SelectService = __decorate([
4889
5187
  onekijsFramework.service
4890
5188
  ], SelectService);
@@ -4896,9 +5194,9 @@ const useSelectController = (dataSource, options = {}) => {
4896
5194
  return collection;
4897
5195
  };
4898
5196
 
4899
- const SelectConfigContext = React__default["default"].createContext(null);
4900
- const useSelectConfig = () => {
4901
- return React.useContext(SelectConfigContext);
5197
+ const SelectServiceContext = React__default["default"].createContext(null);
5198
+ const useSelectService = () => {
5199
+ return React.useContext(SelectServiceContext);
4902
5200
  };
4903
5201
 
4904
5202
  const SelectIconComponent = ({ onClick, open, loading }) => {
@@ -4948,7 +5246,7 @@ const SelectTokensComponent = React__default["default"].memo(({ tokens, onRemove
4948
5246
  });
4949
5247
  SelectTokensComponent.displayName = 'SelectTokensComponent';
4950
5248
 
4951
- const SelectInputComponent = React__default["default"].forwardRef(({ setOpen, open, placeholder, loading, fetching, IconComponent = SelectIconComponent, onFocus: forwardFocus, onBlur: forwardBlur, onChange, onRemove, value, focus, multiple, tokens, autoFocus, style, nullable, clickable, minChars, disabled, }, ref) => {
5249
+ const SelectInputComponent = React__default["default"].forwardRef(({ setOpen, open, placeholder, loading, fetching, IconComponent = SelectIconComponent, onFocus: forwardFocus, onBlur: forwardBlur, onChange, onRemove, value, focus, multiple, tokens, autoFocus, style, nullable, clickable, searchable, minChars, disabled, }, ref) => {
4952
5250
  const inputRef = React.useRef(null);
4953
5251
  const autoSizeRef = React.useRef(null);
4954
5252
  // partialValue is the part of the selected item entered by the user
@@ -5058,14 +5356,20 @@ const SelectInputComponent = React__default["default"].forwardRef(({ setOpen, op
5058
5356
  return result.join(' ');
5059
5357
  }, [focus]);
5060
5358
  const onClick = React.useCallback(() => {
5061
- if (!open && clickable) {
5359
+ if (!open && clickable && !disabled) {
5062
5360
  setOpen(true);
5361
+ inputRef.current && inputRef.current.focus();
5362
+ }
5363
+ if (open && !searchable) {
5364
+ setOpen(false);
5063
5365
  }
5064
- }, [open, setOpen, clickable]);
5366
+ }, [open, setOpen, clickable, searchable, disabled]);
5065
5367
  const onFocus = React.useCallback((e) => {
5066
- inputRef.current && inputRef.current.select();
5368
+ if (searchable) {
5369
+ inputRef.current && inputRef.current.select();
5370
+ }
5067
5371
  forwardFocus && forwardFocus(e);
5068
- }, [forwardFocus]);
5372
+ }, [forwardFocus, searchable]);
5069
5373
  const onBlur = React.useCallback((e) => {
5070
5374
  partialValueRef.current = undefined;
5071
5375
  showSelectedRef.current = true;
@@ -5073,13 +5377,13 @@ const SelectInputComponent = React__default["default"].forwardRef(({ setOpen, op
5073
5377
  }, [forwardBlur]);
5074
5378
  const onIconClick = React.useCallback((e) => {
5075
5379
  if (!disabled) {
5076
- if (!open) {
5380
+ if (!open && searchable) {
5077
5381
  inputRef.current && inputRef.current.select();
5078
5382
  }
5079
5383
  forwardFocus && forwardFocus(e);
5080
5384
  setOpen(!open);
5081
5385
  }
5082
- }, [open, forwardFocus, setOpen, disabled]);
5386
+ }, [open, forwardFocus, setOpen, disabled, searchable]);
5083
5387
  const onNullify = React.useCallback(() => {
5084
5388
  onChange(null);
5085
5389
  }, [onChange]);
@@ -5093,7 +5397,8 @@ const SelectInputComponent = React__default["default"].forwardRef(({ setOpen, op
5093
5397
  multiple && React__default["default"].createElement(SelectTokensComponent, { tokens: tokens, onRemove: onRemove }),
5094
5398
  React__default["default"].createElement("div", { className: "o-select-input-wrapper" },
5095
5399
  React__default["default"].createElement("span", { ref: autoSizeRef, className: "o-select-input-auto-sizer" }),
5096
- React__default["default"].createElement("input", { ref: inputRef, placeholder: placeholder, className: "o-select-input", onFocus: onFocus, onBlur: onBlur, onChange: handleChange, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, value: proxyValue, onClick: onClick, autoCapitalize: "none", autoComplete: "off", autoCorrect: "off", spellCheck: "false", disabled: disabled }))),
5400
+ React__default["default"].createElement("input", { ref: inputRef, placeholder: placeholder, className: "o-select-input", onFocus: onFocus, onBlur: onBlur, onChange: handleChange, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, value: proxyValue, onClick: onClick, autoCapitalize: "none", autoComplete: "off", autoCorrect: "off", spellCheck: "false", disabled: disabled }),
5401
+ !searchable && (React__default["default"].createElement("span", { className: "o-select-input o-select-input-text", onClick: onClick }, proxyValue || '')))),
5097
5402
  !multiple && nullable && value && !disabled && (React__default["default"].createElement("div", { className: "o-select-remover", onClick: onNullify }, "\u2716")),
5098
5403
  React__default["default"].createElement(IconComponent, { onClick: onIconClick, open: open, loading: loading, fetching: fetching })));
5099
5404
  });
@@ -5110,11 +5415,17 @@ const MultiSelectOptionComponent = React__default["default"].memo((props) => {
5110
5415
  });
5111
5416
  MultiSelectOptionComponent.displayName = 'MultiSelectOptionComponent';
5112
5417
  const SelectOptionContent = ({ item }) => {
5113
- return React__default["default"].createElement("div", { className: "o-select-option-data" }, item.text);
5418
+ return React__default["default"].createElement("div", { className: `o-select-option-data${item.group ? ' o-select-option-group-item' : ''}` }, item.text);
5419
+ };
5420
+ const SelectOptionGroup = ({ item }) => {
5421
+ return React__default["default"].createElement("div", { className: "o-select-option-group" }, getGroupText(item));
5114
5422
  };
5115
5423
  const SelectOptionComponent = React__default["default"].memo((props) => {
5116
5424
  const { item, index, onClick, onMouseEnter, onMouseLeave, multiple = false } = props;
5117
- const { OptionContentComponent = SelectOptionContent, OptionLoadingComponent = LoadingItem$1 } = useSelectConfig();
5425
+ const service = useSelectService();
5426
+ const previousItem = service.items[index - 1];
5427
+ const displayGroup = getGroupText(item) !== getGroupText(previousItem);
5428
+ const { OptionContentComponent = SelectOptionContent, OptionLoadingComponent = LoadingItem$1, OptionGroupComponent = SelectOptionGroup, } = service.config || {};
5118
5429
  let clickable = !!onClick && !item?.disabled;
5119
5430
  let hoverable = true;
5120
5431
  if (item?.data === undefined && onekijsFramework.isItemLoading(item)) {
@@ -5145,59 +5456,60 @@ const SelectOptionComponent = React__default["default"].memo((props) => {
5145
5456
  }
5146
5457
  if (!item || !item.data)
5147
5458
  return null;
5148
- return (React__default["default"].createElement("div", { className: classNames, onMouseEnter: () => hoverable && onMouseEnter && item && onMouseEnter(item, index), onMouseLeave: () => hoverable && onMouseLeave && item && onMouseLeave(item, index), onClick: () => clickable && onClick && item && onClick(item, index) },
5149
- multiple && (React__default["default"].createElement(Checkbox, { value: item?.selected ? true : false, onChange: () => undefined, color: "currentColor", className: "o-select-option-multiple-checkbox" })),
5150
- React__default["default"].createElement(OptionContentComponent, { ...props })));
5459
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
5460
+ displayGroup && React__default["default"].createElement(OptionGroupComponent, { ...props }),
5461
+ React__default["default"].createElement("div", { className: classNames, onMouseEnter: () => hoverable && onMouseEnter && item && onMouseEnter(item, index), onMouseLeave: () => hoverable && onMouseLeave && item && onMouseLeave(item, index), onClick: () => clickable && onClick && item && onClick(item, index) },
5462
+ multiple && (React__default["default"].createElement(Checkbox, { value: item?.selected ? true : false, onChange: () => clickable && onClick && item && onClick(item, index), color: "currentColor", className: "o-select-option-multiple-checkbox" })),
5463
+ React__default["default"].createElement(OptionContentComponent, { ...props }))));
5151
5464
  });
5152
5465
  SelectOptionComponent.displayName = 'SelectOptionComponent';
5153
5466
 
5154
- const findItem = (controller, pattern) => {
5155
- let result = undefined;
5156
- if (controller.items === undefined) {
5157
- return undefined;
5158
- }
5159
- for (const item of controller.items) {
5160
- if (item === undefined || item.text === undefined) {
5161
- continue;
5162
- }
5163
- if (item.text.toLowerCase().startsWith(pattern.toLowerCase())) {
5164
- return item;
5165
- }
5166
- if (result === undefined && item.text.toLowerCase().includes(pattern.toLowerCase())) {
5167
- result = item;
5168
- }
5169
- }
5170
- return result;
5171
- };
5172
- const findItemIndex = (controller, item) => {
5173
- if (controller.items === undefined) {
5174
- return -1;
5467
+ const ControllerSelectComponent = ({ attachDropdownToBody = false, className = '', placeholder, controller, InputComponent = SelectInputComponent, IconComponent, OptionContentComponent = SelectOptionContent, OptionComponent = SelectOptionComponent, OptionLoadingComponent = LoadingItem$1, MultiOptionsComponent = MultiSelectOptionComponent, NotFoundComponent = SelectNotFoundComponent, autoFocus, value, onChange, onBlur: forwardBlur, onFocus: forwardFocus, height = '220px', multiple = false, status = onekijsFramework.ValidationStatus.None, size = 'medium', nullable, minChars = 0, openOnFocus = false, searchable = true, dropdownWidthModifier = 'same', preload = 50, increment = 50, animationMs = 200, disabled, defaultValue, required = false, sameWidth = true, overscan, clickable = true, }) => {
5468
+ if (nullable === undefined) {
5469
+ nullable = !required;
5175
5470
  }
5176
- return controller.items.findIndex((i) => {
5177
- if (i === undefined) {
5178
- return false;
5179
- }
5180
- if (i.id === undefined) {
5181
- return false;
5182
- }
5183
- return i.id === item?.id;
5184
- });
5185
- };
5186
- const ControllerSelectComponent = ({ attachDropdownToBody = false, className = '', placeholder, controller, InputComponent = SelectInputComponent, IconComponent, OptionContentComponent = SelectOptionContent, OptionComponent = SelectOptionComponent, OptionLoadingComponent = LoadingItem$1, MultiOptionsComponent = MultiSelectOptionComponent, NotFoundComponent = SelectNotFoundComponent, autoFocus, value, onChange, onBlur: forwardBlur, onFocus: forwardFocus, height = '220px', multiple = false, status = onekijsFramework.ValidationStatus.None, size = 'medium', nullable = true, minChars = 0, openOnFocus = false, clickable = true, dropdownWidthModifier = 'same', preload = 100, increment = 100, animationMs = 200, disabled, }) => {
5187
5471
  const [open, setOpen] = React.useState(false);
5188
5472
  const [focus, setFocus] = React.useState(false);
5189
5473
  const stateRef = React.useRef({});
5190
5474
  const service = controller.asService();
5475
+ service.config = {
5476
+ attachDropdownToBody,
5477
+ className,
5478
+ placeholder,
5479
+ InputComponent,
5480
+ IconComponent,
5481
+ OptionContentComponent,
5482
+ OptionComponent,
5483
+ OptionLoadingComponent,
5484
+ MultiOptionsComponent,
5485
+ NotFoundComponent,
5486
+ autoFocus,
5487
+ value,
5488
+ onChange,
5489
+ onBlur: forwardBlur,
5490
+ onFocus: forwardFocus,
5491
+ height,
5492
+ multiple,
5493
+ status,
5494
+ size,
5495
+ nullable,
5496
+ minChars,
5497
+ openOnFocus,
5498
+ searchable,
5499
+ clickable,
5500
+ dropdownWidthModifier,
5501
+ preload,
5502
+ increment,
5503
+ animationMs,
5504
+ disabled,
5505
+ defaultValue,
5506
+ sameWidth,
5507
+ };
5508
+ const id = React.useId();
5191
5509
  const loading = onekijsFramework.isCollectionLoading(controller);
5192
5510
  const fetching = onekijsFramework.isCollectionFetching(controller);
5193
5511
  const containerRef = React.useRef(null);
5194
5512
  const previousSearchRef = React.useRef();
5195
- const config = React.useMemo(() => {
5196
- return {
5197
- OptionContentComponent,
5198
- OptionLoadingComponent,
5199
- };
5200
- }, [OptionContentComponent, OptionLoadingComponent]);
5201
5513
  const tokens = React.useMemo(() => {
5202
5514
  return (controller.state.selected || [])
5203
5515
  .map((uid) => service.getItem(uid))
@@ -5210,7 +5522,7 @@ const ControllerSelectComponent = ({ attachDropdownToBody = false, className = '
5210
5522
  return controller.getItem(controller.state.active[0]);
5211
5523
  }
5212
5524
  else if (focus && search) {
5213
- const item = findItem(controller, search.toString());
5525
+ const item = findSelectItem(controller, search.toString());
5214
5526
  if (item === undefined && !onekijsFramework.isCollectionFetching(controller)) {
5215
5527
  return onekijsFramework.get(controller, 'items.0');
5216
5528
  }
@@ -5258,7 +5570,7 @@ const ControllerSelectComponent = ({ attachDropdownToBody = false, className = '
5258
5570
  React.useEffect(() => {
5259
5571
  const search = controller.getSearch();
5260
5572
  if (open && focus && search && search !== previousSearchRef.current) {
5261
- const item = findItem(controller, search.toString());
5573
+ const item = findSelectItem(controller, search.toString());
5262
5574
  const activated = onekijsFramework.get(controller.state.active, '0');
5263
5575
  if (item !== undefined && !onekijsFramework.isCollectionFetching(controller)) {
5264
5576
  previousSearchRef.current = search;
@@ -5267,7 +5579,69 @@ const ControllerSelectComponent = ({ attachDropdownToBody = false, className = '
5267
5579
  }
5268
5580
  }
5269
5581
  }
5270
- }, [controller, focus, open]);
5582
+ }, [controller, focus, open, id]);
5583
+ React.useEffect(() => {
5584
+ if (!multiple) {
5585
+ if (value) {
5586
+ service.setSelected('item', service.adapt(value));
5587
+ }
5588
+ else {
5589
+ service.setSelected('item', []);
5590
+ }
5591
+ }
5592
+ else {
5593
+ if (value && Array.isArray(value)) {
5594
+ service.setSelected('item', value.map((v) => service.adapt(v)));
5595
+ }
5596
+ else {
5597
+ service.setSelected('item', []);
5598
+ }
5599
+ }
5600
+ service.check();
5601
+ }, [multiple, value, service]);
5602
+ // Manage the result of a check after a change of the value from the outside
5603
+ // if the selected item is invalid, do a onChange to remove the value
5604
+ React.useEffect(() => {
5605
+ const search = service.getSearch();
5606
+ const invalidItems = service.state.invalidItems || [];
5607
+ if (!search && invalidItems.length > 0) {
5608
+ if (multiple) {
5609
+ const validTokens = [];
5610
+ tokens.forEach((t) => {
5611
+ const invalidToken = invalidItems.find((i) => t.uid === i.uid);
5612
+ if (!invalidToken) {
5613
+ validTokens.push(t);
5614
+ }
5615
+ });
5616
+ if (validTokens.length !== tokens.length && onChange) {
5617
+ let validData = validTokens.map((t) => t.data);
5618
+ if (validData.length === 0 && Array.isArray(service.state.validDefaultValue)) {
5619
+ validData = service.state.validDefaultValue;
5620
+ }
5621
+ onChange(validData);
5622
+ }
5623
+ }
5624
+ else {
5625
+ const currentItem = service.adapt(value);
5626
+ if (invalidItems.find((i) => i.id === currentItem.id)) {
5627
+ // set the defaultValue if it's a valid value otherwise set null
5628
+ onChange && onChange(service.state.validDefaultValue || null);
5629
+ }
5630
+ }
5631
+ }
5632
+ else if (!search && !nullable && !value && service.state.validDefaultValue) {
5633
+ onChange && onChange(service.state.validDefaultValue);
5634
+ }
5635
+ }, [
5636
+ service,
5637
+ multiple,
5638
+ onChange,
5639
+ value,
5640
+ tokens,
5641
+ service.state.invalidItems,
5642
+ service.state.validDefaultValue,
5643
+ nullable,
5644
+ ]);
5271
5645
  const onInputChange = (nextValue) => {
5272
5646
  showActiveRef.current = false;
5273
5647
  if (nextValue === null) {
@@ -5301,13 +5675,14 @@ const ControllerSelectComponent = ({ attachDropdownToBody = false, className = '
5301
5675
  if (service.getSearch()) {
5302
5676
  clearSearch();
5303
5677
  }
5304
- if (multiple && item && !item.selected) {
5678
+ const isSelected = item?.selected;
5679
+ if (multiple && item && !isSelected) {
5305
5680
  service.addSelected('item', item);
5306
5681
  }
5307
- else if (multiple && item && item.selected) {
5682
+ else if (multiple && item && isSelected) {
5308
5683
  service.removeSelected('item', item);
5309
5684
  }
5310
- else if (item && !item.selected) {
5685
+ else if (item && !isSelected) {
5311
5686
  service.setSelected('item', item);
5312
5687
  }
5313
5688
  else {
@@ -5315,7 +5690,7 @@ const ControllerSelectComponent = ({ attachDropdownToBody = false, className = '
5315
5690
  }
5316
5691
  if (onChange) {
5317
5692
  if (multiple) {
5318
- if (item && item.selected) {
5693
+ if (item && isSelected) {
5319
5694
  onRemoveToken(item, index);
5320
5695
  }
5321
5696
  else {
@@ -5351,7 +5726,7 @@ const ControllerSelectComponent = ({ attachDropdownToBody = false, className = '
5351
5726
  const selectedUid = e.key === 'ArrowDown' ? onekijsFramework.first(service.state.selected) : onekijsFramework.last(service.state.selected);
5352
5727
  if (selectedUid !== undefined) {
5353
5728
  const selectedItem = service.getItem(selectedUid);
5354
- const selectedIndex = findItemIndex(service, selectedItem);
5729
+ const selectedIndex = findSelectItemIndex(service, selectedItem);
5355
5730
  if (selectedIndex !== undefined) {
5356
5731
  nextIndex =
5357
5732
  e.key === 'ArrowDown'
@@ -5378,7 +5753,7 @@ const ControllerSelectComponent = ({ attachDropdownToBody = false, className = '
5378
5753
  break;
5379
5754
  case 'Escape':
5380
5755
  if (focus) {
5381
- if (open) {
5756
+ if (open && onekijsFramework.eventLocks.isLockedBy('escape', id)) {
5382
5757
  setOpen(false);
5383
5758
  }
5384
5759
  if (service.getSearch()) {
@@ -5388,7 +5763,7 @@ const ControllerSelectComponent = ({ attachDropdownToBody = false, className = '
5388
5763
  stateRef.current.keepFocus = false;
5389
5764
  break;
5390
5765
  }
5391
- }, [service, open, setOpen, focus, multiple, clearSearch]);
5766
+ }, [service, open, setOpen, focus, multiple, clearSearch, id]);
5392
5767
  const style = {};
5393
5768
  const classNames = addClassname(`o-select ${disabled ? 'o-select-disabled' : 'o-select-enabled'} o-select-size-${size} o-select-${open ? 'open' : 'close'}${status ? ' o-select-status-' + status.toLowerCase() : ''}${multiple ? ' o-select-multiple' : ''}`, className);
5394
5769
  const optionsRef = React.useRef(null);
@@ -5397,46 +5772,80 @@ const ControllerSelectComponent = ({ attachDropdownToBody = false, className = '
5397
5772
  height: height,
5398
5773
  ref: optionsRef,
5399
5774
  preload,
5775
+ overscan,
5400
5776
  increment,
5401
5777
  });
5402
5778
  const onOpen = React.useCallback(() => {
5779
+ onekijsFramework.eventLocks.lock('escape', id);
5403
5780
  const scrollTo = { index: 0, align: 'start' };
5404
5781
  const selectedUid = onekijsFramework.first(service.state.selected);
5405
5782
  if (selectedUid !== undefined) {
5406
5783
  const selectedItem = service.getItem(selectedUid);
5407
- const selectedIndex = findItemIndex(service, selectedItem);
5408
- if (selectedItem !== undefined && selectedIndex > 0) {
5784
+ const selectedIndex = findSelectItemIndex(service, selectedItem);
5785
+ if (selectedItem !== undefined && selectedIndex >= 0) {
5409
5786
  scrollTo.index = selectedIndex;
5410
5787
  scrollTo.align = 'center';
5411
5788
  service.setActive('item', selectedItem);
5412
5789
  }
5413
5790
  }
5414
5791
  scrollToIndex(scrollTo.index, { align: scrollTo.align });
5415
- }, [service, scrollToIndex]);
5792
+ }, [service, scrollToIndex, id]);
5416
5793
  const onClosed = React.useCallback(() => {
5794
+ onekijsFramework.eventLocks.unlock('escape', id);
5417
5795
  service.setActive('item', []);
5418
- }, [service]);
5796
+ service.setHighlighted('item', []);
5797
+ }, [service, id]);
5419
5798
  const [Dropdown, triggerRef] = useDropdown();
5420
5799
  onekijsFramework.useEventListener('keydown', onKeyDownCapture, true);
5421
5800
  onekijsFramework.useEventListener('keydown', onKeyDown, false);
5422
- return (React__default["default"].createElement(SelectConfigContext.Provider, { value: config },
5423
- React__default["default"].createElement("div", { className: classNames, ref: containerRef, onMouseDown: () => (stateRef.current.keepFocus = true), onMouseUp: () => (stateRef.current.keepFocus = false) },
5424
- React__default["default"].createElement(InputComponent, { placeholder: placeholder, setOpen: setOpen, open: open, loading: loading, fetching: fetching, onChange: onInputChange, value: proxyItem ? proxyItem.text : '', focus: focus, onFocus: onFocus, onBlur: onBlur, tokens: tokens, multiple: multiple, onRemove: onRemoveToken, autoFocus: autoFocus, style: style, nullable: nullable, IconComponent: IconComponent, clickable: clickable, minChars: minChars, ref: triggerRef, disabled: disabled }),
5425
- React__default["default"].createElement(Dropdown, { attachToBody: attachDropdownToBody, open: open, distance: 0, animationTimeout: animationMs, onDropStart: onOpen, onCollapseDone: onClosed, placement: "bottom", widthModifier: dropdownWidthModifier, className: className, zIndex: attachDropdownToBody ? 2000 : undefined },
5426
- React__default["default"].createElement(ListBodyComponent, { className: "o-select-options", bodyRef: optionsRef, height: height, ItemComponent: multiple ? MultiOptionsComponent : OptionComponent, ItemLoadingComponent: OptionLoadingComponent, ItemContentComponent: OptionContentComponent, NotFoundComponent: NotFoundComponent, items: selectItems, onItemSelect: onSelect, totalSize: totalSize, virtualItems: isVirtual ? virtualItems : undefined, scrollToIndex: scrollToIndex, service: controller.asService(), state: controller.state, keyboardNavigable: true, multiSelect: multiple, onItemActivate: onActivate })))));
5427
- };
5428
-
5429
- const ArraySelectComponent = (props) => {
5430
- const controller = useSelectController(props.dataSource, { adapter: props.adapter, fetchOnce: props.fetchOnce });
5431
- return React__default["default"].createElement(ControllerSelectComponent, { ...props, controller: controller });
5432
- };
5433
-
5434
- const SelectComponent = React__default["default"].memo((props) => {
5435
- const controller = props.controller;
5436
- if (onekijsFramework.isCollection(controller)) {
5437
- return React__default["default"].createElement(ControllerSelectComponent, { ...props, controller: controller });
5438
- }
5439
- else {
5801
+ const update = React.useCallback(() => {
5802
+ if (optionsRef.current && !sameWidth) {
5803
+ if (optionsRef.current.scrollWidth > optionsRef.current.offsetWidth) {
5804
+ optionsRef.current.style.width = `${optionsRef.current.scrollWidth + optionsRef.current.offsetWidth - optionsRef.current.clientWidth + 5}px`;
5805
+ }
5806
+ }
5807
+ }, [sameWidth]);
5808
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
5809
+ const throttleUpdate = onekijsFramework.useThrottle(update, 20);
5810
+ const resizeObserver = React.useMemo(() => {
5811
+ return new ResizeObserver(() => {
5812
+ throttleUpdate();
5813
+ });
5814
+ }, [throttleUpdate]);
5815
+ onekijsFramework.useIsomorphicLayoutEffect(() => {
5816
+ const el = optionsRef;
5817
+ if (el.current) {
5818
+ resizeObserver.observe(el.current);
5819
+ }
5820
+ return () => {
5821
+ if (el.current) {
5822
+ resizeObserver.unobserve(el.current);
5823
+ }
5824
+ };
5825
+ }, [optionsRef]);
5826
+ onekijsFramework.useIsomorphicLayoutEffect(() => {
5827
+ if (open) {
5828
+ setTimeout(update, 0);
5829
+ }
5830
+ }, [open, update]);
5831
+ return (React__default["default"].createElement(SelectServiceContext.Provider, { value: service },
5832
+ React__default["default"].createElement("div", { className: classNames, ref: containerRef, onMouseDown: () => (stateRef.current.keepFocus = true), onMouseUp: () => (stateRef.current.keepFocus = false) },
5833
+ React__default["default"].createElement(InputComponent, { placeholder: placeholder, setOpen: setOpen, open: open, loading: loading, fetching: fetching, onChange: onInputChange, value: proxyItem ? proxyItem.text : '', focus: focus, onFocus: onFocus, onBlur: onBlur, tokens: tokens, multiple: multiple, onRemove: onRemoveToken, autoFocus: autoFocus, style: style, nullable: nullable, IconComponent: IconComponent, searchable: searchable, clickable: clickable, minChars: minChars, ref: triggerRef, disabled: disabled }),
5834
+ React__default["default"].createElement(Dropdown, { attachToBody: attachDropdownToBody, open: open, distance: 0, animationTimeout: animationMs, onDropStart: onOpen, onCollapseDone: onClosed, placement: "bottom", widthModifier: dropdownWidthModifier, className: className, zIndex: attachDropdownToBody ? 2000 : undefined },
5835
+ React__default["default"].createElement(ListBodyComponent, { className: "o-select-options", bodyRef: optionsRef, height: height, ItemComponent: multiple ? MultiOptionsComponent : OptionComponent, ItemLoadingComponent: OptionLoadingComponent, ItemContentComponent: OptionContentComponent, NotFoundComponent: NotFoundComponent, items: selectItems, onItemSelect: onSelect, onItemUnselect: onSelect, totalSize: totalSize, virtualItems: isVirtual ? virtualItems : undefined, scrollToIndex: scrollToIndex, service: controller.asService(), state: controller.state, keyboardNavigable: true, multiSelect: multiple, onItemActivate: onActivate })))));
5836
+ };
5837
+
5838
+ const ArraySelectComponent = (props) => {
5839
+ const controller = useSelectController(props.dataSource, { adapter: props.adapter, fetchOnce: props.fetchOnce });
5840
+ return React__default["default"].createElement(ControllerSelectComponent, { ...props, controller: controller });
5841
+ };
5842
+
5843
+ const SelectComponent = React__default["default"].memo((props) => {
5844
+ const controller = props.controller;
5845
+ if (onekijsFramework.isCollection(controller)) {
5846
+ return React__default["default"].createElement(ControllerSelectComponent, { ...props, controller: controller });
5847
+ }
5848
+ else {
5440
5849
  return React__default["default"].createElement(ArraySelectComponent, { ...props, dataSource: props.dataSource || [] });
5441
5850
  }
5442
5851
  });
@@ -5449,7 +5858,7 @@ const emptyCells = cssProperty('empty-cells');
5449
5858
  const tableLayout = cssProperty('table-layout');
5450
5859
  const verticalAlign = cssProperty('vertical-align');
5451
5860
 
5452
- const selectStyle = ({ theme, clickable }) => {
5861
+ const selectStyle = ({ theme, clickable = true, searchable = true }) => {
5453
5862
  return styled.css `
5454
5863
  ${preflight()}
5455
5864
  ${width('100%')}
@@ -5571,12 +5980,13 @@ const selectStyle = ({ theme, clickable }) => {
5571
5980
  ${borderWidth('2px')}
5572
5981
  ${padding(0)}
5573
5982
  }
5574
- .o-select-remover {
5575
- ${cursor('pointer')}
5576
- ${color('light')}
5577
- ${fontFamily('Arial')}
5578
- ${paddingX('sm')}
5579
- }
5983
+ }
5984
+
5985
+ .o-select-remover {
5986
+ ${cursor('pointer')}
5987
+ ${color('light')}
5988
+ ${fontFamily('Arial')}
5989
+ ${paddingX('sm')}
5580
5990
  }
5581
5991
 
5582
5992
  &.o-select-disabled {
@@ -5590,24 +6000,39 @@ const selectStyle = ({ theme, clickable }) => {
5590
6000
 
5591
6001
  .o-select-icon-container {
5592
6002
  ${cursor('not-allowed')}
5593
- .o-select-icon {
5594
- ${cursor('not-allowed')}
5595
- }
5596
6003
  }
5597
6004
 
5598
- .o-select-input-data {
5599
- .o-select-token {
6005
+ .o-select-icon {
6006
+ ${color('dark')}
6007
+ ${cursor('not-allowed')}
6008
+ }
6009
+
6010
+ .o-select-token {
6011
+ ${cursor('not-allowed')}
6012
+ ${backgroundColor('dark')}
6013
+ }
6014
+
6015
+ .o-select-token-remove {
6016
+ ${cursor('not-allowed')}
6017
+ }
6018
+ &.o-select-close {
6019
+ .o-select-input {
5600
6020
  ${cursor('not-allowed')}
5601
- .o-select-token-remove {
5602
- ${cursor('not-allowed')}
5603
- }
5604
6021
  }
5605
6022
  }
5606
6023
  }
5607
6024
 
6025
+ input.o-select-input {
6026
+ ${!searchable ? width(0) : ''}
6027
+ }
6028
+
6029
+ .o-select-input-text {
6030
+ ${userSelect('none')}
6031
+ }
6032
+
5608
6033
  &.o-select-close {
5609
6034
  .o-select-input {
5610
- ${cursor('pointer')}
6035
+ ${cursor(clickable ? 'pointer' : 'auto')}
5611
6036
  }
5612
6037
  }
5613
6038
  &.o-select-open {
@@ -5615,6 +6040,9 @@ const selectStyle = ({ theme, clickable }) => {
5615
6040
  ${borderBottomRightRadius(0)}
5616
6041
  ${borderBottomLeftRadius(0)}
5617
6042
  }
6043
+ .o-select-input {
6044
+ ${cursor(searchable ? 'auto' : 'pointer')}
6045
+ }
5618
6046
  }
5619
6047
 
5620
6048
  .o-select-input-data {
@@ -5623,50 +6051,55 @@ const selectStyle = ({ theme, clickable }) => {
5623
6051
  ${flexWrap('wrap')}
5624
6052
  ${alignItems('center')}
5625
6053
  ${paddingX('sm')}
5626
- .o-select-input-wrapper {
5627
- ${flexGrow(1)}
5628
- ${color('gray-800')}
5629
- ${position('relative')}
5630
- ${display('inline-block')}
5631
- ${minWidth('50px')}
5632
- .o-select-input-auto-sizer {
5633
- ${visibility(false)}
5634
- ${display('inline-block')}
5635
- ${whiteSpace('pre')}
5636
- }
5637
- .o-select-input {
5638
- ${position('absolute')}
5639
- ${top(0)}
5640
- ${left(0)}
5641
- ${right(0)}
5642
- ${bottom(0)}
5643
- ${appearance('none')}
5644
- ${outline('none')}
5645
- ${width('full')}
5646
- ${color('gray-800', { placeholder: 'gray-400' })}
5647
- }
5648
- }
6054
+ ${maxWidth('calc(100% - 32px)')}
6055
+ }
5649
6056
 
5650
- .o-select-token {
5651
- ${cursor('default')}
5652
- ${whiteSpace('pre')}
5653
- ${backgroundColor('primary')}
5654
- ${color('white')}
5655
- ${marginRight('sm')}
5656
- ${borderRadius('md')}
5657
- ${fontSize('sm')}
5658
- ${display('flex')}
5659
- .o-select-token-text {
5660
- ${flexGrow(1)}
5661
- ${paddingLeft('sm')}
5662
- }
5663
- .o-select-token-remove {
5664
- ${cursor('pointer')}
5665
- ${color('white', { hover: 'danger' })}
5666
- ${fontFamily('Arial')}
5667
- ${paddingX('sm')}
5668
- }
5669
- }
6057
+ .o-select-input-wrapper {
6058
+ ${flexGrow(1)}
6059
+ ${color('gray-800')}
6060
+ ${position('relative')}
6061
+ ${display('inline-block')}
6062
+ ${minWidth('50px')}
6063
+ }
6064
+
6065
+ .o-select-input-auto-sizer {
6066
+ ${visibility(false)}
6067
+ ${display('inline-block')}
6068
+ ${whiteSpace('pre')}
6069
+ }
6070
+
6071
+ .o-select-input {
6072
+ ${position('absolute')}
6073
+ ${top(0)}
6074
+ ${left(0)}
6075
+ ${right(0)}
6076
+ ${bottom(0)}
6077
+ ${appearance('none')}
6078
+ ${outline('none')}
6079
+ ${width('full')}
6080
+ ${color('gray-800', { placeholder: 'gray-400' })}
6081
+ }
6082
+
6083
+ .o-select-token {
6084
+ ${cursor('default')}
6085
+ ${whiteSpace('pre')}
6086
+ ${backgroundColor('primary')}
6087
+ ${color('white')}
6088
+ ${marginRight('sm')}
6089
+ ${borderRadius('md')}
6090
+ ${fontSize('sm')}
6091
+ ${display('flex')}
6092
+ }
6093
+
6094
+ .o-select-token-text {
6095
+ ${flexGrow(1)}
6096
+ ${paddingLeft('sm')}
6097
+ }
6098
+ .o-select-token-remove {
6099
+ ${cursor('pointer')}
6100
+ ${color('white', { hover: 'danger' })}
6101
+ ${fontFamily('Arial')}
6102
+ ${paddingX('sm')}
5670
6103
  }
5671
6104
 
5672
6105
  .o-select-icon-container {
@@ -5678,23 +6111,23 @@ const selectStyle = ({ theme, clickable }) => {
5678
6111
  ${display('flex')}
5679
6112
  ${alignItems('center')}
5680
6113
  ${borderColor('gray-200')}
5681
- .o-select-icon {
5682
- ${color('primary')}
5683
- ${cursor('pointer')}
5684
- ${width(4)}
5685
- ${height(4)}
5686
- ${outline('none', { focus: 'none' })}
5687
- ${backgroundColor('transparent')}
5688
- ${padding(0)}
5689
- }
5690
- .o-select-arrow-svg {
5691
- ${display('block')}
5692
- ${verticalAlign('middle')}
5693
- ${margin('px')}
5694
- ${transitionDuration('.5s')}
5695
- ${transitionProperty('all')}
5696
- ${transitionTimingFunction('ease-in-out')}
5697
- }
6114
+ }
6115
+ .o-select-icon {
6116
+ ${color('primary')}
6117
+ ${cursor('pointer')}
6118
+ ${width(4)}
6119
+ ${height(4)}
6120
+ ${outline('none', { focus: 'none' })}
6121
+ ${backgroundColor('transparent')}
6122
+ ${padding(0)}
6123
+ }
6124
+ .o-select-arrow-svg {
6125
+ ${display('block')}
6126
+ ${verticalAlign('middle')}
6127
+ ${margin('px')}
6128
+ ${transitionDuration('.5s')}
6129
+ ${transitionProperty('all')}
6130
+ ${transitionTimingFunction('ease-in-out')}
5698
6131
  }
5699
6132
 
5700
6133
  &.o-select-multiple {
@@ -5738,27 +6171,38 @@ const selectStyle = ({ theme, clickable }) => {
5738
6171
  .o-select-options {
5739
6172
  scrollbar-width: thin;
5740
6173
  scrollbar-color: ${(props) => props.theme.palette.colors[props.theme.colors.primary]}
5741
- ${(props) => props.theme.colors['gray-200']};
6174
+ ${(props) => props.theme.colors[props.theme.colors.lighter]};
5742
6175
  &::-webkit-scrollbar {
5743
6176
  width: 12px;
5744
6177
  }
5745
6178
  &::-webkit-scrollbar-track {
5746
- background: ${(props) => props.theme.palette.colors['gray-200']};
6179
+ background: ${(props) => props.theme.palette.colors[props.theme.colors.lighter]};
5747
6180
  }
5748
6181
  &::-webkit-scrollbar-thumb {
5749
6182
  background-color: ${(props) => props.theme.palette.colors[props.theme.colors.primary]};
5750
- border: 3px solid ${(props) => props.theme.palette.colors['gray-200']};
6183
+ border: 3px solid ${(props) => props.theme.palette.colors[props.theme.colors.lighter]};
5751
6184
  }
5752
6185
  ${overflowY('hidden')}
5753
6186
 
6187
+ .o-select-option-group {
6188
+ ${paddingX('md')}
6189
+ ${userSelect('none')}
6190
+ ${fontWeight('bold')}
6191
+ ${paddingTop('sm')}
6192
+ }
6193
+ .o-select-option-group-item {
6194
+ ${paddingLeft('sm')}
6195
+ }
6196
+
5754
6197
  .o-select-option {
5755
6198
  ${width('full')}
5756
6199
  ${paddingX('lg')}
5757
- ${paddingY('sm')}
6200
+ ${paddingY('xs')}
5758
6201
  ${display('flex')}
5759
6202
  ${alignItems('center')}
5760
6203
  ${backgroundColor('transparent', { hover: 'gray-200' })}
5761
6204
  ${userSelect('none')}
6205
+ ${minHeight('32px')}
5762
6206
  &.o-select-option-clickable {
5763
6207
  ${cursor('pointer')}
5764
6208
  }
@@ -5767,8 +6211,9 @@ const selectStyle = ({ theme, clickable }) => {
5767
6211
  ${color('inherit')}
5768
6212
  }
5769
6213
  &.o-select-option-active {
5770
- ${backgroundColor('primary')}
5771
- ${color('white')}
6214
+ ${backgroundColor(lighten(theme.colors.primary, 600))}
6215
+ ${color('primary')}
6216
+ ${fontWeight('bold')}
5772
6217
  }
5773
6218
 
5774
6219
  .o-select-option-icon {
@@ -5800,10 +6245,20 @@ const FormSelect = React__default["default"].memo((props) => {
5800
6245
  }, props));
5801
6246
  const Component = props.FieldComponent || Select;
5802
6247
  return (React__default["default"].createElement(FieldLayout, { ...fieldLayoutProps, required: props.required },
5803
- React__default["default"].createElement(Component, { ...fieldComponentProps })));
6248
+ React__default["default"].createElement(Component, { ...fieldComponentProps, required: props.required, defaultValue: props.defaultValue })));
5804
6249
  });
5805
6250
  FormSelect.displayName = 'FormSelect';
5806
6251
 
6252
+ class DefaultSelectBroker extends onekijsFramework.DefaultCollectionBroker {
6253
+ defaultValue;
6254
+ setDefaultValue(defaultValue, subscriberId) {
6255
+ if (subscriberId === undefined) {
6256
+ this.defaultValue = defaultValue;
6257
+ }
6258
+ this._getSubscribers(subscriberId).forEach((s) => s.setDefaultValue(defaultValue));
6259
+ }
6260
+ }
6261
+
5807
6262
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
5808
6263
  const TabsServiceContext = React__default["default"].createContext(null);
5809
6264
  const useTabsService = () => {
@@ -5857,6 +6312,7 @@ let TabsService = class TabsService extends onekijsFramework.DefaultService {
5857
6312
  t.active = false;
5858
6313
  });
5859
6314
  member.active = true;
6315
+ member.touched = false;
5860
6316
  this.state.active = uid;
5861
6317
  this.touching(this.state.active);
5862
6318
  }
@@ -6197,7 +6653,7 @@ const useTab = (props) => {
6197
6653
  return tab;
6198
6654
  };
6199
6655
 
6200
- const Tab = ({ title, active = false, disabled = false, visible = true, closable = false, children, icon, uid, }) => {
6656
+ const Tab = ({ title, active = false, disabled = false, visible = true, closable = false, children, icon, uid, className, }) => {
6201
6657
  const tab = useTab({
6202
6658
  title,
6203
6659
  active,
@@ -6224,7 +6680,7 @@ const Tab = ({ title, active = false, disabled = false, visible = true, closable
6224
6680
  return null;
6225
6681
  }
6226
6682
  return (React__default["default"].createElement(reactTransitionGroup.CSSTransition, { in: true, timeout: animate, appear: true, onEnter: onEnter, onEntering: onEntering },
6227
- React__default["default"].createElement("div", { className: "o-tab" }, children)));
6683
+ React__default["default"].createElement("div", { className: addClassname('o-tab', className) }, children)));
6228
6684
  };
6229
6685
 
6230
6686
  let TableService = class TableService extends onekijsFramework.CollectionService {
@@ -6603,6 +7059,7 @@ const DefaultTableHeaderTitleComponent = ({ column, sort }) => {
6603
7059
  };
6604
7060
  return (React__default["default"].createElement("div", { onClick: isSortable ? onSort : undefined, style: { display: 'flex', alignItems: 'center' } },
6605
7061
  React__default["default"].createElement("span", { className: "o-table-header-title" }, column.title),
7062
+ column.help && React__default["default"].createElement(Help, { content: column.help, size: "small" }),
6606
7063
  isSortable && React__default["default"].createElement(TableSortComponent, { sort: sort, column: column })));
6607
7064
  };
6608
7065
  const TableHeaderTitleComponent = React__default["default"].memo((props) => {
@@ -6937,22 +7394,23 @@ const tableStyle = ({ theme, fit = true }) => {
6937
7394
  ${borderBottomStyle(t.tdBorderBottomStyle)}
6938
7395
  ${boxShadow('default')}
6939
7396
  ${backgroundColor(t.bgColor)}
7397
+ }
6940
7398
 
6941
- .o-table-body-cell {
6942
- ${paddingX(t.tdPaddingX)}
6943
- ${paddingY(t.tdPaddingY)}
6944
- ${boxSizing('border-box')}
6945
- ${overflow('hidden')}
6946
- &.o-table-cell-expander {
6947
- ${padding(0)}
6948
- .o-table-cell-expander-content {
6949
- ${paddingX(t.tdPaddingX)}
6950
- ${paddingY(t.tdPaddingY)}
6951
- ${cursor('pointer')}
6952
- }
7399
+ .o-table-body-cell {
7400
+ ${paddingX(t.tdPaddingX)}
7401
+ ${paddingY(t.tdPaddingY)}
7402
+ ${boxSizing('border-box')}
7403
+ ${overflow('hidden')}
7404
+ &.o-table-cell-expander {
7405
+ ${padding(0)}
7406
+ .o-table-cell-expander-content {
7407
+ ${paddingX(t.tdPaddingX)}
7408
+ ${paddingY(t.tdPaddingY)}
7409
+ ${cursor('pointer')}
6953
7410
  }
6954
7411
  }
6955
7412
  }
7413
+
6956
7414
  .o-table-body-row-even {
6957
7415
  ${backgroundColor(t.tdStripBgColor)}
6958
7416
  }
@@ -7057,8 +7515,8 @@ const tableStyle = ({ theme, fit = true }) => {
7057
7515
  }
7058
7516
  .o-table-header-title-container {
7059
7517
  ${paddingY('xs')}
7060
- ${borderBottomWidth('1px')}
7061
- ${borderBottomColor('primary')}
7518
+ ${borderBottomWidth(t.thBorderBottomWidth)}
7519
+ ${borderBottomColor(t.thBorderBottomColor)}
7062
7520
  }
7063
7521
  }
7064
7522
 
@@ -7070,7 +7528,7 @@ const tableStyle = ({ theme, fit = true }) => {
7070
7528
  ${textTransform('uppercase')}
7071
7529
  ${fontSize('xs')}
7072
7530
  ${cursor('pointer')}
7073
- ${color('primary')}
7531
+ ${color('pink')}
7074
7532
  .o-toggler-icon-container {
7075
7533
  ${marginBottom('px')}
7076
7534
  }
@@ -7078,15 +7536,30 @@ const tableStyle = ({ theme, fit = true }) => {
7078
7536
  .o-form-table-remove {
7079
7537
  ${display('inline-flex')}
7080
7538
  ${alignItems('center')}
7081
- ${color('primary')}
7539
+ ${color('danger')}
7082
7540
  ${cursor('pointer')}
7541
+ ${paddingTop('sm')}
7542
+ &.o-form-table-remove-disabled {
7543
+ ${color('light')}
7544
+ ${cursor('not-allowed')}
7545
+ }
7083
7546
  }
7084
7547
 
7085
7548
  .o-form-table-remove-cell {
7086
7549
  ${display('flex')}
7087
- ${alignItems('center')}
7550
+ ${alignItems('start')}
7088
7551
  ${justifyContent('center')}
7089
7552
  }
7553
+
7554
+ .o-checkbox-cell {
7555
+ ${display('flex')}
7556
+ ${justifyContent('center')}
7557
+ .o-table-checkbox {
7558
+ ${paddingTop('xs')}
7559
+ ${display('flex')}
7560
+ ${alignItems('start')}
7561
+ }
7562
+ }
7090
7563
  `;
7091
7564
  };
7092
7565
 
@@ -7130,6 +7603,7 @@ const useCheckboxColumn = (options) => {
7130
7603
  return Object.assign({
7131
7604
  filterable: false,
7132
7605
  sortable: false,
7606
+ className: 'o-checkbox-cell',
7133
7607
  }, options, {
7134
7608
  CellComponent: Component(options),
7135
7609
  });
@@ -7199,37 +7673,165 @@ const useLinkColumn = (options) => {
7199
7673
  const SelectCellComponent = (options, broker) => {
7200
7674
  const SelectCellComponent = ({ item, column, rowIndex }) => {
7201
7675
  const { tableName } = useFormTableContext();
7202
- const controller = useSelectController(options.dataSource, Object.assign({}, options, broker.getInitialQuery()));
7676
+ const controller = useSelectController(options.dataSource, options);
7677
+ const service = controller.asService();
7203
7678
  const className = typeof options.className === 'function' ? options.className(item, column, rowIndex) : options.className;
7679
+ const name = `${tableName}.${rowIndex}.${column.id}`;
7204
7680
  React.useEffect(() => {
7205
- broker.addSubscriber(controller);
7681
+ broker.addSubscriber(name, service);
7206
7682
  return () => {
7207
- broker.removeSubscriber(controller);
7683
+ broker.removeSubscriber(name);
7208
7684
  };
7209
- }, [controller]);
7210
- return (React__default["default"].createElement(FormSelect, { size: "small", layout: "table", ...options, name: `${tableName}.${rowIndex}.${column.id}`, className: addClassname('o-table-select', className) }));
7685
+ }, [name, service]);
7686
+ return (React__default["default"].createElement(FormSelect, { size: "small", layout: "table", ...options, name: name, className: addClassname('o-table-select', className), controller: controller }));
7211
7687
  };
7212
7688
  SelectCellComponent.displayName = 'SelectCellComponent';
7213
7689
  return SelectCellComponent;
7214
7690
  };
7215
7691
 
7216
7692
  const useSelectColumn = (options) => {
7693
+ const opts = Object.assign({}, options, { brokerable: true });
7217
7694
  const broker = onekijsFramework.useLazyRef(() => {
7218
- return new onekijsFramework.DefaultCollectionBroker();
7695
+ return new DefaultSelectBroker(opts.dataSource, opts);
7219
7696
  });
7220
- const Component = options.CellComponent || SelectCellComponent;
7697
+ const Component = opts.CellComponent || SelectCellComponent;
7221
7698
  const optionsRef = onekijsFramework.useLazyRef(() => {
7222
7699
  return Object.assign({
7223
7700
  filterable: false,
7224
7701
  sortable: false,
7225
- }, options, {
7226
- CellComponent: Component(options, broker.current),
7702
+ }, opts, {
7703
+ CellComponent: Component(opts, broker.current),
7227
7704
  broker: broker.current,
7228
7705
  });
7229
7706
  });
7230
7707
  return optionsRef.current;
7231
7708
  };
7232
7709
 
7710
+ const TextareaComponent = (props) => {
7711
+ const { className, size = 'medium', status, onFocus: forwardFocus, onBlur: forwardBlur, ...textareaProps } = props;
7712
+ const [focus, setFocus] = React.useState(false);
7713
+ const classNames = addClassname(`o-textarea o-textarea-size-${size}${focus ? ' o-textarea-focus' : ''}${status ? ' o-textarea-status-' + status.toLowerCase() : ''}`, className);
7714
+ const onFocus = (e) => {
7715
+ setFocus(true);
7716
+ forwardFocus && forwardFocus(e);
7717
+ };
7718
+ const onBlur = (e) => {
7719
+ setFocus(false);
7720
+ forwardBlur && forwardBlur(e);
7721
+ };
7722
+ return (React__default["default"].createElement("div", { className: classNames },
7723
+ React__default["default"].createElement("textarea", { className: "o-textarea-field", ...textareaProps, onFocus: onFocus, onBlur: onBlur })));
7724
+ };
7725
+ TextareaComponent.displayName = 'TextareaComponent';
7726
+
7727
+ const textareaStyle = ({ theme, disabled }) => {
7728
+ const t = theme.textarea;
7729
+ return styled.css `
7730
+ ${boxSizing('border-box')}
7731
+ ${width(t.width)}
7732
+ ${backgroundColor(disabled ? 'lighter' : t.bgColor)}
7733
+ ${display('flex')}
7734
+ ${alignItems('center')}
7735
+ ${borderWidth(t.borderWidth)}
7736
+ ${borderColor(t.borderColor)}
7737
+ ${borderRadius(t.borderRadius)}
7738
+ ${borderStyle(t.borderStyle)}
7739
+ ${padding('1px')}
7740
+ ${cursor(disabled ? 'not-allowed' : 'auto')}
7741
+ textarea {
7742
+ ${cursor(disabled ? 'not-allowed' : 'auto')}
7743
+ }
7744
+ &.o-textarea-focus {
7745
+ ${borderColor(t.borderFocusColor)}
7746
+ ${borderWidth(t.borderFocusWidth)}
7747
+ ${padding(0)}
7748
+ }
7749
+ .o-textarea-field {
7750
+ ${width('full')}
7751
+ ${flexGrow(1)}
7752
+ ${paddingX(t.paddingX)}
7753
+ ${paddingY(t.paddingY)}
7754
+ ${appearance(t.appearance)}
7755
+ ${outline(t.outline)}
7756
+ ${borderWidth(0)}
7757
+ ${backgroundColor('inherit')}
7758
+ ${color(t.fontColor, { placeholder: t.placeholderColor })}
7759
+ }
7760
+
7761
+ &.o-textarea-size-xsmall textarea {
7762
+ ${paddingY(0)}
7763
+ ${fontSize('sm')}
7764
+ }
7765
+ &.o-textarea-size-small textarea {
7766
+ ${paddingY('xs')}
7767
+ ${fontSize('sm')}
7768
+ }
7769
+ &.o-textarea-size-medium textarea {
7770
+ ${paddingY('sm')}
7771
+ ${fontSize('default')}
7772
+ }
7773
+
7774
+ &.o-textarea-size-large textarea {
7775
+ ${paddingY('md')}
7776
+ ${fontSize('default')}
7777
+ }
7778
+
7779
+ &.o-textarea-size-xlarge textarea {
7780
+ ${paddingY('lg')}
7781
+ ${fontSize('lg')}
7782
+ }
7783
+
7784
+ &.o-textarea-status-error {
7785
+ ${borderColor('danger')}
7786
+ }
7787
+
7788
+ &.o-textarea-status-warning {
7789
+ ${borderColor('warning')}
7790
+ }
7791
+
7792
+ &.o-textarea-status-success {
7793
+ ${borderColor('success')}
7794
+ }
7795
+ `;
7796
+ };
7797
+
7798
+ const Textarea = styled__default["default"](TextareaComponent) `
7799
+ ${textareaStyle}
7800
+ `;
7801
+
7802
+ const FormTextarea = React__default["default"].memo((props) => {
7803
+ const [fieldLayoutProps, fieldComponentProps] = useFieldLayout(Object.assign({
7804
+ defaultValue: props.defaultValue === undefined ? '' : props.defaultValue,
7805
+ }, props));
7806
+ const Component = props.FieldComponent || Textarea;
7807
+ return (React__default["default"].createElement(FieldLayout, { ...fieldLayoutProps, required: props.required },
7808
+ React__default["default"].createElement(Component, { ...fieldComponentProps, value: !fieldComponentProps.value ? '' : fieldComponentProps.value })));
7809
+ });
7810
+ FormTextarea.displayName = 'FormTextarea';
7811
+
7812
+ const TextareaCellComponent = (options) => {
7813
+ const TextareaCellComponent = ({ item, column, rowIndex }) => {
7814
+ const { tableName } = useFormTableContext();
7815
+ const className = typeof options.className === 'function' ? options.className(item, column, rowIndex) : options.className;
7816
+ return (React__default["default"].createElement(FormTextarea, { size: "small", layout: "table", ...options, name: `${tableName}.${rowIndex}.${column.id}`, className: addClassname('o-table-textarea', className) }));
7817
+ };
7818
+ TextareaCellComponent.displayName = 'TextareaCellComponent';
7819
+ return TextareaCellComponent;
7820
+ };
7821
+
7822
+ const useTextareaColumn = (options) => {
7823
+ const Component = options.CellComponent || TextareaCellComponent;
7824
+ const optionsRef = onekijsFramework.useLazyRef(() => {
7825
+ return Object.assign({
7826
+ filterable: false,
7827
+ sortable: false,
7828
+ }, options, {
7829
+ CellComponent: Component(options),
7830
+ });
7831
+ });
7832
+ return optionsRef.current;
7833
+ };
7834
+
7233
7835
  const RemoveIcon = ({ className, onClick }) => {
7234
7836
  return (React__default["default"].createElement("div", { className: className, onClick: onClick },
7235
7837
  React__default["default"].createElement("svg", { version: "1.1", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", viewBox: "0 0 16 16", width: "100%", height: "100%" },
@@ -7249,12 +7851,12 @@ const DeleteRowComponent = ({ rowIndex }) => {
7249
7851
  const form = onekijsFramework.useForm();
7250
7852
  const { tableName, minLength = 0, required } = useFormTableContext();
7251
7853
  const removeRow = () => {
7252
- form.remove(tableName, rowIndex);
7854
+ if (rowIndex >= min) {
7855
+ form.remove(tableName, rowIndex);
7856
+ }
7253
7857
  };
7254
7858
  const min = Math.max(minLength, required ? 1 : 0);
7255
- if (rowIndex < min)
7256
- return null;
7257
- return (React__default["default"].createElement("div", { className: "o-form-table-remove", onClick: removeRow },
7859
+ return (React__default["default"].createElement("div", { className: `o-form-table-remove${rowIndex < min ? ' o-form-table-remove-disabled' : ''}`, onClick: removeRow },
7258
7860
  React__default["default"].createElement(RemoveIcon$1, { width: "14px", height: "14px" })));
7259
7861
  };
7260
7862
  const SelectRowComponent = ({ item }) => {
@@ -7279,6 +7881,7 @@ const FooterComponent = () => {
7279
7881
  };
7280
7882
  const FormTableComponent = React__default["default"].memo(({ addLabel = 'add', controller, value, onChange, className, name, format = 'auto', required, minLength, maxLength, ...props }) => {
7281
7883
  const form = onekijsFramework.useForm();
7884
+ const id = React.useId();
7282
7885
  const tableService = controller.asService();
7283
7886
  const formatRef = onekijsFramework.useLazyRef(() => {
7284
7887
  if (format === 'auto') {
@@ -7286,6 +7889,7 @@ const FormTableComponent = React__default["default"].memo(({ addLabel = 'add', c
7286
7889
  }
7287
7890
  return format;
7288
7891
  });
7892
+ const [mounted, setMounted] = React.useState(false);
7289
7893
  const formTableContext = onekijsFramework.useLazyRef(() => {
7290
7894
  const onSelect = (item, selected) => {
7291
7895
  const getId = (v) => {
@@ -7302,14 +7906,27 @@ const FormTableComponent = React__default["default"].memo(({ addLabel = 'add', c
7302
7906
  };
7303
7907
  return { tableName: name, onSelect, addLabel, required, minLength, maxLength };
7304
7908
  });
7909
+ // listen on value change from the form
7910
+ // for the initial value in the table controller
7911
+ // delay the rendering of the table until the value has been set in the controller
7305
7912
  React.useEffect(() => {
7306
- if (tableService.dataSource) {
7307
- tableService.setSelected('value', value || []);
7308
- }
7309
- else if (value !== undefined) {
7310
- tableService.setData(value);
7311
- }
7312
- }, [tableService, value, formatRef]);
7913
+ const watch = [name];
7914
+ const listener = (value) => {
7915
+ if (tableService.dataSource) {
7916
+ tableService.setSelected('value', value || []);
7917
+ }
7918
+ else if (value !== undefined) {
7919
+ tableService.setData(value);
7920
+ }
7921
+ };
7922
+ form.onValueChange(id, listener, watch);
7923
+ listener(value);
7924
+ setMounted(true);
7925
+ return () => {
7926
+ form.offValueChange(id);
7927
+ };
7928
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7929
+ }, []);
7313
7930
  React.useEffect(() => {
7314
7931
  if (tableService.dataSource) {
7315
7932
  tableService.addColumn({
@@ -7331,6 +7948,8 @@ const FormTableComponent = React__default["default"].memo(({ addLabel = 'add', c
7331
7948
  }, 0);
7332
7949
  }
7333
7950
  }, [tableService]);
7951
+ if (!mounted)
7952
+ return null;
7334
7953
  return (React__default["default"].createElement(DefaultFormTableContext.Provider, { value: formTableContext.current },
7335
7954
  React__default["default"].createElement(ControllerTableComponent, { controller: controller, className: addClassname('o-form-table', className), FooterComponent: tableService.dataSource ? undefined : FooterComponent, footer: tableService.dataSource ? false : true, NotFoundComponent: null, ...props })));
7336
7955
  });
@@ -7398,6 +8017,29 @@ const Tag = styled__default["default"](TagComponent) `
7398
8017
  ${tagStyle}
7399
8018
  `;
7400
8019
 
8020
+ const defaultTreeQueryEngine = (items, query, comparator, comparators, searcher) => {
8021
+ let result = [];
8022
+ if (!query.filter) {
8023
+ // remove all children of non expanded items
8024
+ let visible = 1;
8025
+ items.forEach((item) => {
8026
+ if (item.level <= visible) {
8027
+ result.push(item);
8028
+ if (item.expanded) {
8029
+ visible = item.level + 1;
8030
+ }
8031
+ else {
8032
+ visible = item.level;
8033
+ }
8034
+ }
8035
+ });
8036
+ }
8037
+ else {
8038
+ result = items;
8039
+ }
8040
+ return onekijsFramework.defaultQueryEngine(result, query, comparator, comparators, searcher);
8041
+ };
8042
+
7401
8043
  let TreeService = class TreeService extends onekijsFramework.CollectionService {
7402
8044
  adapt(data) {
7403
8045
  return this._adapt(data);
@@ -7578,27 +8220,8 @@ let TreeService = class TreeService extends onekijsFramework.CollectionService {
7578
8220
  yield delay(delay_ms);
7579
8221
  yield this.setMeta('item', item, 'loadingStatus', onekijsFramework.LoadingStatus.Loading);
7580
8222
  }
7581
- _execute(items, query, comparator, comparators) {
7582
- let result = [];
7583
- if (!query.filter) {
7584
- // remove all children of non expanded items
7585
- let visible = 1;
7586
- items.forEach((item) => {
7587
- if (item.level <= visible) {
7588
- result.push(item);
7589
- if (item.expanded) {
7590
- visible = item.level + 1;
7591
- }
7592
- else {
7593
- visible = item.level;
7594
- }
7595
- }
7596
- });
7597
- }
7598
- else {
7599
- result = items;
7600
- }
7601
- return super._execute(result, query, comparator, comparators);
8223
+ _execute(items, query, comparator, comparators, searcher) {
8224
+ return defaultTreeQueryEngine(items, query, comparator, comparators, searcher);
7602
8225
  }
7603
8226
  _expand(item) {
7604
8227
  this.setMeta('item', item, 'expanded', true);
@@ -8654,7 +9277,7 @@ const useStep = (props) => {
8654
9277
  return step;
8655
9278
  };
8656
9279
 
8657
- const Step = ({ title, active = false, disabled = false, visible = true, closable = false, children, icon, uid, optional = false, showTitle = true, }) => {
9280
+ const Step = ({ title, active = false, disabled = false, visible = true, closable = false, children, icon, uid, optional = false, showTitle = true, className, }) => {
8658
9281
  const { animate, forwardOnly } = useWizardState();
8659
9282
  const service = useWizardService();
8660
9283
  const step = useStep({
@@ -8671,7 +9294,7 @@ const Step = ({ title, active = false, disabled = false, visible = true, closabl
8671
9294
  uid: uid === undefined ? title : uid,
8672
9295
  });
8673
9296
  const fieldContainer = onekijsFramework.useFieldContainer({
8674
- onValidationChange: (_field, _validation, touchedValidation, allValidation) => {
9297
+ onValidationChange: (touchedValidation, allValidation) => {
8675
9298
  if (step) {
8676
9299
  service.onValidationChange(step.uid, touchedValidation, allValidation);
8677
9300
  }
@@ -8698,7 +9321,7 @@ const Step = ({ title, active = false, disabled = false, visible = true, closabl
8698
9321
  }
8699
9322
  return (React__default["default"].createElement(onekijsFramework.FormContext.Provider, { value: fieldContainer.context },
8700
9323
  React__default["default"].createElement(reactTransitionGroup.CSSTransition, { in: true, timeout: animate, appear: true, onEnter: onEnter, onEntering: onEntering },
8701
- React__default["default"].createElement("div", { className: "o-step-content" },
9324
+ React__default["default"].createElement("div", { className: addClassname('o-step-content', className) },
8702
9325
  showTitle && React__default["default"].createElement("div", { className: "o-step-content-title" }, title),
8703
9326
  children))));
8704
9327
  };
@@ -8768,6 +9391,13 @@ const listStylePosition = cssProperty('list-style-position');
8768
9391
  // disc; circle; square; decimal; georgian; cjk-ideographic; kannada; any string
8769
9392
  const listStyleType = cssProperty('list-style-type');
8770
9393
 
9394
+ const perspective = cssProperty('perspective');
9395
+ const perspectiveOrigin = cssProperty('perspective-origin');
9396
+ const rotate = cssProperty('rotate');
9397
+ const scale = cssProperty('scale');
9398
+ const transform = cssProperty('transform');
9399
+ const transformOrigin = cssProperty('transform-origin');
9400
+
8771
9401
  exports.ColorKeys = void 0;
8772
9402
  (function (ColorKeys) {
8773
9403
  ColorKeys["white"] = "white";
@@ -9158,7 +9788,7 @@ const baseTheme = (customTheme = {}) => {
9158
9788
  thBorderBottomColor: 'lightest',
9159
9789
  thBgColor: 'lightest',
9160
9790
  thFontWeigth: 'semibold',
9161
- thFontColor: 'darker',
9791
+ thFontColor: 'primary',
9162
9792
  thFontCase: 'uppercase',
9163
9793
  thFontSize: 'xs',
9164
9794
  thLetterSpacing: 'xl',
@@ -9210,6 +9840,37 @@ const baseTheme = (customTheme = {}) => {
9210
9840
  fontColor: 'darkest',
9211
9841
  placeholderColor: 'light',
9212
9842
  },
9843
+ textarea: {
9844
+ bgColor: 'white',
9845
+ width: 'full',
9846
+ borderWidth: 1,
9847
+ borderColor: 'light',
9848
+ borderRadius: 'sm',
9849
+ borderStyle: 'solid',
9850
+ borderFocusColor: 'primary',
9851
+ borderFocusWidth: 2,
9852
+ paddingX: 'sm',
9853
+ paddingY: 'xs',
9854
+ xsPaddingX: 'sm',
9855
+ xsPaddingY: 0,
9856
+ xsFontSize: 'sm',
9857
+ smPaddingX: 'sm',
9858
+ smPaddingY: 'xs',
9859
+ smFontSize: 'sm',
9860
+ mdPaddingX: 'sm',
9861
+ mdPaddingY: 'sm',
9862
+ mdFontSize: 'default',
9863
+ lgPaddingX: 'sm',
9864
+ lgPaddingY: 'md',
9865
+ lgFontSize: 'default',
9866
+ xlPaddingX: 'sm',
9867
+ xlPaddingY: 'lg',
9868
+ xlFontSize: 'lg',
9869
+ appearance: 'none',
9870
+ outline: 'none',
9871
+ fontColor: 'darkest',
9872
+ placeholderColor: 'light',
9873
+ },
9213
9874
  label: {
9214
9875
  fontWeight: 'medium',
9215
9876
  fontCase: 'none',
@@ -9564,6 +10225,7 @@ exports.Card = Card;
9564
10225
  exports.CardComponent = CardComponent;
9565
10226
  exports.CardTitle = CardTitle;
9566
10227
  exports.Checkbox = Checkbox;
10228
+ exports.CheckboxCellComponent = CheckboxCellComponent;
9567
10229
  exports.CheckboxComponent = CheckboxComponent;
9568
10230
  exports.CloseAllIcon = CloseAllIcon;
9569
10231
  exports.Col = Col;
@@ -9582,9 +10244,12 @@ exports.DashboardRight = DashboardRight;
9582
10244
  exports.DashboardServiceContext = DashboardServiceContext;
9583
10245
  exports.DashboardStateContext = DashboardStateContext;
9584
10246
  exports.DashboardToggler = DashboardToggler;
10247
+ exports.DefaultCellComponent = DefaultCellComponent;
10248
+ exports.DefaultSelectBroker = DefaultSelectBroker;
9585
10249
  exports.Dropdown = Dropdown;
9586
10250
  exports.DropdownButton = DropdownButton;
9587
10251
  exports.DropdownComponent = DropdownComponent;
10252
+ exports.ExpandedCellComponent = ExpandedCellComponent;
9588
10253
  exports.FieldDescription = FieldDescription;
9589
10254
  exports.FieldDescriptionComponent = FieldDescriptionComponent;
9590
10255
  exports.FieldHelp = Help;
@@ -9598,7 +10263,9 @@ exports.FormCheckbox = FormCheckbox;
9598
10263
  exports.FormInput = FormInput;
9599
10264
  exports.FormSelect = FormSelect;
9600
10265
  exports.FormTable = FormTable;
10266
+ exports.FormTextarea = FormTextarea;
9601
10267
  exports.Input = Input;
10268
+ exports.InputCellComponent = InputCellComponent;
9602
10269
  exports.InputComponent = InputComponent;
9603
10270
  exports.Label = Label;
9604
10271
  exports.List = List;
@@ -9615,10 +10282,13 @@ exports.Property = Property;
9615
10282
  exports.Row = Row;
9616
10283
  exports.SearchIcon = SearchIcon;
9617
10284
  exports.Select = Select;
10285
+ exports.SelectCellComponent = SelectCellComponent;
9618
10286
  exports.SelectComponent = SelectComponent;
9619
10287
  exports.SelectIconComponent = SelectIconComponent;
9620
10288
  exports.SelectInputComponent = SelectInputComponent;
10289
+ exports.SelectNotFoundComponent = SelectNotFoundComponent;
9621
10290
  exports.SelectOptionComponent = SelectOptionComponent;
10291
+ exports.SelectService = SelectService$1;
9622
10292
  exports.SelectTokensComponent = SelectTokensComponent;
9623
10293
  exports.Step = Step;
9624
10294
  exports.StepTitle = StepTitle;
@@ -9630,6 +10300,9 @@ exports.Tabs = Tabs;
9630
10300
  exports.Tag = Tag;
9631
10301
  exports.TagComponent = TagComponent;
9632
10302
  exports.TailwindTheme = TailwindTheme;
10303
+ exports.Textarea = Textarea;
10304
+ exports.TextareaCellComponent = TextareaCellComponent;
10305
+ exports.TextareaComponent = TextareaComponent;
9633
10306
  exports.TogglerIcon = TogglerIcon;
9634
10307
  exports.Tooltip = Tooltip;
9635
10308
  exports.Tree = Tree;
@@ -9748,6 +10421,7 @@ exports.cssProperty = cssProperty;
9748
10421
  exports.cursor = cursor;
9749
10422
  exports.darken = darken;
9750
10423
  exports.dashboardOverlayStyle = dashboardOverlayStyle;
10424
+ exports.defaultTreeQueryEngine = defaultTreeQueryEngine;
9751
10425
  exports.deriveColor = deriveColor;
9752
10426
  exports.display = display;
9753
10427
  exports.dropdownButtonStyle = dropdownButtonStyle;
@@ -9755,6 +10429,8 @@ exports.dropdownStyle = dropdownStyle;
9755
10429
  exports.emptyCells = emptyCells;
9756
10430
  exports.enumFormatter = enumFormatter;
9757
10431
  exports.fill = fill;
10432
+ exports.findSelectItem = findSelectItem;
10433
+ exports.findSelectItemIndex = findSelectItemIndex;
9758
10434
  exports.flex = flex;
9759
10435
  exports.flexBasis = flexBasis;
9760
10436
  exports.flexDirection = flexDirection;
@@ -9877,6 +10553,7 @@ exports.rowGap = rowGap;
9877
10553
  exports.rowStyle = rowStyle;
9878
10554
  exports.sameWidthPopperModifier = sameWidthPopperModifier;
9879
10555
  exports.scale = scale;
10556
+ exports.shouldCheckSelect = shouldCheckSelect;
9880
10557
  exports.stroke = stroke;
9881
10558
  exports.strokeWidth = strokeWidth;
9882
10559
  exports.tableLayout = tableLayout;
@@ -9928,6 +10605,7 @@ exports.useListController = useListController;
9928
10605
  exports.useSelectColumn = useSelectColumn;
9929
10606
  exports.useSelectController = useSelectController;
9930
10607
  exports.useTableController = useTableController;
10608
+ exports.useTextareaColumn = useTextareaColumn;
9931
10609
  exports.useTreeConfig = useTreeConfig;
9932
10610
  exports.useTreeController = useTreeController;
9933
10611
  exports.useTreeInitialState = useTreeInitialState;