onekijs-ui 0.20.8 → 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.
- package/dist/components/select/SelectService.d.ts +6 -4
- package/dist/components/wizard/WizardService.d.ts +1 -0
- package/dist/components/wizard/typings.d.ts +6 -4
- package/dist/index.d.ts +4 -0
- package/dist/index.js +38 -14
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +35 -15
- package/dist/index.module.js.map +1 -1
- package/package.json +3 -3
- package/src/components/select/SelectService.ts +20 -0
- package/src/components/wizard/WizardService.ts +4 -0
- package/src/components/wizard/components/WizardContainer.tsx +12 -4
- package/src/components/wizard/typings.ts +7 -4
- package/src/index.ts +4 -0
|
@@ -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").
|
|
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").
|
|
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").
|
|
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?:
|
|
28
|
+
cancelLabel?: ReactNode;
|
|
29
29
|
controller?: WizardService;
|
|
30
30
|
Component?: FCC<Omit<WizardProps, 'Component'>>;
|
|
31
|
-
doneLabel?:
|
|
31
|
+
doneLabel?: ReactNode;
|
|
32
|
+
reviewLabel?: ReactNode;
|
|
32
33
|
forwardOnly?: boolean;
|
|
33
34
|
inModal?: boolean;
|
|
34
|
-
nextLabel?:
|
|
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
|
@@ -6441,6 +6441,12 @@ let SelectService = class SelectService extends onekijsFramework.CollectionServi
|
|
|
6441
6441
|
}
|
|
6442
6442
|
yield call(this._setInvalidItems, invalidItems);
|
|
6443
6443
|
}
|
|
6444
|
+
get status() {
|
|
6445
|
+
if (!this._doSearch(this.state.search)) {
|
|
6446
|
+
return onekijsFramework.LoadingStatus.NotReady;
|
|
6447
|
+
}
|
|
6448
|
+
return super.status;
|
|
6449
|
+
}
|
|
6444
6450
|
setData(data, query) {
|
|
6445
6451
|
this.lastCheckQuery = undefined;
|
|
6446
6452
|
super.setData(data, query);
|
|
@@ -6536,6 +6542,16 @@ let SelectService = class SelectService extends onekijsFramework.CollectionServi
|
|
|
6536
6542
|
}
|
|
6537
6543
|
return a.id === b.id;
|
|
6538
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
|
+
}
|
|
6539
6555
|
_setDefaultValue(value) {
|
|
6540
6556
|
this.state.defaultValueLoading = false;
|
|
6541
6557
|
this.state.defaultValue = value;
|
|
@@ -11301,10 +11317,11 @@ const StepTitle = ({ member, onActivate, index }) => {
|
|
|
11301
11317
|
`${member.title}`)));
|
|
11302
11318
|
};
|
|
11303
11319
|
|
|
11304
|
-
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' }) => {
|
|
11305
11321
|
const classNames = addClassname('o-wizard', className);
|
|
11306
11322
|
const state = useWizardState();
|
|
11307
11323
|
const service = useWizardService();
|
|
11324
|
+
const lastStepUid = service.getLastStep()?.uid;
|
|
11308
11325
|
const activate = React.useCallback((step) => {
|
|
11309
11326
|
if (!step || step.disabled || (!step.touched && !step.touching))
|
|
11310
11327
|
return;
|
|
@@ -11341,7 +11358,7 @@ const WizardContainer = ({ cancelLabel = 'Cancel', className, children, doneLabe
|
|
|
11341
11358
|
onCancel && (React.createElement(Button, { kind: "primary", pattern: "flat", className: "o-wizard-control-button", type: "button", onClick: () => onCancel() }, cancelLabel)),
|
|
11342
11359
|
!service.isFirstStep() && (React.createElement(Button, { kind: "primary", pattern: "outline", className: "o-wizard-control-button", onClick: () => service.previous(), type: "button" }, previousLabel)),
|
|
11343
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)),
|
|
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))))));
|
|
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))))));
|
|
11345
11362
|
};
|
|
11346
11363
|
|
|
11347
11364
|
const ControlledWizardComponent = ({ Component = WizardContainer, controller, ...props }) => {
|
|
@@ -11375,6 +11392,9 @@ exports.WizardService = class WizardService extends TabsService {
|
|
|
11375
11392
|
}
|
|
11376
11393
|
return undefined;
|
|
11377
11394
|
}
|
|
11395
|
+
getLastStep() {
|
|
11396
|
+
return this.state.members.filter((m) => m.visible && !m.disabled).slice(-1)[0];
|
|
11397
|
+
}
|
|
11378
11398
|
getPreviousStep() {
|
|
11379
11399
|
for (let i = this.getCurrentActiveIndex() - 1; i >= 0; i--) {
|
|
11380
11400
|
const step = this.state.members[i];
|
|
@@ -11683,6 +11703,18 @@ const WizardModal = styled(WizardModalComponent) `
|
|
|
11683
11703
|
${wizardModalStyle}
|
|
11684
11704
|
`;
|
|
11685
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
|
+
|
|
11686
11718
|
const WizardSummaryComponent = ({ className }) => {
|
|
11687
11719
|
const form = onekijsFramework.useForm();
|
|
11688
11720
|
const tree = Object.values(form.getDisplayerTree());
|
|
@@ -11696,18 +11728,6 @@ const WizardSummary = styled(WizardSummaryComponent) `
|
|
|
11696
11728
|
${wizardSummaryStyle}
|
|
11697
11729
|
`;
|
|
11698
11730
|
|
|
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
11731
|
const Step = ({ title, active = false, disabled = false, visible = true, closable = false, children, icon, uid, optional = false, showTitle = true, className, onTouch, help, }) => {
|
|
11712
11732
|
const { animate, forwardOnly } = useWizardState();
|
|
11713
11733
|
const step = useStep({
|
|
@@ -13168,6 +13188,7 @@ exports.useNumberColumn = useInputColumn;
|
|
|
13168
13188
|
exports.useSelectColumn = useSelectColumn;
|
|
13169
13189
|
exports.useSelectController = useSelectController;
|
|
13170
13190
|
exports.useSelectService = useSelectService;
|
|
13191
|
+
exports.useStep = useStep;
|
|
13171
13192
|
exports.useTab = useTab;
|
|
13172
13193
|
exports.useTableController = useTableController;
|
|
13173
13194
|
exports.useTableService = useTableService;
|
|
@@ -13183,6 +13204,9 @@ exports.useTreeItemContext = useTreeItemContext;
|
|
|
13183
13204
|
exports.useTreeSelectController = useTreeSelectController;
|
|
13184
13205
|
exports.useTreeService = useTreeService;
|
|
13185
13206
|
exports.useTreeState = useTreeState;
|
|
13207
|
+
exports.useWizardController = useWizardController;
|
|
13208
|
+
exports.useWizardService = useWizardService;
|
|
13209
|
+
exports.useWizardState = useWizardState;
|
|
13186
13210
|
exports.userSelect = userSelect;
|
|
13187
13211
|
exports.verticalAlign = verticalAlign;
|
|
13188
13212
|
exports.visibility = visibility;
|