onekijs-ui 0.20.7 → 0.20.9

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.
@@ -80,11 +80,11 @@ export declare const getIconDivProps: (props: IconProps) => {
80
80
  results?: number | undefined;
81
81
  security?: string | undefined;
82
82
  unselectable?: "on" | "off" | undefined;
83
- inputMode?: "search" | "text" | "none" | "email" | "tel" | "url" | "numeric" | "decimal" | undefined;
83
+ inputMode?: "search" | "text" | "email" | "tel" | "url" | "none" | "numeric" | "decimal" | undefined;
84
84
  is?: string | undefined;
85
85
  'aria-activedescendant'?: string | undefined;
86
86
  'aria-atomic'?: (boolean | "true" | "false") | undefined;
87
- 'aria-autocomplete'?: "none" | "inline" | "both" | "list" | undefined;
87
+ 'aria-autocomplete'?: "list" | "none" | "inline" | "both" | undefined;
88
88
  'aria-braillelabel'?: string | undefined;
89
89
  'aria-brailleroledescription'?: string | undefined;
90
90
  'aria-busy'?: (boolean | "true" | "false") | undefined;
@@ -104,7 +104,7 @@ export declare const getIconDivProps: (props: IconProps) => {
104
104
  'aria-expanded'?: (boolean | "true" | "false") | undefined;
105
105
  'aria-flowto'?: string | undefined;
106
106
  'aria-grabbed'?: (boolean | "true" | "false") | undefined;
107
- 'aria-haspopup'?: boolean | "dialog" | "menu" | "listbox" | "grid" | "true" | "false" | "tree" | undefined;
107
+ 'aria-haspopup'?: boolean | "dialog" | "menu" | "true" | "false" | "grid" | "listbox" | "tree" | undefined;
108
108
  'aria-hidden'?: (boolean | "true" | "false") | undefined;
109
109
  'aria-invalid'?: boolean | "true" | "false" | "grammar" | "spelling" | undefined;
110
110
  'aria-keyshortcuts'?: string | undefined;
@@ -1,20 +1,22 @@
1
- import { AnonymousObject, CollectionFetcherResult, CollectionService, Query } from 'onekijs-framework';
1
+ import { AnonymousObject, CollectionFetcherResult, CollectionService, CollectionStatus, Primitive, Query } from 'onekijs-framework';
2
2
  import { SelectConfig, SelectItem, SelectState } from './typings';
3
3
  declare class SelectService<T = any, I extends SelectItem<T> = SelectItem<T>, S extends SelectState<T, I> = SelectState<T, I>> extends CollectionService<T, I, S> {
4
4
  config: SelectConfig<T, I> | undefined;
5
5
  protected lastCheckQuery: Query | undefined;
6
6
  get defaultValue(): T | T[] | null | undefined;
7
7
  get defaultValueLoading(): boolean | undefined;
8
- check(): Generator<void | import("redux-saga/effects").AllEffect<import("redux-saga/effects").CallEffect<Generator<I[] | Generator<void | import("redux-saga/effects").CancelEffect | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | CollectionFetcherResult<T> | Promise<CollectionFetcherResult<T> | undefined>, 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 | import("redux-saga/effects").CancelEffect | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | CollectionFetcherResult<T> | Promise<CollectionFetcherResult<T> | undefined>, 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)[]>;
8
+ check(): Generator<void | import("redux-saga/effects").AllEffect<import("redux-saga/effects").CallEffect<Generator<I[] | Generator<void | CollectionFetcherResult<T> | import("redux-saga/effects").CancelEffect | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | Promise<CollectionFetcherResult<T> | undefined>, 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 | CollectionFetcherResult<T> | import("redux-saga/effects").CancelEffect | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | Promise<CollectionFetcherResult<T> | undefined>, 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)[]>;
9
+ get status(): CollectionStatus;
9
10
  setData(data: T[], query?: Query): void;
10
- setDefaultValue(value: T | T[] | null | undefined): Generator<void | Generator<void | import("redux-saga/effects").AllEffect<import("redux-saga/effects").CallEffect<Generator<I[] | Generator<void | import("redux-saga/effects").CancelEffect | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | CollectionFetcherResult<T> | Promise<CollectionFetcherResult<T> | undefined>, 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 | import("redux-saga/effects").CancelEffect | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | CollectionFetcherResult<T> | Promise<CollectionFetcherResult<T> | undefined>, 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>;
11
+ setDefaultValue(value: T | T[] | null | undefined): Generator<void | Generator<void | import("redux-saga/effects").AllEffect<import("redux-saga/effects").CallEffect<Generator<I[] | Generator<void | CollectionFetcherResult<T> | import("redux-saga/effects").CancelEffect | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | Promise<CollectionFetcherResult<T> | undefined>, 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 | CollectionFetcherResult<T> | import("redux-saga/effects").CancelEffect | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | Promise<CollectionFetcherResult<T> | undefined>, 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>;
11
12
  setDefaultValueLoading(loading: boolean): void;
12
13
  setItemWidth(_item: I, value: number): void;
13
14
  setValue(value: null | T | T[]): void;
14
15
  setUrl(url: string, query?: Query): void;
15
16
  _buildItem(data: T | null | undefined, adaptee: unknown, context?: AnonymousObject): I;
16
- _filterItem(item: I | undefined, query: Query, valid: boolean): Generator<I[] | Generator<void | import("redux-saga/effects").CancelEffect | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | CollectionFetcherResult<T> | Promise<CollectionFetcherResult<T> | undefined>, CollectionFetcherResult<T>, (import("redux-saga").Task<any> | null) & CollectionFetcherResult<T> & (CollectionFetcherResult<T> | undefined)>, I | undefined, I[] & CollectionFetcherResult<T>>;
17
+ _filterItem(item: I | undefined, query: Query, valid: boolean): Generator<I[] | Generator<void | CollectionFetcherResult<T> | import("redux-saga/effects").CancelEffect | import("redux-saga/effects").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | Promise<CollectionFetcherResult<T> | undefined>, CollectionFetcherResult<T>, (import("redux-saga").Task<any> | null) & CollectionFetcherResult<T> & (CollectionFetcherResult<T> | undefined)>, I | undefined, I[] & CollectionFetcherResult<T>>;
17
18
  _compareItem(a: I | undefined, b: I | undefined): boolean;
19
+ _doSearch(search: Primitive | undefined): boolean;
18
20
  _setDefaultValue(value: T | T[] | null | undefined): void;
19
21
  _setValidDefaultValue(value: T | T[] | null): void;
20
22
  _setInvalidItems(invalidItems: I[]): void;
@@ -5,6 +5,7 @@ export declare class WizardService<M extends StepState = StepState, S extends Wi
5
5
  activatePrevious(): void;
6
6
  getCurrentStep(): M | undefined;
7
7
  getNextStep(): M | undefined;
8
+ getLastStep(): M | undefined;
8
9
  getPreviousStep(): M | undefined;
9
10
  isFirstStep(): boolean;
10
11
  isLastStep(): boolean;
@@ -1,5 +1,5 @@
1
1
  import { AnyFunction, FCC } from 'onekijs-framework';
2
- import { ReactNode } from 'react';
2
+ import React, { ReactNode } from 'react';
3
3
  import { GridSize } from '../grid/typings';
4
4
  import { ModalProps } from '../modal/typings';
5
5
  import { TabProps, TabsProps, TabsState, TabState, TabTitleProps } from '../tab/typings';
@@ -25,13 +25,14 @@ export type StepTitleProps<M extends StepState = StepState> = TabTitleProps<M> &
25
25
  export type UseWizardController = (props: WizardProps) => WizardService;
26
26
  export type WizardModalProps<M extends StepState = StepState> = ModalProps & WizardProps<M>;
27
27
  export type WizardProps<M extends StepState = StepState> = Omit<TabsProps, 'controller' | 'Component' | 'TitleComponent'> & {
28
- cancelLabel?: string;
28
+ cancelLabel?: ReactNode;
29
29
  controller?: WizardService;
30
30
  Component?: FCC<Omit<WizardProps, 'Component'>>;
31
- doneLabel?: string;
31
+ doneLabel?: ReactNode;
32
+ reviewLabel?: ReactNode;
32
33
  forwardOnly?: boolean;
33
34
  inModal?: boolean;
34
- nextLabel?: string;
35
+ nextLabel?: ReactNode;
35
36
  previousLabel?: string;
36
37
  stepSize?: GridSize;
37
38
  onCancel?: AnyFunction;
@@ -40,6 +41,7 @@ export type WizardProps<M extends StepState = StepState> = Omit<TabsProps, 'cont
40
41
  onPrevious?: (currentStep: M, previousStep: M) => boolean;
41
42
  title?: ReactNode;
42
43
  TitleComponent?: React.FC<StepTitleProps>;
44
+ hasSummaryStep?: boolean;
43
45
  };
44
46
  export type WizardState<M extends StepState = StepState> = TabsState<M> & Pick<WizardProps<M>, 'onCancel' | 'onDone' | 'onNext' | 'onPrevious'> & {
45
47
  forwardOnly?: boolean;
package/dist/index.d.ts CHANGED
@@ -202,6 +202,10 @@ export { defaultTreeQueryEngine } from './components/tree/util';
202
202
  export { default as Wizard } from './components/wizard';
203
203
  export { default as WizardModal } from './components/wizard/WizardModal';
204
204
  export { WizardService } from './components/wizard/WizardService';
205
+ export { default as useWizardService } from './components/wizard/hooks/useWizardService';
206
+ export { default as useWizardController } from './components/wizard/hooks/useWizardController';
207
+ export { default as useStep } from './components/wizard/hooks/useStep';
208
+ export { useWizardState } from './components/wizard/hooks/useWizardState';
205
209
  export { default as WizardSummary } from './components/wizard/WizardSummary';
206
210
  export { default as ControlledWizardComponent } from './components/wizard/components/ControlledWizardComponent';
207
211
  export { default as FormStep } from './components/wizard/components/FormStep';
package/dist/index.js CHANGED
@@ -937,6 +937,7 @@ const AccordionPanel = ({ title, initialActive, initialExpand, children, Compone
937
937
 
938
938
  const ButtonComponent = React.forwardRef((props, ref) => {
939
939
  const { kind, pattern, className, loading, IconComponent, onClick, type = 'button', ...buttonProps } = props;
940
+ const buttonRef = React.useRef(null);
940
941
  let classNames = addClassname('o-button', className);
941
942
  if (loading) {
942
943
  classNames = addClassname('o-button-loading', classNames);
@@ -944,10 +945,20 @@ const ButtonComponent = React.forwardRef((props, ref) => {
944
945
  if (props.disabled) {
945
946
  classNames = addClassname('o-button-disabled', classNames);
946
947
  }
947
- return (React.createElement("span", { className: classNames, onClick: onClick, ref: ref },
948
+ const handleClick = (e) => {
949
+ if (!onClick) {
950
+ if (buttonRef.current) {
951
+ buttonRef.current.click();
952
+ }
953
+ }
954
+ else {
955
+ onClick(e);
956
+ }
957
+ };
958
+ return (React.createElement("span", { className: classNames, onClick: handleClick, ref: ref },
948
959
  loading && React.createElement(LoadingIcon, { onClick: undefined, color: "currentColor" }),
949
960
  !loading && IconComponent && React.createElement(IconComponent, { ...props, onClick: undefined, className: "o-button-icon" }),
950
- React.createElement("button", { ...buttonProps, type: type, className: "o-button-content" })));
961
+ React.createElement("button", { ref: buttonRef, ...buttonProps, type: type, className: "o-button-content" })));
951
962
  });
952
963
  ButtonComponent.displayName = 'Button';
953
964
 
@@ -6430,6 +6441,12 @@ let SelectService = class SelectService extends onekijsFramework.CollectionServi
6430
6441
  }
6431
6442
  yield call(this._setInvalidItems, invalidItems);
6432
6443
  }
6444
+ get status() {
6445
+ if (!this._doSearch(this.state.search)) {
6446
+ return onekijsFramework.LoadingStatus.NotReady;
6447
+ }
6448
+ return super.status;
6449
+ }
6433
6450
  setData(data, query) {
6434
6451
  this.lastCheckQuery = undefined;
6435
6452
  super.setData(data, query);
@@ -6525,6 +6542,16 @@ let SelectService = class SelectService extends onekijsFramework.CollectionServi
6525
6542
  }
6526
6543
  return a.id === b.id;
6527
6544
  }
6545
+ _doSearch(search) {
6546
+ const minChars = this.config?.minChars || 0;
6547
+ if (search === undefined) {
6548
+ search = '';
6549
+ }
6550
+ if (typeof search === 'string' && search.length < minChars) {
6551
+ return false;
6552
+ }
6553
+ return true;
6554
+ }
6528
6555
  _setDefaultValue(value) {
6529
6556
  this.state.defaultValueLoading = false;
6530
6557
  this.state.defaultValue = value;
@@ -11290,10 +11317,11 @@ const StepTitle = ({ member, onActivate, index }) => {
11290
11317
  `${member.title}`)));
11291
11318
  };
11292
11319
 
11293
- const WizardContainer = ({ cancelLabel = 'Cancel', className, children, doneLabel = 'Submit', nextLabel = 'Next', onCancel, onDone, previousLabel = 'Previous', title, stepSize = 3, TitleComponent = StepTitle, }) => {
11320
+ const WizardContainer = ({ cancelLabel = 'Cancel', className, children, doneLabel = 'Submit', nextLabel = 'Next', onCancel, onDone, previousLabel = 'Previous', title, stepSize = 3, TitleComponent = StepTitle, forwardOnly = true, hasSummaryStep = false, reviewLabel = 'Review and Submit' }) => {
11294
11321
  const classNames = addClassname('o-wizard', className);
11295
11322
  const state = useWizardState();
11296
11323
  const service = useWizardService();
11324
+ const lastStepUid = service.getLastStep()?.uid;
11297
11325
  const activate = React.useCallback((step) => {
11298
11326
  if (!step || step.disabled || (!step.touched && !step.touching))
11299
11327
  return;
@@ -11330,7 +11358,7 @@ const WizardContainer = ({ cancelLabel = 'Cancel', className, children, doneLabe
11330
11358
  onCancel && (React.createElement(Button, { kind: "primary", pattern: "flat", className: "o-wizard-control-button", type: "button", onClick: () => onCancel() }, cancelLabel)),
11331
11359
  !service.isFirstStep() && (React.createElement(Button, { kind: "primary", pattern: "outline", className: "o-wizard-control-button", onClick: () => service.previous(), type: "button" }, previousLabel)),
11332
11360
  !service.isLastStep() && (React.createElement(Button, { kind: service.isCurrentStepInVisibleError() ? 'danger' : 'primary', pattern: "solid", className: "o-wizard-control-button", disabled: service.isCurrentStepInVisibleError(), onClick: () => service.next(), type: "button" }, nextLabel)),
11333
- service.isLastStep() && (React.createElement(SubmitButton, { kind: errorRef.current.length > 0 ? 'danger' : 'success', pattern: "solid", className: "o-wizard-control-button", disabled: errorRef.current.length > 0, onClick: onDone, type: "button", showErrors: true }, doneLabel))))));
11361
+ (service.isLastStep() || !forwardOnly) && (React.createElement(SubmitButton, { kind: errorRef.current.length > 0 ? 'danger' : 'success', pattern: "solid", className: "o-wizard-control-button", disabled: errorRef.current.length > 0, onClick: (hasSummaryStep && !service.isLastStep() && lastStepUid) ? () => service.activate(lastStepUid) : onDone, type: "button", showErrors: true }, (hasSummaryStep && !service.isLastStep()) ? reviewLabel : doneLabel))))));
11334
11362
  };
11335
11363
 
11336
11364
  const ControlledWizardComponent = ({ Component = WizardContainer, controller, ...props }) => {
@@ -11364,6 +11392,9 @@ exports.WizardService = class WizardService extends TabsService {
11364
11392
  }
11365
11393
  return undefined;
11366
11394
  }
11395
+ getLastStep() {
11396
+ return this.state.members.filter((m) => m.visible && !m.disabled).slice(-1)[0];
11397
+ }
11367
11398
  getPreviousStep() {
11368
11399
  for (let i = this.getCurrentActiveIndex() - 1; i >= 0; i--) {
11369
11400
  const step = this.state.members[i];
@@ -11672,6 +11703,18 @@ const WizardModal = styled(WizardModalComponent) `
11672
11703
  ${wizardModalStyle}
11673
11704
  `;
11674
11705
 
11706
+ const useStep = (props) => {
11707
+ const service = useWizardService();
11708
+ const state = useWizardState();
11709
+ const step = state.members[state.membersIndex[props.uid]];
11710
+ React.useEffect(() => {
11711
+ if (step === undefined) {
11712
+ service.initMember(Object.assign({ uid: props.uid }, props));
11713
+ }
11714
+ }, [props, service, step]);
11715
+ return step;
11716
+ };
11717
+
11675
11718
  const WizardSummaryComponent = ({ className }) => {
11676
11719
  const form = onekijsFramework.useForm();
11677
11720
  const tree = Object.values(form.getDisplayerTree());
@@ -11685,18 +11728,6 @@ const WizardSummary = styled(WizardSummaryComponent) `
11685
11728
  ${wizardSummaryStyle}
11686
11729
  `;
11687
11730
 
11688
- const useStep = (props) => {
11689
- const service = useWizardService();
11690
- const state = useWizardState();
11691
- const step = state.members[state.membersIndex[props.uid]];
11692
- React.useEffect(() => {
11693
- if (step === undefined) {
11694
- service.initMember(Object.assign({ uid: props.uid }, props));
11695
- }
11696
- }, [props, service, step]);
11697
- return step;
11698
- };
11699
-
11700
11731
  const Step = ({ title, active = false, disabled = false, visible = true, closable = false, children, icon, uid, optional = false, showTitle = true, className, onTouch, help, }) => {
11701
11732
  const { animate, forwardOnly } = useWizardState();
11702
11733
  const step = useStep({
@@ -12166,7 +12197,7 @@ const baseTheme = (customTheme = {}) => {
12166
12197
  '4xl': '2.25rem',
12167
12198
  '5xl': '3rem',
12168
12199
  '6xl': '4rem',
12169
- default: '.0875rem',
12200
+ default: '.875rem',
12170
12201
  },
12171
12202
  spacings: {
12172
12203
  xs: '-0.05em',
@@ -13157,6 +13188,7 @@ exports.useNumberColumn = useInputColumn;
13157
13188
  exports.useSelectColumn = useSelectColumn;
13158
13189
  exports.useSelectController = useSelectController;
13159
13190
  exports.useSelectService = useSelectService;
13191
+ exports.useStep = useStep;
13160
13192
  exports.useTab = useTab;
13161
13193
  exports.useTableController = useTableController;
13162
13194
  exports.useTableService = useTableService;
@@ -13172,6 +13204,9 @@ exports.useTreeItemContext = useTreeItemContext;
13172
13204
  exports.useTreeSelectController = useTreeSelectController;
13173
13205
  exports.useTreeService = useTreeService;
13174
13206
  exports.useTreeState = useTreeState;
13207
+ exports.useWizardController = useWizardController;
13208
+ exports.useWizardService = useWizardService;
13209
+ exports.useWizardState = useWizardState;
13175
13210
  exports.userSelect = userSelect;
13176
13211
  exports.verticalAlign = verticalAlign;
13177
13212
  exports.visibility = visibility;