onekijs-ui 0.15.5 → 0.15.7

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 (34) hide show
  1. package/dist/components/list/components/StandardListComponent.d.ts +0 -1
  2. package/dist/components/select/SelectService.d.ts +1 -1
  3. package/dist/components/select/TreeSelectService.d.ts +3 -2
  4. package/dist/components/select/components/ControlledSelectComponent.d.ts +1 -1
  5. package/dist/components/select/typings.d.ts +3 -1
  6. package/dist/components/tree/TreeService.d.ts +1 -1
  7. package/dist/components/wizard/components/FormStep.d.ts +4 -0
  8. package/dist/components/wizard/typings.d.ts +3 -0
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +131 -106
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.module.js +131 -107
  13. package/dist/index.module.js.map +1 -1
  14. package/dist/styles/size.d.ts +6 -6
  15. package/dist/styles/typography.d.ts +1 -1
  16. package/package.json +3 -3
  17. package/src/components/field/util.ts +1 -1
  18. package/src/components/list/components/StandardListComponent.tsx +2 -2
  19. package/src/components/select/SelectService.ts +1 -1
  20. package/src/components/select/TreeSelectService.ts +5 -4
  21. package/src/components/select/components/ControlledSelectComponent.tsx +8 -5
  22. package/src/components/select/typings.ts +3 -1
  23. package/src/components/table/FormTable.tsx +10 -1
  24. package/src/components/table/components/FormTableComponent.tsx +3 -1
  25. package/src/components/table/components/TableBodyCellComponent.tsx +1 -1
  26. package/src/components/table/components/cells/CheckboxCellComponent.tsx +4 -15
  27. package/src/components/table/components/cells/InputCellComponent.tsx +5 -1
  28. package/src/components/table/components/cells/SelectCellComponent.tsx +4 -1
  29. package/src/components/table/components/cells/TextareaCellComponent.tsx +4 -1
  30. package/src/components/tree/TreeService.ts +3 -3
  31. package/src/components/wizard/components/FormStep.tsx +26 -0
  32. package/src/components/wizard/components/WizardContainer.tsx +2 -0
  33. package/src/components/wizard/typings.ts +4 -0
  34. package/src/index.ts +1 -0
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ListItem, StandardListProps } from '../typings';
3
2
  declare const StandardListComponent: <T = any, I extends ListItem<T> = ListItem<T>>({ items, ItemComponent, ItemLoadingComponent, ItemContentComponent, onItemClick, onItemMouseEnter, onItemMouseLeave, }: StandardListProps<T, I>) => JSX.Element;
4
3
  export default StandardListComponent;
@@ -9,7 +9,7 @@ declare class SelectService<T = any, I extends SelectItem<T> = SelectItem<T>, S
9
9
  setDefaultValue(value: T | T[] | null | undefined): Generator<void | Generator<void | import("redux-saga/effects").AllEffect<import("redux-saga/effects").CallEffect<Generator<I[] | Generator<void | AnonymousObject<any>, CollectionFetcherResult<T>, (import("redux-saga").Task<any> | null) & CollectionFetcherResult<T> & (CollectionFetcherResult<T> | undefined)>, I | undefined, I[] & CollectionFetcherResult<T>>>> | import("redux-saga/effects").AllEffect<Generator<I[] | Generator<void | AnonymousObject<any>, CollectionFetcherResult<T>, (import("redux-saga").Task<any> | null) & CollectionFetcherResult<T> & (CollectionFetcherResult<T> | undefined)>, I | undefined, I[] & CollectionFetcherResult<T>>> | import("redux-saga/effects").CallEffect<void>, void, (I | undefined)[]>, void, unknown>;
10
10
  setValue(value: null | T | T[]): void;
11
11
  setUrl(url: string, query?: Query): void;
12
- _buildItem(data: T | undefined, adaptee: unknown, context?: AnonymousObject): I;
12
+ _buildItem(data: T | null | undefined, adaptee: unknown, context?: AnonymousObject): I;
13
13
  _filterItem(item: I | undefined, query: Query, valid: boolean): Generator<I[] | Generator<void | AnonymousObject<any>, CollectionFetcherResult<T>, (import("redux-saga").Task<any> | null) & CollectionFetcherResult<T> & (CollectionFetcherResult<T> | undefined)>, I | undefined, I[] & CollectionFetcherResult<T>>;
14
14
  _setDefaultValue(value: T | T[] | null | undefined): void;
15
15
  _setValidDefaultValue(value: T | T[] | null): void;
@@ -1,8 +1,9 @@
1
+ import { CollectionService } from 'onekijs-framework';
1
2
  import TreeService from '../tree/TreeService';
2
3
  import SelectService from './SelectService';
3
4
  import { TreeSelectItem, TreeSelectState } from './typings';
4
- declare class TreeSelectService<T = any, I extends TreeSelectItem<T> = TreeSelectItem<T>, S extends TreeSelectState<T, I> = TreeSelectState<T, I>> extends SelectService<T, I, S> {
5
+ declare class TreeSelectService<T = any, I extends TreeSelectItem<T> = TreeSelectItem<T>, S extends TreeSelectState<T, I> = TreeSelectState<T, I>> extends CollectionService<T, I, S> {
5
6
  }
6
- interface TreeSelectService<T = any, I extends TreeSelectItem<T> = TreeSelectItem<T>, S extends TreeSelectState<T, I> = TreeSelectState<T, I>> extends TreeService<T, I, S> {
7
+ interface TreeSelectService<T = any, I extends TreeSelectItem<T> = TreeSelectItem<T>, S extends TreeSelectState<T, I> = TreeSelectState<T, I>> extends SelectService<T, I, S>, TreeService<T, I, S> {
7
8
  }
8
9
  export default TreeSelectService;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { ControllerSelectProps, SelectController, SelectItem, SelectState } from '../typings';
3
- declare const ControlledSelectComponent: <T = any, I extends SelectItem<T> = SelectItem<T>, S extends SelectState<T, I> = SelectState<T, I>, C extends SelectController<T, I, S> = SelectController<T, I, S>>({ attachDropdownToBody, className, placeholder, controller, InputComponent, IconComponent, OptionContentComponent, OptionComponent, OptionLoadingComponent, MultiOptionsComponent, NotFoundComponent, autoFocus, value, onChange, onBlur: forwardBlur, onFocus: forwardFocus, height, multiple, status, size, nullable, minChars, openOnFocus, searchable, dropdownWidthModifier, preload, increment, animationMs, disabled, defaultValue, required, sameWidth, overscan, clickable, ListComponent, }: ControllerSelectProps<T, I, S, C>) => JSX.Element;
3
+ declare const ControlledSelectComponent: <T = any, I extends SelectItem<T> = SelectItem<T>, S extends SelectState<T, I> = SelectState<T, I>, C extends SelectController<T, I, S> = SelectController<T, I, S>>({ attachDropdownToBody, className, placeholder, controller, InputComponent, IconComponent, OptionContentComponent, OptionComponent, OptionLoadingComponent, MultiOptionsComponent, NotFoundComponent, autoFocus, value, onChange, onBlur: forwardBlur, onFocus: forwardFocus, height, multiple, status, size, nullable, minChars, openOnFocus, searchable, dropdownWidthModifier, preload, increment, animationMs, disabled, defaultValue, required, sameWidth, overscan, clickable, ListComponent, autoCompleteSearch, }: ControllerSelectProps<T, I, S, C>) => JSX.Element;
4
4
  export default ControlledSelectComponent;
@@ -21,7 +21,7 @@ export declare type FormSelectProps<T = any, I extends SelectItem<T> = SelectIte
21
21
  defaultValue?: T | T[] | null;
22
22
  FieldComponent?: React.FC<SelectProps<T, I>>;
23
23
  };
24
- export declare type SelectController<T, I extends SelectItem<T> = SelectItem<T>, S extends SelectState<T, I> = SelectState<T, I>> = Collection<T, I, S> & {
24
+ export declare type SelectController<T = any, I extends SelectItem<T> = SelectItem<T>, S extends SelectState<T, I> = SelectState<T, I>> = Collection<T, I, S> & {
25
25
  config?: SelectConfig<T, I>;
26
26
  check: () => void;
27
27
  defaultValue: T | T[] | null | undefined;
@@ -50,6 +50,7 @@ export interface SelectInputProps<T = any, I extends SelectItem<T> = SelectItem<
50
50
  searchable: boolean;
51
51
  clickable: boolean;
52
52
  minChars: number;
53
+ autoCompleteSearch: boolean;
53
54
  }
54
55
  export declare type SelectGroup = string | {
55
56
  text: string;
@@ -110,6 +111,7 @@ export declare type SelectConfig<T = any, I extends SelectItem<T> = SelectItem<T
110
111
  required?: boolean;
111
112
  sameWidth?: boolean;
112
113
  ListComponent?: React.FC<SelectListComponentProps<T, I>>;
114
+ autoCompleteSearch?: boolean;
113
115
  };
114
116
  export declare type SelectListComponentProps<T = any, I extends SelectItem<T> = SelectItem<T>> = CollectionListProps<T, I> & {
115
117
  optionsRef: React.RefObject<HTMLDivElement>;
@@ -12,7 +12,7 @@ declare class TreeService<T = any, I extends TreeItem<T> = TreeItem<T>, S extend
12
12
  initDb(dataSource: T[] | string | undefined): void;
13
13
  _adapt(data: T | null | undefined, context?: AnonymousObject): I;
14
14
  _addFilterExpanded(item: I): void;
15
- _buildItem(data: T | undefined, adaptee: unknown, context?: AnonymousObject): I;
15
+ _buildItem(data: T | null | undefined, adaptee: unknown, context?: AnonymousObject): I;
16
16
  _clearFilterExpanded(): void;
17
17
  _delayChildrenLoading(delay_ms: number, item: I): Generator<I[] | import("redux-saga/effects").CallEffect<true>, void, unknown>;
18
18
  _execute(items: I[], query: LocalQuery, comparator: QuerySortComparator, comparators: AnonymousObject<QuerySortComparator>, searcher?: QuerySearcher<T>): I[];
@@ -0,0 +1,4 @@
1
+ import { FCC } from 'onekijs-framework';
2
+ import { FormStepProps } from '../typings';
3
+ declare const FormCard: FCC<FormStepProps>;
4
+ export default FormCard;
@@ -11,6 +11,9 @@ export declare type StepProps = TabProps & {
11
11
  optional?: boolean;
12
12
  showTitle?: boolean;
13
13
  };
14
+ export declare type FormStepProps = StepProps & {
15
+ name: string;
16
+ };
14
17
  export declare type StepState = TabState & {
15
18
  optional: boolean;
16
19
  };
package/dist/index.d.ts CHANGED
@@ -31,6 +31,7 @@ export { default as DashboardRight } from './components/dashboard/components/Das
31
31
  export { default as DashboardToggler } from './components/dashboard/components/DashboardToggler';
32
32
  export { DashboardService } from './components/dashboard/DashboardService';
33
33
  export { default as useDashboard } from './components/dashboard/hooks/useDashboard';
34
+ export { default as FormStep } from './components/wizard/components/FormStep';
34
35
  export { useDashboardHorizontalPanel, useDashboardVerticalPanel, useDashoardBodyPanel, } from './components/dashboard/hooks/useDashboardPanel';
35
36
  export { DashboardServiceContext, default as useDashboardService, } from './components/dashboard/hooks/useDashboardService';
36
37
  export { DashboardStateContext, default as useDashboardState } from './components/dashboard/hooks/useDashboardState';
package/dist/index.js CHANGED
@@ -1557,7 +1557,7 @@ const Card = styled__default["default"](CardComponent) `
1557
1557
  ${cardStyle}
1558
1558
  `;
1559
1559
 
1560
- const FormCard = ({ name, disabled, visible, ...cardProps }) => {
1560
+ const FormCard$1 = ({ name, disabled, visible, ...cardProps }) => {
1561
1561
  const decorator = onekijsFramework.useFormDecorator(name);
1562
1562
  const form = onekijsFramework.useForm();
1563
1563
  const metadata = onekijsFramework.useFormMetadata(decorator.name);
@@ -2139,7 +2139,7 @@ const extractFieldLayoutProps = (props) => {
2139
2139
  'lgLabelWidth',
2140
2140
  'xlLabelWidth',
2141
2141
  ];
2142
- const fieldOptionsKeys = ['defaultValue', 'touchedOn', 'disabled', 'visible'];
2142
+ const fieldOptionsKeys = ['defaultValue', 'touchedOn', 'disabled', 'visible', 'editable'];
2143
2143
  Object.keys(nonValidatorProps).forEach((k) => {
2144
2144
  if (fieldLayoutKeys.includes(k)) {
2145
2145
  fieldLayoutProps[k] = props[k];
@@ -3594,6 +3594,94 @@ const useDashboard = () => {
3594
3594
  return [DashboardRef.current, service];
3595
3595
  };
3596
3596
 
3597
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
3598
+ const WizardServiceContext = React__default["default"].createContext(null);
3599
+ const useWizardService = () => {
3600
+ return React.useContext(WizardServiceContext);
3601
+ };
3602
+
3603
+ const WizardStateContext = React__default["default"].createContext(null);
3604
+ const useWizardState = () => {
3605
+ return React.useContext(WizardStateContext);
3606
+ };
3607
+
3608
+ const useStep = (props) => {
3609
+ const service = useWizardService();
3610
+ const state = useWizardState();
3611
+ const step = state.members[state.membersIndex[props.uid]];
3612
+ React.useEffect(() => {
3613
+ if (step === undefined) {
3614
+ service.initMember(Object.assign({ uid: props.uid }, props));
3615
+ }
3616
+ }, [props, service, step]);
3617
+ return step;
3618
+ };
3619
+
3620
+ const Step = ({ title, active = false, disabled = false, visible = true, closable = false, children, icon, uid, optional = false, showTitle = true, className, }) => {
3621
+ const { animate, forwardOnly } = useWizardState();
3622
+ const service = useWizardService();
3623
+ const step = useStep({
3624
+ title,
3625
+ active,
3626
+ disabled,
3627
+ visible,
3628
+ closable,
3629
+ icon,
3630
+ loading: false,
3631
+ optional,
3632
+ touched: !forwardOnly,
3633
+ touching: !forwardOnly,
3634
+ uid: uid === undefined ? title : uid,
3635
+ });
3636
+ const fieldContainer = onekijsFramework.useFieldContainer({
3637
+ onValidationChange: (touchedValidation, allValidation) => {
3638
+ if (step) {
3639
+ service.onValidationChange(step.uid, touchedValidation, allValidation);
3640
+ }
3641
+ },
3642
+ });
3643
+ const touched = step?.touched;
3644
+ const touchAllFields = fieldContainer.touchAllFields;
3645
+ const onEnter = (node) => {
3646
+ node.style.opacity = '0';
3647
+ };
3648
+ const onEntering = (node) => {
3649
+ setTimeout(() => {
3650
+ node.style.opacity = '1';
3651
+ node.style.transition = `opacity ${animate}ms ease-in-out`;
3652
+ }, 0);
3653
+ };
3654
+ React.useEffect(() => {
3655
+ if (touched) {
3656
+ touchAllFields();
3657
+ }
3658
+ }, [touched, touchAllFields]);
3659
+ if (!step || !step.active) {
3660
+ return null;
3661
+ }
3662
+ return (React__default["default"].createElement(onekijsFramework.FormContext.Provider, { value: fieldContainer.context },
3663
+ React__default["default"].createElement(reactTransitionGroup.CSSTransition, { in: true, timeout: animate, appear: true, onEnter: onEnter, onEntering: onEntering },
3664
+ React__default["default"].createElement("div", { className: addClassname('o-step-content', className) },
3665
+ showTitle && React__default["default"].createElement("div", { className: "o-step-content-title" }, title),
3666
+ children))));
3667
+ };
3668
+
3669
+ const FormCard = ({ name, disabled, visible, ...stepProps }) => {
3670
+ const decorator = onekijsFramework.useFormDecorator(name);
3671
+ const metadata = onekijsFramework.useFormMetadata(decorator.name);
3672
+ const service = useWizardService();
3673
+ React.useEffect(() => {
3674
+ const step = service.getMember(name);
3675
+ if (step && metadata.visible !== undefined && step.visible !== metadata.visible) {
3676
+ metadata.visible ? service.show(name) : service.hide(name);
3677
+ }
3678
+ if (step && metadata.disabled !== undefined && step.disabled !== metadata.disabled) {
3679
+ metadata.disabled ? service.disable(name) : service.enable(name);
3680
+ }
3681
+ });
3682
+ return React__default["default"].createElement(Step, { ...stepProps, uid: name });
3683
+ };
3684
+
3597
3685
  const useDashboardHorizontalPanel = (area) => {
3598
3686
  const state = React.useContext(DashboardStateContext);
3599
3687
  return area === 'header' ? state.header : state.footer;
@@ -4557,7 +4645,7 @@ const StandardListComponent = ({ items, ItemComponent = ListItemComponent$1, Ite
4557
4645
  if (item?.loadingStatus === onekijsFramework.LoadingStatus.Loading) {
4558
4646
  return React__default["default"].createElement(ItemLoadingComponent, { key: `item-${index}` });
4559
4647
  }
4560
- if (!item || !item.data) {
4648
+ if (!item || onekijsFramework.isItemFetching(item)) {
4561
4649
  return null;
4562
4650
  }
4563
4651
  return (React__default["default"].createElement(ItemComponent, { key: `item-${index}`, index: index, item: item, data: item.data, onClick: onItemClick, onMouseEnter: onItemMouseEnter, onMouseLeave: onItemMouseLeave, ItemContentComponent: ItemContentComponent }));
@@ -6130,7 +6218,7 @@ const DefaultSelectListComponent = (props) => {
6130
6218
  });
6131
6219
  return (React__default["default"].createElement(ListBodyComponent, { ...props, className: "o-select-options", bodyRef: props.optionsRef, items: selectItems, totalSize: totalSize, virtualItems: isVirtual ? virtualItems : undefined, scrollToIndex: scrollToIndex, keyboardNavigable: true, service: props.controller?.asService(), state: props.controller.state }));
6132
6220
  };
6133
- const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '', placeholder, controller, InputComponent = SelectInputComponent$1, IconComponent, OptionContentComponent = SelectOptionContent, OptionComponent = SelectOptionComponent$1, OptionLoadingComponent = LoadingItem$1, MultiOptionsComponent = SelectOptionComponent$1, NotFoundComponent = SelectNotFoundComponent, autoFocus, value, onChange, onBlur: forwardBlur, onFocus: forwardFocus, height = 220, multiple = false, status = onekijsFramework.ValidationStatus.None, size = 'medium', nullable, minChars = 0, openOnFocus = false, searchable = true, dropdownWidthModifier = 'min', preload = 50, increment = 50, animationMs = 200, disabled, defaultValue, required = false, sameWidth = true, overscan, clickable = true, ListComponent = DefaultSelectListComponent, }) => {
6221
+ const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '', placeholder, controller, InputComponent = SelectInputComponent$1, IconComponent, OptionContentComponent = SelectOptionContent, OptionComponent = SelectOptionComponent$1, OptionLoadingComponent = LoadingItem$1, MultiOptionsComponent = SelectOptionComponent$1, NotFoundComponent = SelectNotFoundComponent, autoFocus, value, onChange, onBlur: forwardBlur, onFocus: forwardFocus, height = 220, multiple = false, status = onekijsFramework.ValidationStatus.None, size = 'medium', nullable, minChars = 0, openOnFocus = false, searchable = true, dropdownWidthModifier = 'min', preload = 50, increment = 50, animationMs = 200, disabled, defaultValue, required = false, sameWidth = true, overscan, clickable = true, ListComponent = DefaultSelectListComponent, autoCompleteSearch = true, }) => {
6134
6222
  if (nullable === undefined) {
6135
6223
  nullable = !required;
6136
6224
  }
@@ -6171,6 +6259,7 @@ const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '
6171
6259
  defaultValue,
6172
6260
  sameWidth,
6173
6261
  overscan,
6262
+ autoCompleteSearch,
6174
6263
  };
6175
6264
  const id = React.useId();
6176
6265
  const loading = onekijsFramework.isCollectionLoading(controller);
@@ -6190,7 +6279,7 @@ const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '
6190
6279
  return controller.getItem(controller.state.active[0]);
6191
6280
  }
6192
6281
  else if (focus && search) {
6193
- const item = findSelectItem(controller, search.toString());
6282
+ const item = autoCompleteSearch ? findSelectItem(controller, search.toString()) : controller.items[0];
6194
6283
  if (item === undefined && !onekijsFramework.isCollectionFetching(controller)) {
6195
6284
  return onekijsFramework.get(controller, 'items.0');
6196
6285
  }
@@ -6202,7 +6291,7 @@ const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '
6202
6291
  if (!multiple) {
6203
6292
  return controller.adapt(value);
6204
6293
  }
6205
- }, [focus, controller, value, multiple]);
6294
+ }, [focus, controller, value, multiple, autoCompleteSearch]);
6206
6295
  const optionsRef = React.useRef(null);
6207
6296
  const update = React.useCallback(() => {
6208
6297
  if (optionsRef.current && onekijsFramework.get(service, 'config.sameWidth')) {
@@ -6288,7 +6377,7 @@ const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '
6288
6377
  React.useEffect(() => {
6289
6378
  const search = controller.getSearch();
6290
6379
  if (open && focus && search && search !== previousSearchRef.current) {
6291
- const item = findSelectItem(controller, search.toString());
6380
+ const item = autoCompleteSearch ? findSelectItem(controller, search.toString()) : controller.items[0];
6292
6381
  const activated = onekijsFramework.get(controller.state.active, '0');
6293
6382
  if (item !== undefined && !onekijsFramework.isCollectionFetching(controller)) {
6294
6383
  previousSearchRef.current = search;
@@ -6297,7 +6386,7 @@ const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '
6297
6386
  }
6298
6387
  }
6299
6388
  }
6300
- }, [controller, focus, open, id]);
6389
+ }, [controller, focus, open, id, autoCompleteSearch]);
6301
6390
  React.useEffect(() => {
6302
6391
  if (!multiple) {
6303
6392
  if (value) {
@@ -6511,7 +6600,7 @@ const ControlledSelectComponent = ({ attachDropdownToBody = false, className = '
6511
6600
  onekijsFramework.useEventListener('keydown', onKeyDown, false);
6512
6601
  return (React__default["default"].createElement(SelectServiceContext.Provider, { value: service },
6513
6602
  React__default["default"].createElement("div", { className: classNames, ref: containerRef, onMouseDown: () => (stateRef.current.keepFocus = true), onMouseUp: () => (stateRef.current.keepFocus = false) },
6514
- 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 }),
6603
+ React__default["default"].createElement(InputComponent, { placeholder: placeholder, setOpen: setOpen, open: open, loading: loading, fetching: fetching, onChange: onInputChange, value: autoCompleteSearch ? (proxyItem ? proxyItem.text : '') : controller.getSearch() || '', 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, autoCompleteSearch: autoCompleteSearch }),
6515
6604
  React__default["default"].createElement(Dropdown, { attachToBody: attachDropdownToBody, open: open, distance: 0, animationTimeout: animationMs, onDropStart: onOpen, onCollapseDone: onClosed, placement: "bottom-start", widthModifier: dropdownWidthModifier, className: className, zIndex: attachDropdownToBody ? 2000 : undefined },
6516
6605
  React__default["default"].createElement(ListComponent, { className: "o-select-options", height: height, ItemComponent: multiple ? MultiOptionsComponent : OptionComponent, ItemLoadingComponent: OptionLoadingComponent, ItemContentComponent: OptionContentComponent, NotFoundComponent: NotFoundComponent, onItemSelect: onSelect, onItemUnselect: onSelect, controller: controller, keyboardNavigable: true, multiSelect: multiple, onItemActivate: onActivate, optionsRef: optionsRef })))));
6517
6606
  };
@@ -7159,8 +7248,8 @@ let TreeService = class TreeService extends onekijsFramework.CollectionService {
7159
7248
  : treeAdaptee.children.map((child) => {
7160
7249
  if (context !== undefined) {
7161
7250
  context.level = level + 1;
7162
- context.position = context.nextPosition;
7163
- context.nextPosition = context.position + 1;
7251
+ context.position = context.nextPosition !== undefined ? context.nextPosition : undefined;
7252
+ context.nextPosition = context.position !== undefined ? context.position + 1 : undefined;
7164
7253
  }
7165
7254
  else {
7166
7255
  context = {
@@ -7458,12 +7547,12 @@ TreeService = __decorate([
7458
7547
  ], TreeService);
7459
7548
  var TreeService$1 = TreeService;
7460
7549
 
7461
- let TreeSelectService = class TreeSelectService extends SelectService$1 {
7550
+ let TreeSelectService = class TreeSelectService extends onekijsFramework.CollectionService {
7462
7551
  };
7463
7552
  TreeSelectService = __decorate([
7464
7553
  onekijsFramework.service
7465
7554
  ], TreeSelectService);
7466
- onekijsFramework.applyMixins(TreeSelectService, [TreeService$1]);
7555
+ onekijsFramework.applyMixins(TreeSelectService, [SelectService$1, TreeService$1]);
7467
7556
  var TreeSelectService$1 = TreeSelectService;
7468
7557
 
7469
7558
  const useTreeSelectController = (dataSource, options = {}) => {
@@ -8708,7 +8797,7 @@ const TableBodyCellComponent = React__default["default"].memo((props) => {
8708
8797
  service.initCell(rowIndex, column.id, ref);
8709
8798
  }
8710
8799
  });
8711
- return (React__default["default"].createElement("div", { ref: ref, className: addClassname('o-table-body-cell', className), style: getCellWidth(column, fit, grow) }, props.item.data && React__default["default"].createElement(Component, { ...props, data: props.item.data })));
8800
+ return (React__default["default"].createElement("div", { ref: ref, className: addClassname('o-table-body-cell', className), style: getCellWidth(column, fit, grow) }, props.item && React__default["default"].createElement(Component, { ...props, data: props.item.data })));
8712
8801
  });
8713
8802
  TableBodyCellComponent.displayName = 'TableCell';
8714
8803
 
@@ -9539,22 +9628,11 @@ const useFormTableContext = () => {
9539
9628
  const CheckboxCellComponent = (options) => {
9540
9629
  const CheckboxCellComponent = ({ item, column, rowIndex }) => {
9541
9630
  const { tableName } = useFormTableContext();
9542
- // const [validators] = extractValidators(options);
9543
- // const field = useField(`${tableName}.${rowIndex}.${column.id}`, validators, {
9544
- // defaultValue: options.defaultValue ? options.defaultValue : false,
9545
- // });
9546
- // const validation = useValidation(`${tableName}.${rowIndex}.${column.id}`);
9547
- // const status = validation?.status;
9548
- // const message = validation?.message;
9549
- // return (
9550
- // <>
9551
- // <Checkbox {...options} {...field} className="o-table-checkbox" status={validation.status} />
9552
- // {message && <FieldDescription content={message} className={`o-field-description-${status.toLowerCase()}`} />}
9553
- // </>
9554
- // );
9555
9631
  const { size, ...checkboxOptions } = options;
9632
+ // if the id is empty, it's a single table column and the value is the row itself
9633
+ const name = column.id ? `${tableName}.${rowIndex}.${column.id}` : `${tableName}.${rowIndex}`;
9556
9634
  const className = typeof options.className === 'function' ? options.className(item, column, rowIndex) : options.className;
9557
- return (React__default["default"].createElement(FormCheckbox, { layout: "table", ...checkboxOptions, name: `${tableName}.${rowIndex}.${column.id}`, className: addClassname('o-table-checkbox', className) }));
9635
+ return (React__default["default"].createElement(FormCheckbox, { layout: "table", ...checkboxOptions, name: name, className: addClassname('o-table-checkbox', className) }));
9558
9636
  };
9559
9637
  CheckboxCellComponent.displayName = 'CheckboxCellComponent';
9560
9638
  return CheckboxCellComponent;
@@ -9576,7 +9654,9 @@ const InputCellComponent = (options) => {
9576
9654
  const InputCellComponent = ({ item, column, rowIndex }) => {
9577
9655
  const { tableName } = useFormTableContext();
9578
9656
  const className = typeof options.className === 'function' ? options.className(item, column, rowIndex) : options.className;
9579
- return (React__default["default"].createElement(FormInput, { size: "small", layout: "table", ...options, name: `${tableName}.${rowIndex}.${column.id}`, className: addClassname('o-table-input', className) }));
9657
+ // if the id is empty, it's a single table column and the value is the row itself
9658
+ const name = column.id ? `${tableName}.${rowIndex}.${column.id}` : `${tableName}.${rowIndex}`;
9659
+ return (React__default["default"].createElement(FormInput, { size: "small", layout: "table", ...options, name: name, className: addClassname('o-table-input', className) }));
9580
9660
  };
9581
9661
  InputCellComponent.displayName = 'InputCellComponent';
9582
9662
  return InputCellComponent;
@@ -9648,8 +9728,9 @@ const SelectCellComponent = (options, broker) => {
9648
9728
  const { tableName } = useFormTableContext();
9649
9729
  const controller = useSelectController(options.dataSource, options);
9650
9730
  const service = controller.asService();
9731
+ // if the id is empty, it's a single table column and the value is the row itself
9732
+ const name = column.id ? `${tableName}.${rowIndex}.${column.id}` : `${tableName}.${rowIndex}`;
9651
9733
  const className = typeof options.className === 'function' ? options.className(item, column, rowIndex) : options.className;
9652
- const name = `${tableName}.${rowIndex}.${column.id}`;
9653
9734
  React.useEffect(() => {
9654
9735
  broker.addSubscriber(name, service);
9655
9736
  return () => {
@@ -9794,8 +9875,10 @@ FormTextarea.displayName = 'FormTextarea';
9794
9875
  const TextareaCellComponent = (options) => {
9795
9876
  const TextareaCellComponent = ({ item, column, rowIndex }) => {
9796
9877
  const { tableName } = useFormTableContext();
9878
+ // if the id is empty, it's a single table column and the value is the row itself
9879
+ const name = column.id ? `${tableName}.${rowIndex}.${column.id}` : `${tableName}.${rowIndex}`;
9797
9880
  const className = typeof options.className === 'function' ? options.className(item, column, rowIndex) : options.className;
9798
- return (React__default["default"].createElement(FormTextarea, { size: "small", layout: "table", ...options, name: `${tableName}.${rowIndex}.${column.id}`, className: addClassname('o-table-textarea', className) }));
9881
+ return (React__default["default"].createElement(FormTextarea, { size: "small", layout: "table", ...options, name: name, className: addClassname('o-table-textarea', className) }));
9799
9882
  };
9800
9883
  TextareaCellComponent.displayName = 'TextareaCellComponent';
9801
9884
  return TextareaCellComponent;
@@ -9900,8 +9983,9 @@ const SelectRowComponent = ({ item }) => {
9900
9983
  const FooterComponent = () => {
9901
9984
  const form = onekijsFramework.useForm();
9902
9985
  const { tableName, addLabel, maxLength } = useFormTableContext();
9986
+ const isSingleColumnTable = useTableColumns().find((c) => c.id === '');
9903
9987
  const addRow = (e) => {
9904
- form.add(tableName);
9988
+ form.add(tableName, isSingleColumnTable ? undefined : {});
9905
9989
  e.preventDefault();
9906
9990
  };
9907
9991
  const currentSize = (form.getValue(tableName) || []).length;
@@ -9991,8 +10075,17 @@ const StyledFormTableComponent = styled__default["default"](FormTableComponent)
9991
10075
  ${tableStyle}
9992
10076
  `;
9993
10077
  const FormTable = React__default["default"].memo((props) => {
10078
+ let defaultValue = props.defaultValue;
10079
+ if (defaultValue === undefined) {
10080
+ let minLength = (props.minLength ?? props.min) || 0;
10081
+ if (props.required && minLength < 1) {
10082
+ minLength = 1;
10083
+ }
10084
+ const isSingleColumnTable = props.controller.columns.find((c) => c.id === '');
10085
+ defaultValue = minLength > 0 ? Array(minLength).fill(isSingleColumnTable ? undefined : {}) : [];
10086
+ }
9994
10087
  const [fieldLayoutProps, fieldComponentProps] = useFieldLayout(Object.assign({
9995
- defaultValue: props.defaultValue === undefined ? [] : props.defaultValue,
10088
+ defaultValue,
9996
10089
  }, props));
9997
10090
  const Component = props.FieldComponent || StyledFormTableComponent;
9998
10091
  return (React__default["default"].createElement(FieldLayout, { ...fieldLayoutProps, required: props.required },
@@ -10054,17 +10147,6 @@ const Tag = styled__default["default"](TagComponent) `
10054
10147
  ${tagStyle}
10055
10148
  `;
10056
10149
 
10057
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
10058
- const WizardServiceContext = React__default["default"].createContext(null);
10059
- const useWizardService = () => {
10060
- return React.useContext(WizardServiceContext);
10061
- };
10062
-
10063
- const WizardStateContext = React__default["default"].createContext(null);
10064
- const useWizardState = () => {
10065
- return React.useContext(WizardStateContext);
10066
- };
10067
-
10068
10150
  const StepTitle = ({ member, onActivate, index }) => {
10069
10151
  return (React__default["default"].createElement("div", { className: `o-step${member.active ? ' o-step-active' : ' o-step-inactive'}${member.disabled ? ' o-step-disabled' : ' o-step-enabled'}${member.visible ? ' o-step-visible' : ' o-step-hidden'}${member.touched || member.touching ? ' o-step-touched' : ' o-step-untouched'}${member.success ? ' o-step-success' : ''}${member.touchingWarning || (member.touched && member.warning) ? ' o-step-warning' : ''}${member.touchingError || (member.touched && member.error) ? ' o-step-error' : ''}${member.loading ? ' o-step-loading' : ''}`, onClick: () => onActivate(member) },
10070
10152
  member.icon,
@@ -10096,6 +10178,9 @@ const WizardContainer = ({ cancelLabel = 'Cancel', className, children, doneLabe
10096
10178
  if (step.visible) {
10097
10179
  indexRef.current++;
10098
10180
  }
10181
+ else {
10182
+ return null;
10183
+ }
10099
10184
  if (step.error !== undefined) {
10100
10185
  errorRef.current.push({
10101
10186
  stepIndex: indexRef.current,
@@ -10429,67 +10514,6 @@ const Wizard = styled__default["default"](WizardComponent) `
10429
10514
  ${wizardStyle}
10430
10515
  `;
10431
10516
 
10432
- const useStep = (props) => {
10433
- const service = useWizardService();
10434
- const state = useWizardState();
10435
- const step = state.members[state.membersIndex[props.uid]];
10436
- React.useEffect(() => {
10437
- if (step === undefined) {
10438
- service.initMember(Object.assign({ uid: props.uid }, props));
10439
- }
10440
- }, [props, service, step]);
10441
- return step;
10442
- };
10443
-
10444
- const Step = ({ title, active = false, disabled = false, visible = true, closable = false, children, icon, uid, optional = false, showTitle = true, className, }) => {
10445
- const { animate, forwardOnly } = useWizardState();
10446
- const service = useWizardService();
10447
- const step = useStep({
10448
- title,
10449
- active,
10450
- disabled,
10451
- visible,
10452
- closable,
10453
- icon,
10454
- loading: false,
10455
- optional,
10456
- touched: !forwardOnly,
10457
- touching: !forwardOnly,
10458
- uid: uid === undefined ? title : uid,
10459
- });
10460
- const fieldContainer = onekijsFramework.useFieldContainer({
10461
- onValidationChange: (touchedValidation, allValidation) => {
10462
- if (step) {
10463
- service.onValidationChange(step.uid, touchedValidation, allValidation);
10464
- }
10465
- },
10466
- });
10467
- const touched = step?.touched;
10468
- const touchAllFields = fieldContainer.touchAllFields;
10469
- const onEnter = (node) => {
10470
- node.style.opacity = '0';
10471
- };
10472
- const onEntering = (node) => {
10473
- setTimeout(() => {
10474
- node.style.opacity = '1';
10475
- node.style.transition = `opacity ${animate}ms ease-in-out`;
10476
- }, 0);
10477
- };
10478
- React.useEffect(() => {
10479
- if (touched) {
10480
- touchAllFields();
10481
- }
10482
- }, [touched, touchAllFields]);
10483
- if (!step || !step.active) {
10484
- return null;
10485
- }
10486
- return (React__default["default"].createElement(onekijsFramework.FormContext.Provider, { value: fieldContainer.context },
10487
- React__default["default"].createElement(reactTransitionGroup.CSSTransition, { in: true, timeout: animate, appear: true, onEnter: onEnter, onEntering: onEntering },
10488
- React__default["default"].createElement("div", { className: addClassname('o-step-content', className) },
10489
- showTitle && React__default["default"].createElement("div", { className: "o-step-content-title" }, title),
10490
- children))));
10491
- };
10492
-
10493
10517
  const WizardModalComponent = ({ title, doneLabel = 'Submit', ...props }) => {
10494
10518
  return (React__default["default"].createElement(Modal, { ...props },
10495
10519
  React__default["default"].createElement(Wizard, { ...props, title: title, doneLabel: doneLabel, inModal: true })));
@@ -11424,10 +11448,11 @@ exports.FieldLayout = FieldLayout;
11424
11448
  exports.FieldLayoutComponent = FieldLayoutComponent;
11425
11449
  exports.FileIcon = FileIcon;
11426
11450
  exports.FolderIcon = FolderIcon;
11427
- exports.FormCard = FormCard;
11451
+ exports.FormCard = FormCard$1;
11428
11452
  exports.FormCheckbox = FormCheckbox;
11429
11453
  exports.FormInput = FormInput;
11430
11454
  exports.FormSelect = FormSelect$1;
11455
+ exports.FormStep = FormCard;
11431
11456
  exports.FormTable = FormTable;
11432
11457
  exports.FormTextarea = FormTextarea;
11433
11458
  exports.Input = Input;