onekijs-ui 0.20.8 → 0.21.0

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,7 +80,7 @@ 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" | "email" | "tel" | "url" | "none" | "numeric" | "decimal" | undefined;
83
+ inputMode?: "search" | "url" | "text" | "none" | "email" | "tel" | "numeric" | "decimal" | undefined;
84
84
  is?: string | undefined;
85
85
  'aria-activedescendant'?: string | undefined;
86
86
  'aria-atomic'?: (boolean | "true" | "false") | undefined;
@@ -94,7 +94,7 @@ export declare const getIconDivProps: (props: IconProps) => {
94
94
  'aria-colindextext'?: string | undefined;
95
95
  'aria-colspan'?: number | undefined;
96
96
  'aria-controls'?: string | undefined;
97
- 'aria-current'?: boolean | "time" | "step" | "date" | "true" | "false" | "page" | "location" | undefined;
97
+ 'aria-current'?: boolean | "step" | "time" | "date" | "true" | "false" | "page" | "location" | undefined;
98
98
  'aria-describedby'?: string | undefined;
99
99
  'aria-description'?: string | undefined;
100
100
  'aria-details'?: string | 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" | "true" | "false" | "grid" | "listbox" | "tree" | undefined;
107
+ 'aria-haspopup'?: boolean | "dialog" | "menu" | "listbox" | "grid" | "true" | "false" | "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").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | import("redux-saga/effects").CancelEffect | 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").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | import("redux-saga/effects").CancelEffect | 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 | 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)[]>;
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").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | import("redux-saga/effects").CancelEffect | 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").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | import("redux-saga/effects").CancelEffect | 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 | 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
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").ForkEffect<Generator<void | import("redux-saga/effects").CallEffect<true>, void, unknown>> | import("redux-saga/effects").CancelEffect | 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 | 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
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;
@@ -0,0 +1,4 @@
1
+ import { FCC } from 'onekijs-framework';
2
+ import { SliderProps } from '../typings';
3
+ declare const SliderComponent: FCC<SliderProps>;
4
+ export default SliderComponent;
@@ -0,0 +1,2 @@
1
+ declare const Resizer: import("styled-components").StyledComponent<import("onekijs-framework").FCC<import("./typings").SliderProps>, import("styled-components").DefaultTheme, {}, never>;
2
+ export default Resizer;
@@ -0,0 +1,3 @@
1
+ import { ComponentStyle } from '../../styles/typings';
2
+ import { SliderProps } from './typings';
3
+ export declare const sliderStyle: ComponentStyle<SliderProps>;
@@ -0,0 +1,9 @@
1
+ import { ColorPropertyTheme, SizePropertyTheme, TLength } from '../../styles/typings';
2
+ import { Property } from 'csstype';
3
+ export type SliderProps = {
4
+ anchorColor: ColorPropertyTheme | Property.BackgroundColor;
5
+ backgroundColor: ColorPropertyTheme | Property.BackgroundColor;
6
+ fillColor: ColorPropertyTheme | Property.BackgroundColor;
7
+ size: 'small' | 'medium' | 'large' | 'extra_large';
8
+ width: SizePropertyTheme | Property.Width<TLength>;
9
+ };
@@ -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
@@ -5227,10 +5227,10 @@ var LoadingItem$1 = styled(LoadingItem) `
5227
5227
 
5228
5228
  @keyframes skeleton-loading {
5229
5229
  0% {
5230
- background-color: hsl(200, 20%, 95%);
5230
+ ${backgroundColor('lightest')};
5231
5231
  }
5232
5232
  100% {
5233
- background-color: hsl(200, 20%, 80%);
5233
+ ${backgroundColor('light')};
5234
5234
  }
5235
5235
  }
5236
5236
  `;
@@ -6194,6 +6194,7 @@ const notifcationsStyle = ({ position: pos = 'bottom-right' }) => {
6194
6194
  &.o-notification-error {
6195
6195
  ${backgroundColor('red-100')}
6196
6196
  ${borderColor('red-200')}
6197
+ ${color('danger')}
6197
6198
  .o-notification-timer {
6198
6199
  ${color('danger')}
6199
6200
  }
@@ -6201,6 +6202,7 @@ const notifcationsStyle = ({ position: pos = 'bottom-right' }) => {
6201
6202
  &.o-notification-success {
6202
6203
  ${backgroundColor('green-0')}
6203
6204
  ${borderColor('green-100')}
6205
+ ${color('green-500')}
6204
6206
  .o-notification-timer {
6205
6207
  ${color('green-500')}
6206
6208
  }
@@ -6208,6 +6210,7 @@ const notifcationsStyle = ({ position: pos = 'bottom-right' }) => {
6208
6210
  &.o-notification-info {
6209
6211
  ${backgroundColor('blue-0')}
6210
6212
  ${borderColor('blue-200')}
6213
+ ${color('blue-500')}
6211
6214
  .o-notification-timer {
6212
6215
  ${color('blue-500')}
6213
6216
  }
@@ -6215,6 +6218,7 @@ const notifcationsStyle = ({ position: pos = 'bottom-right' }) => {
6215
6218
  &.o-notification-warning {
6216
6219
  ${backgroundColor('yellow-100')}
6217
6220
  ${borderColor('yellow-200')}
6221
+ ${color('warning')}
6218
6222
  .o-notification-timer {
6219
6223
  ${color('warning')}
6220
6224
  }
@@ -6441,6 +6445,12 @@ let SelectService = class SelectService extends onekijsFramework.CollectionServi
6441
6445
  }
6442
6446
  yield call(this._setInvalidItems, invalidItems);
6443
6447
  }
6448
+ get status() {
6449
+ if (!this._doSearch(this.state.search)) {
6450
+ return onekijsFramework.LoadingStatus.NotReady;
6451
+ }
6452
+ return super.status;
6453
+ }
6444
6454
  setData(data, query) {
6445
6455
  this.lastCheckQuery = undefined;
6446
6456
  super.setData(data, query);
@@ -6536,6 +6546,16 @@ let SelectService = class SelectService extends onekijsFramework.CollectionServi
6536
6546
  }
6537
6547
  return a.id === b.id;
6538
6548
  }
6549
+ _doSearch(search) {
6550
+ const minChars = this.config?.minChars || 0;
6551
+ if (search === undefined) {
6552
+ search = '';
6553
+ }
6554
+ if (typeof search === 'string' && search.length < minChars) {
6555
+ return false;
6556
+ }
6557
+ return true;
6558
+ }
6539
6559
  _setDefaultValue(value) {
6540
6560
  this.state.defaultValueLoading = false;
6541
6561
  this.state.defaultValue = value;
@@ -11301,10 +11321,11 @@ const StepTitle = ({ member, onActivate, index }) => {
11301
11321
  `${member.title}`)));
11302
11322
  };
11303
11323
 
11304
- const WizardContainer = ({ cancelLabel = 'Cancel', className, children, doneLabel = 'Submit', nextLabel = 'Next', onCancel, onDone, previousLabel = 'Previous', title, stepSize = 3, TitleComponent = StepTitle, }) => {
11324
+ 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' }) => {
11305
11325
  const classNames = addClassname('o-wizard', className);
11306
11326
  const state = useWizardState();
11307
11327
  const service = useWizardService();
11328
+ const lastStepUid = service.getLastStep()?.uid;
11308
11329
  const activate = React.useCallback((step) => {
11309
11330
  if (!step || step.disabled || (!step.touched && !step.touching))
11310
11331
  return;
@@ -11341,7 +11362,7 @@ const WizardContainer = ({ cancelLabel = 'Cancel', className, children, doneLabe
11341
11362
  onCancel && (React.createElement(Button, { kind: "primary", pattern: "flat", className: "o-wizard-control-button", type: "button", onClick: () => onCancel() }, cancelLabel)),
11342
11363
  !service.isFirstStep() && (React.createElement(Button, { kind: "primary", pattern: "outline", className: "o-wizard-control-button", onClick: () => service.previous(), type: "button" }, previousLabel)),
11343
11364
  !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)),
11344
- 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))))));
11365
+ (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))))));
11345
11366
  };
11346
11367
 
11347
11368
  const ControlledWizardComponent = ({ Component = WizardContainer, controller, ...props }) => {
@@ -11375,6 +11396,9 @@ exports.WizardService = class WizardService extends TabsService {
11375
11396
  }
11376
11397
  return undefined;
11377
11398
  }
11399
+ getLastStep() {
11400
+ return this.state.members.filter((m) => m.visible && !m.disabled).slice(-1)[0];
11401
+ }
11378
11402
  getPreviousStep() {
11379
11403
  for (let i = this.getCurrentActiveIndex() - 1; i >= 0; i--) {
11380
11404
  const step = this.state.members[i];
@@ -11683,6 +11707,18 @@ const WizardModal = styled(WizardModalComponent) `
11683
11707
  ${wizardModalStyle}
11684
11708
  `;
11685
11709
 
11710
+ const useStep = (props) => {
11711
+ const service = useWizardService();
11712
+ const state = useWizardState();
11713
+ const step = state.members[state.membersIndex[props.uid]];
11714
+ React.useEffect(() => {
11715
+ if (step === undefined) {
11716
+ service.initMember(Object.assign({ uid: props.uid }, props));
11717
+ }
11718
+ }, [props, service, step]);
11719
+ return step;
11720
+ };
11721
+
11686
11722
  const WizardSummaryComponent = ({ className }) => {
11687
11723
  const form = onekijsFramework.useForm();
11688
11724
  const tree = Object.values(form.getDisplayerTree());
@@ -11696,18 +11732,6 @@ const WizardSummary = styled(WizardSummaryComponent) `
11696
11732
  ${wizardSummaryStyle}
11697
11733
  `;
11698
11734
 
11699
- const useStep = (props) => {
11700
- const service = useWizardService();
11701
- const state = useWizardState();
11702
- const step = state.members[state.membersIndex[props.uid]];
11703
- React.useEffect(() => {
11704
- if (step === undefined) {
11705
- service.initMember(Object.assign({ uid: props.uid }, props));
11706
- }
11707
- }, [props, service, step]);
11708
- return step;
11709
- };
11710
-
11711
11735
  const Step = ({ title, active = false, disabled = false, visible = true, closable = false, children, icon, uid, optional = false, showTitle = true, className, onTouch, help, }) => {
11712
11736
  const { animate, forwardOnly } = useWizardState();
11713
11737
  const step = useStep({
@@ -13168,6 +13192,7 @@ exports.useNumberColumn = useInputColumn;
13168
13192
  exports.useSelectColumn = useSelectColumn;
13169
13193
  exports.useSelectController = useSelectController;
13170
13194
  exports.useSelectService = useSelectService;
13195
+ exports.useStep = useStep;
13171
13196
  exports.useTab = useTab;
13172
13197
  exports.useTableController = useTableController;
13173
13198
  exports.useTableService = useTableService;
@@ -13183,6 +13208,9 @@ exports.useTreeItemContext = useTreeItemContext;
13183
13208
  exports.useTreeSelectController = useTreeSelectController;
13184
13209
  exports.useTreeService = useTreeService;
13185
13210
  exports.useTreeState = useTreeState;
13211
+ exports.useWizardController = useWizardController;
13212
+ exports.useWizardService = useWizardService;
13213
+ exports.useWizardState = useWizardState;
13186
13214
  exports.userSelect = userSelect;
13187
13215
  exports.verticalAlign = verticalAlign;
13188
13216
  exports.visibility = visibility;