onekijs-ui 0.15.6 → 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.
- package/dist/components/list/components/StandardListComponent.d.ts +0 -1
- package/dist/components/select/FormSelect.d.ts +1 -0
- package/dist/components/select/components/ArraySelectComponent.d.ts +1 -0
- package/dist/components/select/components/ArrayTreeSelectComponent.d.ts +1 -0
- package/dist/components/select/components/ControlledSelectComponent.d.ts +1 -0
- package/dist/components/select/components/SelectComponent.d.ts +1 -0
- package/dist/components/select/components/SelectOptionComponent.d.ts +1 -0
- package/dist/components/select/components/SelectTokenComponent.d.ts +1 -0
- package/dist/components/select/components/SelectTokensComponent.d.ts +1 -0
- package/dist/components/select/components/TreeSelectComponent.d.ts +1 -0
- package/dist/components/select/components/TreeSelectOptionContent.d.ts +1 -0
- package/dist/components/select/typings.d.ts +1 -1
- package/dist/components/tree/components/ArrayTreeComponent.d.ts +1 -0
- package/dist/components/tree/components/ControllerTreeComponent.d.ts +1 -0
- package/dist/components/tree/components/TreeBodyComponent.d.ts +1 -0
- package/dist/components/tree/components/TreeComponent.d.ts +1 -0
- package/dist/components/tree/components/TreeItemComponent.d.ts +1 -0
- package/dist/components/tree/components/TreeListComponent.d.ts +1 -0
- package/dist/components/tree/components/VirtualTreeBodyComponent.d.ts +1 -0
- package/dist/components/tree/components/VirtualTreeListComponent.d.ts +1 -0
- package/dist/components/tree/index.d.ts +1 -0
- package/dist/components/wizard/components/FormStep.d.ts +4 -0
- package/dist/components/wizard/typings.d.ts +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +120 -96
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +120 -97
- package/dist/index.module.js.map +1 -1
- package/dist/styles/size.d.ts +6 -6
- package/dist/styles/typography.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/field/util.ts +1 -1
- package/src/components/list/components/StandardListComponent.tsx +2 -2
- package/src/components/select/typings.ts +1 -1
- package/src/components/table/FormTable.tsx +10 -1
- package/src/components/table/components/FormTableComponent.tsx +3 -1
- package/src/components/table/components/TableBodyCellComponent.tsx +1 -1
- package/src/components/table/components/cells/CheckboxCellComponent.tsx +4 -15
- package/src/components/table/components/cells/InputCellComponent.tsx +5 -1
- package/src/components/table/components/cells/SelectCellComponent.tsx +4 -1
- package/src/components/table/components/cells/TextareaCellComponent.tsx +4 -1
- package/src/components/wizard/components/FormStep.tsx +26 -0
- package/src/components/wizard/components/WizardContainer.tsx +2 -0
- package/src/components/wizard/typings.ts +4 -0
- 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;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { ArrayTreeSelectProps, TreeSelectItem } from '../typings';
|
|
2
3
|
declare const ArrayTreeSelectComponent: <T = any, I extends TreeSelectItem<T> = TreeSelectItem<T>>(props: ArrayTreeSelectProps<T, I>) => JSX.Element;
|
|
3
4
|
export default ArrayTreeSelectComponent;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { ControllerSelectProps, SelectController, SelectItem, SelectState } from '../typings';
|
|
2
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;
|
|
3
4
|
export default ControlledSelectComponent;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { SelectController, SelectItem, SelectProps, SelectState } from '../typings';
|
|
2
3
|
declare const _default: {
|
|
3
4
|
<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>>(props: SelectProps<T, I, S, C>): JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { TreeSelectController, TreeSelectItem, TreeSelectProps, TreeSelectState } from '../typings';
|
|
2
3
|
declare const _default: {
|
|
3
4
|
<T = any, I extends TreeSelectItem<T> = TreeSelectItem<T>, S extends TreeSelectState<T, I> = TreeSelectState<T, I>, C extends TreeSelectController<T, I, S> = TreeSelectController<T, I, S>>(props: TreeSelectProps<T, I, S, C>): JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { ListItemProps } from '../../list/typings';
|
|
2
3
|
import { TreeSelectItem } from '../typings';
|
|
3
4
|
export declare const TreeSelectOptionContent: <T, I extends TreeSelectItem<T> = TreeSelectItem<T>>(props: ListItemProps<T, I>) => JSX.Element;
|
|
@@ -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;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { ControllerTreeProps, TreeItem } from '../typings';
|
|
2
3
|
declare const ControllerTreeComponent: {
|
|
3
4
|
<T = any, I extends TreeItem<T> = TreeItem<T>>({ controller, className, onActivate, onSelect, height, virtual, gap, TreeIconComponent, TreeItemComponent, TreeItemContentComponent, treeItemClassName, TreeTogglerComponent, paddingLeft, paddingRight, animate, keyboardNavigable, listRef, }: ControllerTreeProps<T, I, import("../typings").TreeState<T, I>, import("../typings").TreeController<T, I, import("../typings").TreeState<T, I>>>): JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { ControllerTreeProps, TreeItem } from '../typings';
|
|
2
3
|
declare const TreeBodyComponent: {
|
|
3
4
|
<T = any, I extends TreeItem<T> = TreeItem<T>>({ className, controller, }: ControllerTreeProps<T, I, import("../typings").TreeState<T, I>, import("../typings").TreeController<T, I, import("../typings").TreeState<T, I>>>): JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { TreeItem, TreeProps } from '../typings';
|
|
2
3
|
declare const _default: {
|
|
3
4
|
<T = any, I extends TreeItem<T> = TreeItem<T>>(props: TreeProps<T, I, import("../typings").TreeState<T, I>, import("../typings").TreeController<T, I, import("../typings").TreeState<T, I>>>): JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { ListItemProps } from '../../list/typings';
|
|
2
3
|
import { TreeItem, TreeItemProps, TreeItemToggleProps } from '../typings';
|
|
3
4
|
export declare const TreeItemToggler: <T = any, I extends TreeItem<T> = TreeItem<T>>({ item, onExpand, onCollapse, index, }: TreeItemToggleProps<T, I>) => JSX.Element | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { TreeItem, TreeListProps } from '../typings';
|
|
2
3
|
declare const TreeListComponent: <T = any, I extends TreeItem<T> = TreeItem<T>>({ items, onItemClick, onItemMouseEnter, onItemMouseLeave, }: TreeListProps<T, I>) => JSX.Element;
|
|
3
4
|
export default TreeListComponent;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { ControllerTreeProps, TreeItem } from '../typings';
|
|
2
3
|
declare const VirtualTreeBodyComponent: {
|
|
3
4
|
<T = any, I extends TreeItem<T> = TreeItem<T>>({ className, controller, height, }: ControllerTreeProps<T, I, import("../typings").TreeState<T, I>, import("../typings").TreeController<T, I, import("../typings").TreeState<T, I>>>): JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { TreeItem, VirtualTreeListProps } from '../typings';
|
|
2
3
|
declare const VirtualTreeListComponent: <T = any, I extends TreeItem<T> = TreeItem<T>>({ items, onItemClick, onItemMouseEnter, onItemMouseLeave, virtualItems, }: VirtualTreeListProps<T, I>) => JSX.Element;
|
|
3
4
|
export default VirtualTreeListComponent;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
declare const _default: {
|
|
2
3
|
<T = any, I extends import("./typings").TreeItem<T> = import("./typings").TreeItem<T>>(props: import("./typings").TreeProps<T, I, import("./typings").TreeState<T, I>, import("./typings").TreeController<T, I, import("./typings").TreeState<T, I>>>): JSX.Element;
|
|
3
4
|
displayName: string;
|
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 ||
|
|
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 }));
|
|
@@ -8709,7 +8797,7 @@ const TableBodyCellComponent = React__default["default"].memo((props) => {
|
|
|
8709
8797
|
service.initCell(rowIndex, column.id, ref);
|
|
8710
8798
|
}
|
|
8711
8799
|
});
|
|
8712
|
-
return (React__default["default"].createElement("div", { ref: ref, className: addClassname('o-table-body-cell', className), style: getCellWidth(column, fit, grow) }, props.item
|
|
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 })));
|
|
8713
8801
|
});
|
|
8714
8802
|
TableBodyCellComponent.displayName = 'TableCell';
|
|
8715
8803
|
|
|
@@ -9540,22 +9628,11 @@ const useFormTableContext = () => {
|
|
|
9540
9628
|
const CheckboxCellComponent = (options) => {
|
|
9541
9629
|
const CheckboxCellComponent = ({ item, column, rowIndex }) => {
|
|
9542
9630
|
const { tableName } = useFormTableContext();
|
|
9543
|
-
// const [validators] = extractValidators(options);
|
|
9544
|
-
// const field = useField(`${tableName}.${rowIndex}.${column.id}`, validators, {
|
|
9545
|
-
// defaultValue: options.defaultValue ? options.defaultValue : false,
|
|
9546
|
-
// });
|
|
9547
|
-
// const validation = useValidation(`${tableName}.${rowIndex}.${column.id}`);
|
|
9548
|
-
// const status = validation?.status;
|
|
9549
|
-
// const message = validation?.message;
|
|
9550
|
-
// return (
|
|
9551
|
-
// <>
|
|
9552
|
-
// <Checkbox {...options} {...field} className="o-table-checkbox" status={validation.status} />
|
|
9553
|
-
// {message && <FieldDescription content={message} className={`o-field-description-${status.toLowerCase()}`} />}
|
|
9554
|
-
// </>
|
|
9555
|
-
// );
|
|
9556
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}`;
|
|
9557
9634
|
const className = typeof options.className === 'function' ? options.className(item, column, rowIndex) : options.className;
|
|
9558
|
-
return (React__default["default"].createElement(FormCheckbox, { layout: "table", ...checkboxOptions, name:
|
|
9635
|
+
return (React__default["default"].createElement(FormCheckbox, { layout: "table", ...checkboxOptions, name: name, className: addClassname('o-table-checkbox', className) }));
|
|
9559
9636
|
};
|
|
9560
9637
|
CheckboxCellComponent.displayName = 'CheckboxCellComponent';
|
|
9561
9638
|
return CheckboxCellComponent;
|
|
@@ -9577,7 +9654,9 @@ const InputCellComponent = (options) => {
|
|
|
9577
9654
|
const InputCellComponent = ({ item, column, rowIndex }) => {
|
|
9578
9655
|
const { tableName } = useFormTableContext();
|
|
9579
9656
|
const className = typeof options.className === 'function' ? options.className(item, column, rowIndex) : options.className;
|
|
9580
|
-
|
|
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) }));
|
|
9581
9660
|
};
|
|
9582
9661
|
InputCellComponent.displayName = 'InputCellComponent';
|
|
9583
9662
|
return InputCellComponent;
|
|
@@ -9649,8 +9728,9 @@ const SelectCellComponent = (options, broker) => {
|
|
|
9649
9728
|
const { tableName } = useFormTableContext();
|
|
9650
9729
|
const controller = useSelectController(options.dataSource, options);
|
|
9651
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}`;
|
|
9652
9733
|
const className = typeof options.className === 'function' ? options.className(item, column, rowIndex) : options.className;
|
|
9653
|
-
const name = `${tableName}.${rowIndex}.${column.id}`;
|
|
9654
9734
|
React.useEffect(() => {
|
|
9655
9735
|
broker.addSubscriber(name, service);
|
|
9656
9736
|
return () => {
|
|
@@ -9795,8 +9875,10 @@ FormTextarea.displayName = 'FormTextarea';
|
|
|
9795
9875
|
const TextareaCellComponent = (options) => {
|
|
9796
9876
|
const TextareaCellComponent = ({ item, column, rowIndex }) => {
|
|
9797
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}`;
|
|
9798
9880
|
const className = typeof options.className === 'function' ? options.className(item, column, rowIndex) : options.className;
|
|
9799
|
-
return (React__default["default"].createElement(FormTextarea, { size: "small", layout: "table", ...options, name:
|
|
9881
|
+
return (React__default["default"].createElement(FormTextarea, { size: "small", layout: "table", ...options, name: name, className: addClassname('o-table-textarea', className) }));
|
|
9800
9882
|
};
|
|
9801
9883
|
TextareaCellComponent.displayName = 'TextareaCellComponent';
|
|
9802
9884
|
return TextareaCellComponent;
|
|
@@ -9901,8 +9983,9 @@ const SelectRowComponent = ({ item }) => {
|
|
|
9901
9983
|
const FooterComponent = () => {
|
|
9902
9984
|
const form = onekijsFramework.useForm();
|
|
9903
9985
|
const { tableName, addLabel, maxLength } = useFormTableContext();
|
|
9986
|
+
const isSingleColumnTable = useTableColumns().find((c) => c.id === '');
|
|
9904
9987
|
const addRow = (e) => {
|
|
9905
|
-
form.add(tableName);
|
|
9988
|
+
form.add(tableName, isSingleColumnTable ? undefined : {});
|
|
9906
9989
|
e.preventDefault();
|
|
9907
9990
|
};
|
|
9908
9991
|
const currentSize = (form.getValue(tableName) || []).length;
|
|
@@ -9992,8 +10075,17 @@ const StyledFormTableComponent = styled__default["default"](FormTableComponent)
|
|
|
9992
10075
|
${tableStyle}
|
|
9993
10076
|
`;
|
|
9994
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
|
+
}
|
|
9995
10087
|
const [fieldLayoutProps, fieldComponentProps] = useFieldLayout(Object.assign({
|
|
9996
|
-
defaultValue
|
|
10088
|
+
defaultValue,
|
|
9997
10089
|
}, props));
|
|
9998
10090
|
const Component = props.FieldComponent || StyledFormTableComponent;
|
|
9999
10091
|
return (React__default["default"].createElement(FieldLayout, { ...fieldLayoutProps, required: props.required },
|
|
@@ -10055,17 +10147,6 @@ const Tag = styled__default["default"](TagComponent) `
|
|
|
10055
10147
|
${tagStyle}
|
|
10056
10148
|
`;
|
|
10057
10149
|
|
|
10058
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
10059
|
-
const WizardServiceContext = React__default["default"].createContext(null);
|
|
10060
|
-
const useWizardService = () => {
|
|
10061
|
-
return React.useContext(WizardServiceContext);
|
|
10062
|
-
};
|
|
10063
|
-
|
|
10064
|
-
const WizardStateContext = React__default["default"].createContext(null);
|
|
10065
|
-
const useWizardState = () => {
|
|
10066
|
-
return React.useContext(WizardStateContext);
|
|
10067
|
-
};
|
|
10068
|
-
|
|
10069
10150
|
const StepTitle = ({ member, onActivate, index }) => {
|
|
10070
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) },
|
|
10071
10152
|
member.icon,
|
|
@@ -10097,6 +10178,9 @@ const WizardContainer = ({ cancelLabel = 'Cancel', className, children, doneLabe
|
|
|
10097
10178
|
if (step.visible) {
|
|
10098
10179
|
indexRef.current++;
|
|
10099
10180
|
}
|
|
10181
|
+
else {
|
|
10182
|
+
return null;
|
|
10183
|
+
}
|
|
10100
10184
|
if (step.error !== undefined) {
|
|
10101
10185
|
errorRef.current.push({
|
|
10102
10186
|
stepIndex: indexRef.current,
|
|
@@ -10430,67 +10514,6 @@ const Wizard = styled__default["default"](WizardComponent) `
|
|
|
10430
10514
|
${wizardStyle}
|
|
10431
10515
|
`;
|
|
10432
10516
|
|
|
10433
|
-
const useStep = (props) => {
|
|
10434
|
-
const service = useWizardService();
|
|
10435
|
-
const state = useWizardState();
|
|
10436
|
-
const step = state.members[state.membersIndex[props.uid]];
|
|
10437
|
-
React.useEffect(() => {
|
|
10438
|
-
if (step === undefined) {
|
|
10439
|
-
service.initMember(Object.assign({ uid: props.uid }, props));
|
|
10440
|
-
}
|
|
10441
|
-
}, [props, service, step]);
|
|
10442
|
-
return step;
|
|
10443
|
-
};
|
|
10444
|
-
|
|
10445
|
-
const Step = ({ title, active = false, disabled = false, visible = true, closable = false, children, icon, uid, optional = false, showTitle = true, className, }) => {
|
|
10446
|
-
const { animate, forwardOnly } = useWizardState();
|
|
10447
|
-
const service = useWizardService();
|
|
10448
|
-
const step = useStep({
|
|
10449
|
-
title,
|
|
10450
|
-
active,
|
|
10451
|
-
disabled,
|
|
10452
|
-
visible,
|
|
10453
|
-
closable,
|
|
10454
|
-
icon,
|
|
10455
|
-
loading: false,
|
|
10456
|
-
optional,
|
|
10457
|
-
touched: !forwardOnly,
|
|
10458
|
-
touching: !forwardOnly,
|
|
10459
|
-
uid: uid === undefined ? title : uid,
|
|
10460
|
-
});
|
|
10461
|
-
const fieldContainer = onekijsFramework.useFieldContainer({
|
|
10462
|
-
onValidationChange: (touchedValidation, allValidation) => {
|
|
10463
|
-
if (step) {
|
|
10464
|
-
service.onValidationChange(step.uid, touchedValidation, allValidation);
|
|
10465
|
-
}
|
|
10466
|
-
},
|
|
10467
|
-
});
|
|
10468
|
-
const touched = step?.touched;
|
|
10469
|
-
const touchAllFields = fieldContainer.touchAllFields;
|
|
10470
|
-
const onEnter = (node) => {
|
|
10471
|
-
node.style.opacity = '0';
|
|
10472
|
-
};
|
|
10473
|
-
const onEntering = (node) => {
|
|
10474
|
-
setTimeout(() => {
|
|
10475
|
-
node.style.opacity = '1';
|
|
10476
|
-
node.style.transition = `opacity ${animate}ms ease-in-out`;
|
|
10477
|
-
}, 0);
|
|
10478
|
-
};
|
|
10479
|
-
React.useEffect(() => {
|
|
10480
|
-
if (touched) {
|
|
10481
|
-
touchAllFields();
|
|
10482
|
-
}
|
|
10483
|
-
}, [touched, touchAllFields]);
|
|
10484
|
-
if (!step || !step.active) {
|
|
10485
|
-
return null;
|
|
10486
|
-
}
|
|
10487
|
-
return (React__default["default"].createElement(onekijsFramework.FormContext.Provider, { value: fieldContainer.context },
|
|
10488
|
-
React__default["default"].createElement(reactTransitionGroup.CSSTransition, { in: true, timeout: animate, appear: true, onEnter: onEnter, onEntering: onEntering },
|
|
10489
|
-
React__default["default"].createElement("div", { className: addClassname('o-step-content', className) },
|
|
10490
|
-
showTitle && React__default["default"].createElement("div", { className: "o-step-content-title" }, title),
|
|
10491
|
-
children))));
|
|
10492
|
-
};
|
|
10493
|
-
|
|
10494
10517
|
const WizardModalComponent = ({ title, doneLabel = 'Submit', ...props }) => {
|
|
10495
10518
|
return (React__default["default"].createElement(Modal, { ...props },
|
|
10496
10519
|
React__default["default"].createElement(Wizard, { ...props, title: title, doneLabel: doneLabel, inModal: true })));
|
|
@@ -11425,10 +11448,11 @@ exports.FieldLayout = FieldLayout;
|
|
|
11425
11448
|
exports.FieldLayoutComponent = FieldLayoutComponent;
|
|
11426
11449
|
exports.FileIcon = FileIcon;
|
|
11427
11450
|
exports.FolderIcon = FolderIcon;
|
|
11428
|
-
exports.FormCard = FormCard;
|
|
11451
|
+
exports.FormCard = FormCard$1;
|
|
11429
11452
|
exports.FormCheckbox = FormCheckbox;
|
|
11430
11453
|
exports.FormInput = FormInput;
|
|
11431
11454
|
exports.FormSelect = FormSelect$1;
|
|
11455
|
+
exports.FormStep = FormCard;
|
|
11432
11456
|
exports.FormTable = FormTable;
|
|
11433
11457
|
exports.FormTextarea = FormTextarea;
|
|
11434
11458
|
exports.Input = Input;
|