@ssa-ui-kit/core 2.14.0 → 2.15.0-canary-3fd3271-20250501
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/Icon/icons/ExcelDownload.d.ts +3 -0
- package/dist/components/Icon/icons/FilterFunnel.d.ts +3 -0
- package/dist/components/Icon/icons/all.d.ts +2 -0
- package/dist/components/Icon/icons/iconsList.d.ts +1 -1
- package/dist/components/Typeahead/Typeahead.context.d.ts +12 -12
- package/dist/components/Typeahead/Typeahead.d.ts +1 -1
- package/dist/components/Typeahead/types.d.ts +5 -4
- package/dist/components/Typeahead/useTypeahead.d.ts +16 -15
- package/dist/index.js +311 -252
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -520,6 +520,14 @@ __webpack_require__.d(Employee_namespaceObject, {
|
|
|
520
520
|
ICON_NAME: () => (Employee_ICON_NAME)
|
|
521
521
|
});
|
|
522
522
|
|
|
523
|
+
// NAMESPACE OBJECT: ./src/components/Icon/icons/ExcelDownload.tsx
|
|
524
|
+
var ExcelDownload_namespaceObject = {};
|
|
525
|
+
__webpack_require__.r(ExcelDownload_namespaceObject);
|
|
526
|
+
__webpack_require__.d(ExcelDownload_namespaceObject, {
|
|
527
|
+
ExcelDownload: () => (ExcelDownload),
|
|
528
|
+
ICON_NAME: () => (ExcelDownload_ICON_NAME)
|
|
529
|
+
});
|
|
530
|
+
|
|
523
531
|
// NAMESPACE OBJECT: ./src/components/Icon/icons/Expertise.tsx
|
|
524
532
|
var Expertise_namespaceObject = {};
|
|
525
533
|
__webpack_require__.r(Expertise_namespaceObject);
|
|
@@ -536,6 +544,14 @@ __webpack_require__.d(Filter_namespaceObject, {
|
|
|
536
544
|
ICON_NAME: () => (Filter_ICON_NAME)
|
|
537
545
|
});
|
|
538
546
|
|
|
547
|
+
// NAMESPACE OBJECT: ./src/components/Icon/icons/FilterFunnel.tsx
|
|
548
|
+
var FilterFunnel_namespaceObject = {};
|
|
549
|
+
__webpack_require__.r(FilterFunnel_namespaceObject);
|
|
550
|
+
__webpack_require__.d(FilterFunnel_namespaceObject, {
|
|
551
|
+
FilterFunnel: () => (FilterFunnel),
|
|
552
|
+
ICON_NAME: () => (FilterFunnel_ICON_NAME)
|
|
553
|
+
});
|
|
554
|
+
|
|
539
555
|
// NAMESPACE OBJECT: ./src/components/Icon/icons/Geography.tsx
|
|
540
556
|
var Geography_namespaceObject = {};
|
|
541
557
|
__webpack_require__.r(Geography_namespaceObject);
|
|
@@ -873,8 +889,10 @@ __webpack_require__.d(all_namespaceObject, {
|
|
|
873
889
|
Edit: () => (Edit_namespaceObject),
|
|
874
890
|
Email: () => (Email_namespaceObject),
|
|
875
891
|
Employee: () => (Employee_namespaceObject),
|
|
892
|
+
ExcelDownload: () => (ExcelDownload_namespaceObject),
|
|
876
893
|
Expertise: () => (Expertise_namespaceObject),
|
|
877
894
|
Filter: () => (Filter_namespaceObject),
|
|
895
|
+
FilterFunnel: () => (FilterFunnel_namespaceObject),
|
|
878
896
|
Geography: () => (Geography_namespaceObject),
|
|
879
897
|
Home: () => (Home_namespaceObject),
|
|
880
898
|
Import: () => (Import_namespaceObject),
|
|
@@ -2596,6 +2614,36 @@ const Employee = ({
|
|
|
2596
2614
|
})]
|
|
2597
2615
|
});
|
|
2598
2616
|
const Employee_ICON_NAME = 'employee';
|
|
2617
|
+
;// ./src/components/Icon/icons/ExcelDownload.tsx
|
|
2618
|
+
|
|
2619
|
+
const ExcelDownload = ({
|
|
2620
|
+
fill = '#000',
|
|
2621
|
+
size = 24,
|
|
2622
|
+
tooltip = 'Excel download',
|
|
2623
|
+
...props
|
|
2624
|
+
}) => (0,jsx_runtime_namespaceObject.jsxs)("svg", {
|
|
2625
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2626
|
+
width: `${size}px`,
|
|
2627
|
+
height: `${size}px`,
|
|
2628
|
+
viewBox: "0 0 24 24",
|
|
2629
|
+
fill: "none",
|
|
2630
|
+
...props,
|
|
2631
|
+
children: [(0,jsx_runtime_namespaceObject.jsx)("title", {
|
|
2632
|
+
children: tooltip
|
|
2633
|
+
}), (0,jsx_runtime_namespaceObject.jsx)("path", {
|
|
2634
|
+
fillRule: "evenodd",
|
|
2635
|
+
clipRule: "evenodd",
|
|
2636
|
+
d: "M6.04815 2C4.81157 2 3.7998 3.01813 3.7998 4.2625V17.7375C3.7998 18.9819 4.81157 20 6.04815 20H14.0058C13.6986 19.7203 13.5334 19.34 13.5176 18.9524H6.04815C5.37634 18.9524 4.84083 18.4135 4.84083 17.7375V4.2625C4.84083 3.58646 5.37634 3.04757 6.04815 3.04757H11.986C11.9879 3.04857 11.9915 3.05051 11.9972 3.05405L11.9999 3.05572L12.007 3.06013V6.00121C12.007 6.47167 12.1866 6.90245 12.4801 7.22748C12.8131 7.59634 13.2929 7.82903 13.8234 7.82903H16.7549L16.7586 9.39603V11.686C17.008 11.3746 17.3791 11.1648 17.7997 11.1287L17.7998 7.32704L17.7976 7.29664C17.7953 7.26342 17.792 7.21583 17.7895 7.20309C17.7694 7.1015 17.7199 7.00816 17.6471 6.9349L13.2753 2.53554C12.9348 2.19237 12.4726 2 11.991 2H6.04815ZM3.7998 4.2625L3.88836 4.29517V4.29274L3.7998 4.2625ZM13.048 6.00121V3.78825L16.0225 6.78145H13.8234C13.39 6.78145 13.048 6.43738 13.048 6.00121Z",
|
|
2637
|
+
fill: fill
|
|
2638
|
+
}), (0,jsx_runtime_namespaceObject.jsx)("path", {
|
|
2639
|
+
d: "M9.86867 12.4996L7.97338 9H9.74921L10.6803 11.0954C10.7534 11.2606 10.8189 11.4641 10.8757 11.6923H10.8862C10.9229 11.5562 10.9932 11.3425 11.0921 11.0718L12.121 9H13.7457L11.8068 12.4647L13.7998 16H12.0774L10.9516 13.717C10.9099 13.6323 10.8662 13.4775 10.8216 13.2492H10.8103C10.7888 13.3558 10.7377 13.5224 10.6593 13.7406L9.53276 15.9992H7.7998L9.86867 12.4996Z",
|
|
2640
|
+
fill: fill
|
|
2641
|
+
}), (0,jsx_runtime_namespaceObject.jsx)("path", {
|
|
2642
|
+
d: "M17.9128 11.9231C18.2994 11.9231 18.6128 12.2365 18.6128 12.6231V19.8599L20.372 18.359C20.6661 18.108 21.1079 18.143 21.3589 18.4371C21.6098 18.7312 21.5748 19.1731 21.2807 19.424L18.3677 21.9094C18.2212 22.0344 18.036 22.0895 17.8553 22.0745C17.6994 22.0618 17.5579 21.998 17.4476 21.8999L14.5003 19.4278C14.2041 19.1794 14.1654 18.7378 14.4138 18.4416C14.6623 18.1454 15.1038 18.1067 15.4 18.3552L17.2128 19.8757V12.6231C17.2128 12.2365 17.5262 11.9231 17.9128 11.9231Z",
|
|
2643
|
+
fill: fill
|
|
2644
|
+
})]
|
|
2645
|
+
});
|
|
2646
|
+
const ExcelDownload_ICON_NAME = 'excel-download';
|
|
2599
2647
|
;// ./src/components/Icon/icons/Expertise.tsx
|
|
2600
2648
|
|
|
2601
2649
|
const Expertise = ({
|
|
@@ -2647,6 +2695,33 @@ const Filter = ({
|
|
|
2647
2695
|
})]
|
|
2648
2696
|
});
|
|
2649
2697
|
const Filter_ICON_NAME = 'filter';
|
|
2698
|
+
;// ./src/components/Icon/icons/FilterFunnel.tsx
|
|
2699
|
+
|
|
2700
|
+
const FilterFunnel = ({
|
|
2701
|
+
fill = '#000',
|
|
2702
|
+
size = 24,
|
|
2703
|
+
tooltip = 'Filter funnel',
|
|
2704
|
+
...props
|
|
2705
|
+
}) => (0,jsx_runtime_namespaceObject.jsxs)("svg", {
|
|
2706
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2707
|
+
width: `${size}px`,
|
|
2708
|
+
height: `${size}px`,
|
|
2709
|
+
viewBox: "0 0 20 20",
|
|
2710
|
+
fill: "none",
|
|
2711
|
+
...props,
|
|
2712
|
+
children: [(0,jsx_runtime_namespaceObject.jsx)("title", {
|
|
2713
|
+
children: tooltip
|
|
2714
|
+
}), (0,jsx_runtime_namespaceObject.jsx)("path", {
|
|
2715
|
+
d: "M2.73438 2.5C2.605 2.5 2.5 2.605 2.5 2.73438V4.60938C2.5 4.66281 2.51846 4.71461 2.55127 4.75586L8.125 11.723V15.9116C8.125 16.0067 8.182 16.0915 8.26965 16.1276L11.5509 17.4826C11.58 17.4943 11.6106 17.5 11.6406 17.5C11.6866 17.5 11.7313 17.4864 11.7706 17.4606C11.8358 17.417 11.875 17.3439 11.875 17.2656V11.723L17.4487 4.75586C17.4815 4.71461 17.5 4.66281 17.5 4.60938V2.73438C17.5 2.605 17.395 2.5 17.2656 2.5H2.73438ZM2.96875 2.96875H17.0312V4.52698L11.528 11.4062H8.47198L2.96875 4.52698V2.96875ZM8.59375 11.875H11.4062V16.9159L8.59375 15.755V11.875Z",
|
|
2716
|
+
fill: fill
|
|
2717
|
+
}), (0,jsx_runtime_namespaceObject.jsx)("path", {
|
|
2718
|
+
fillRule: "evenodd",
|
|
2719
|
+
clipRule: "evenodd",
|
|
2720
|
+
d: "M2.73438 2.25C2.46693 2.25 2.25 2.46693 2.25 2.73438V4.60938C2.25 4.7201 2.28853 4.82714 2.35605 4.91203L7.875 11.8107V15.6701C7.875 15.6701 7.86214 16.0606 7.91666 16.1667C7.98574 16.3011 8.17447 16.3588 8.17447 16.3588L11.4555 17.7137L11.4574 17.7145C11.5169 17.7385 11.5794 17.75 11.6406 17.75C11.7368 17.75 11.8288 17.7214 11.9076 17.6698L11.9096 17.6684C12.0438 17.5786 12.125 17.4277 12.125 17.2656V11.8107L17.6444 4.91149C17.7119 4.8266 17.75 4.7201 17.75 4.60938V2.73438C17.75 2.46693 17.5331 2.25 17.2656 2.25H2.73438ZM16.7812 3.21875H3.21875V4.43928L8.59214 11.1562H11.4079L16.7812 4.43928V3.21875ZM8.84375 12.125V15.5877L11.1562 16.5422V12.125H8.84375Z",
|
|
2721
|
+
fill: fill
|
|
2722
|
+
})]
|
|
2723
|
+
});
|
|
2724
|
+
const FilterFunnel_ICON_NAME = 'filter-funnel';
|
|
2650
2725
|
;// ./src/components/Icon/icons/Geography.tsx
|
|
2651
2726
|
|
|
2652
2727
|
const Geography = ({
|
|
@@ -3934,6 +4009,10 @@ const Warning_ICON_NAME = 'warning';
|
|
|
3934
4009
|
|
|
3935
4010
|
|
|
3936
4011
|
|
|
4012
|
+
|
|
4013
|
+
|
|
4014
|
+
|
|
4015
|
+
|
|
3937
4016
|
|
|
3938
4017
|
|
|
3939
4018
|
|
|
@@ -17435,6 +17514,7 @@ const TypeaheadContext = /*#__PURE__*/external_react_namespaceObject.createConte
|
|
|
17435
17514
|
options: [],
|
|
17436
17515
|
placeholder: '',
|
|
17437
17516
|
useFormResult: {},
|
|
17517
|
+
error: undefined,
|
|
17438
17518
|
setValue: () => {
|
|
17439
17519
|
/* no-op */
|
|
17440
17520
|
},
|
|
@@ -17442,7 +17522,7 @@ const TypeaheadContext = /*#__PURE__*/external_react_namespaceObject.createConte
|
|
|
17442
17522
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
17443
17523
|
return {};
|
|
17444
17524
|
},
|
|
17445
|
-
|
|
17525
|
+
onChange: () => {
|
|
17446
17526
|
/* no-op */
|
|
17447
17527
|
},
|
|
17448
17528
|
handleClearAll: () => {
|
|
@@ -17462,9 +17542,6 @@ const TypeaheadContext = /*#__PURE__*/external_react_namespaceObject.createConte
|
|
|
17462
17542
|
},
|
|
17463
17543
|
handleRemoveSelectedClick: () => () => {
|
|
17464
17544
|
/* no-op */
|
|
17465
|
-
},
|
|
17466
|
-
handleSelectedClick: () => {
|
|
17467
|
-
/* no-op */
|
|
17468
17545
|
}
|
|
17469
17546
|
});
|
|
17470
17547
|
const useTypeaheadContext = () => external_react_namespaceObject.useContext(TypeaheadContext);
|
|
@@ -17472,10 +17549,18 @@ const useTypeaheadContext = () => external_react_namespaceObject.useContext(Type
|
|
|
17472
17549
|
|
|
17473
17550
|
|
|
17474
17551
|
|
|
17552
|
+
const findExactMatch = (input, options) => {
|
|
17553
|
+
const normalizedInput = input.toLowerCase();
|
|
17554
|
+
return Object.values(options).find(opt => {
|
|
17555
|
+
const labelText = (opt.label ?? opt.value).toString().toLowerCase();
|
|
17556
|
+
return labelText === normalizedInput;
|
|
17557
|
+
});
|
|
17558
|
+
};
|
|
17475
17559
|
const useTypeahead = ({
|
|
17476
17560
|
name = 'typeahead-input',
|
|
17477
17561
|
isOpen: isInitOpen,
|
|
17478
17562
|
selectedItems,
|
|
17563
|
+
defaultSelectedItems,
|
|
17479
17564
|
isDisabled,
|
|
17480
17565
|
isMultiple,
|
|
17481
17566
|
children,
|
|
@@ -17488,8 +17573,8 @@ const useTypeahead = ({
|
|
|
17488
17573
|
error,
|
|
17489
17574
|
success,
|
|
17490
17575
|
placeholder,
|
|
17491
|
-
|
|
17492
|
-
|
|
17576
|
+
filterOptions = true,
|
|
17577
|
+
autoSelect = true,
|
|
17493
17578
|
onChange,
|
|
17494
17579
|
onClearAll,
|
|
17495
17580
|
onRemoveSelectedClick,
|
|
@@ -17497,266 +17582,240 @@ const useTypeahead = ({
|
|
|
17497
17582
|
renderOption
|
|
17498
17583
|
}) => {
|
|
17499
17584
|
const inputName = `${name}-text`;
|
|
17500
|
-
const [isOpen,
|
|
17501
|
-
|
|
17502
|
-
|
|
17503
|
-
|
|
17504
|
-
const [
|
|
17505
|
-
|
|
17506
|
-
|
|
17507
|
-
|
|
17508
|
-
|
|
17509
|
-
const
|
|
17510
|
-
const
|
|
17585
|
+
const [isOpen, _setIsOpen] = (0,hooks_namespaceObject.useUncontrolled)({
|
|
17586
|
+
defaultValue: isInitOpen,
|
|
17587
|
+
finalValue: false
|
|
17588
|
+
});
|
|
17589
|
+
const [selected, setSelected] = (0,hooks_namespaceObject.useUncontrolled)({
|
|
17590
|
+
value: selectedItems,
|
|
17591
|
+
defaultValue: defaultSelectedItems,
|
|
17592
|
+
finalValue: []
|
|
17593
|
+
});
|
|
17594
|
+
const [rawInput, setRawInput] = (0,external_react_namespaceObject.useState)(null);
|
|
17595
|
+
const {
|
|
17596
|
+
ref: inputRef
|
|
17597
|
+
} = (0,hooks_namespaceObject.useElementSize)();
|
|
17511
17598
|
const triggerRef = (0,external_react_namespaceObject.useRef)(null);
|
|
17512
|
-
const
|
|
17599
|
+
const defaultForm = (0,external_react_hook_form_namespaceObject.useForm)();
|
|
17600
|
+
const form = (0,external_react_hook_form_namespaceObject.useFormContext)() ?? defaultForm;
|
|
17601
|
+
const {
|
|
17602
|
+
register,
|
|
17603
|
+
setValue
|
|
17604
|
+
} = form;
|
|
17513
17605
|
(0,external_react_namespaceObject.useEffect)(() => {
|
|
17514
|
-
if (!
|
|
17515
|
-
|
|
17606
|
+
if (!selected.length) {
|
|
17607
|
+
return;
|
|
17516
17608
|
}
|
|
17517
|
-
}, []);
|
|
17518
|
-
(0,external_react_namespaceObject.useEffect)(() => {
|
|
17519
17609
|
if (isMultiple) {
|
|
17520
17610
|
setValue?.(name, selected, {
|
|
17521
|
-
shouldDirty:
|
|
17611
|
+
shouldDirty: false
|
|
17522
17612
|
});
|
|
17523
|
-
setInputValue('');
|
|
17524
|
-
setFirstSuggestion('');
|
|
17525
17613
|
} else {
|
|
17526
|
-
setValue?.(name, selected
|
|
17527
|
-
shouldDirty:
|
|
17614
|
+
setValue?.(name, selected[0], {
|
|
17615
|
+
shouldDirty: false
|
|
17528
17616
|
});
|
|
17529
17617
|
}
|
|
17530
|
-
|
|
17531
|
-
|
|
17532
|
-
(0,external_react_namespaceObject.
|
|
17533
|
-
|
|
17534
|
-
|
|
17535
|
-
|
|
17536
|
-
|
|
17537
|
-
|
|
17538
|
-
const status = success ? 'success' : useFormResult.formState.errors[name] ? 'error' : 'basic';
|
|
17539
|
-
setStatus(status);
|
|
17540
|
-
}, [useFormResult.formState.errors[name], success]);
|
|
17541
|
-
(0,external_react_namespaceObject.useEffect)(() => {
|
|
17542
|
-
if (error) {
|
|
17543
|
-
useFormResult.setError(name, error);
|
|
17544
|
-
} else {
|
|
17545
|
-
setStatus('basic');
|
|
17546
|
-
useFormResult.resetField(name);
|
|
17547
|
-
}
|
|
17548
|
-
}, [error]);
|
|
17549
|
-
(0,external_react_namespaceObject.useEffect)(() => {
|
|
17550
|
-
processChildren({
|
|
17551
|
-
selectedLocal: selected
|
|
17618
|
+
}, []);
|
|
17619
|
+
const typeaheadId = (0,external_react_namespaceObject.useId)();
|
|
17620
|
+
const optionsWithKey = (0,external_react_namespaceObject.useMemo)(() => {
|
|
17621
|
+
const opts = {};
|
|
17622
|
+
external_react_default().Children.forEach(children, child => {
|
|
17623
|
+
if (/*#__PURE__*/external_react_default().isValidElement(child)) {
|
|
17624
|
+
opts[child.props.value] = child.props;
|
|
17625
|
+
}
|
|
17552
17626
|
});
|
|
17627
|
+
return opts;
|
|
17553
17628
|
}, [children]);
|
|
17554
|
-
(0,external_react_namespaceObject.
|
|
17555
|
-
|
|
17556
|
-
if (
|
|
17557
|
-
|
|
17558
|
-
|
|
17559
|
-
|
|
17560
|
-
|
|
17561
|
-
|
|
17562
|
-
|
|
17563
|
-
|
|
17564
|
-
|
|
17565
|
-
|
|
17566
|
-
|
|
17567
|
-
|
|
17629
|
+
const inputValue = (0,external_react_namespaceObject.useMemo)(() => {
|
|
17630
|
+
if (isMultiple) return rawInput ?? '';
|
|
17631
|
+
if (rawInput != null) return rawInput;
|
|
17632
|
+
return selected.length === 1 ? optionsWithKey[selected[0]]?.label?.toString() || '' : '';
|
|
17633
|
+
}, [isMultiple, rawInput, selected, optionsWithKey]);
|
|
17634
|
+
const filteredChildren = (0,external_react_namespaceObject.useMemo)(() => {
|
|
17635
|
+
// if filtering is disabled, or there's no input, show all
|
|
17636
|
+
if (!filterOptions || !inputValue) return external_react_default().Children.toArray(children);
|
|
17637
|
+
const needle = inputValue.toLowerCase();
|
|
17638
|
+
return external_react_default().Children.toArray(children).filter(child => {
|
|
17639
|
+
if (! /*#__PURE__*/external_react_default().isValidElement(child)) return false;
|
|
17640
|
+
const {
|
|
17641
|
+
label,
|
|
17642
|
+
value
|
|
17643
|
+
} = child.props;
|
|
17644
|
+
const text = (label ?? value)?.toString().toLowerCase() || '';
|
|
17645
|
+
return text.includes(needle);
|
|
17568
17646
|
});
|
|
17569
|
-
}, [
|
|
17570
|
-
(0,external_react_namespaceObject.
|
|
17571
|
-
|
|
17572
|
-
|
|
17573
|
-
|
|
17647
|
+
}, [children, inputValue]);
|
|
17648
|
+
const items = (0,external_react_namespaceObject.useMemo)(() => {
|
|
17649
|
+
return filteredChildren.map((child, index) => {
|
|
17650
|
+
if (! /*#__PURE__*/external_react_default().isValidElement(child)) return null;
|
|
17651
|
+
const isActive = selected.includes(child.props.value);
|
|
17574
17652
|
const {
|
|
17575
|
-
id,
|
|
17576
17653
|
value,
|
|
17577
17654
|
label,
|
|
17655
|
+
id,
|
|
17578
17656
|
isDisabled
|
|
17579
17657
|
} = child.props;
|
|
17580
|
-
const isActive = selected.includes(child.props.value);
|
|
17581
17658
|
return /*#__PURE__*/external_react_default().cloneElement(child, {
|
|
17582
|
-
index,
|
|
17583
17659
|
...child.props,
|
|
17660
|
+
index,
|
|
17584
17661
|
isActive,
|
|
17585
17662
|
isDisabled,
|
|
17586
|
-
|
|
17663
|
+
role: 'option',
|
|
17587
17664
|
'aria-selected': isActive,
|
|
17588
17665
|
'aria-labelledby': `typeahead-label-${name}`,
|
|
17589
|
-
|
|
17590
|
-
|
|
17591
|
-
event.preventDefault();
|
|
17666
|
+
onClick: e => {
|
|
17667
|
+
e.preventDefault();
|
|
17592
17668
|
if (!isDisabled) {
|
|
17593
|
-
|
|
17669
|
+
const shouldClose = !isMultiple;
|
|
17670
|
+
handleChange({
|
|
17671
|
+
value,
|
|
17672
|
+
shouldClose
|
|
17673
|
+
});
|
|
17594
17674
|
}
|
|
17595
17675
|
},
|
|
17596
|
-
children: renderOption
|
|
17676
|
+
children: renderOption?.({
|
|
17597
17677
|
value: id || value,
|
|
17598
|
-
input: inputValue
|
|
17678
|
+
input: inputValue,
|
|
17599
17679
|
label
|
|
17600
|
-
})
|
|
17680
|
+
}) ?? child.props.children ?? label ?? value
|
|
17601
17681
|
});
|
|
17602
17682
|
});
|
|
17603
|
-
|
|
17604
|
-
|
|
17605
|
-
|
|
17606
|
-
|
|
17607
|
-
|
|
17608
|
-
if (!
|
|
17609
|
-
|
|
17610
|
-
|
|
17611
|
-
|
|
17612
|
-
setSelected([foundItem.value]);
|
|
17683
|
+
}, [children, selected, inputValue]);
|
|
17684
|
+
const firstSuggestion = (0,external_react_namespaceObject.useMemo)(() => {
|
|
17685
|
+
if (!inputValue) return '';
|
|
17686
|
+
const needle = inputValue.toLowerCase();
|
|
17687
|
+
for (const child of filteredChildren) {
|
|
17688
|
+
if (! /*#__PURE__*/external_react_default().isValidElement(child)) continue;
|
|
17689
|
+
const labelText = (child.props.label ?? child.props.value).toString();
|
|
17690
|
+
if (labelText.toLowerCase().startsWith(needle)) {
|
|
17691
|
+
return inputValue + labelText.slice(inputValue.length);
|
|
17613
17692
|
}
|
|
17614
17693
|
}
|
|
17615
|
-
|
|
17616
|
-
|
|
17617
|
-
|
|
17618
|
-
|
|
17619
|
-
|
|
17620
|
-
});
|
|
17621
|
-
}, [selected]);
|
|
17622
|
-
(0,external_react_namespaceObject.useEffect)(() => {
|
|
17623
|
-
if (inputValue) {
|
|
17624
|
-
const newFirstSuggestion = Object.values(optionsWithKey)?.find(item => {
|
|
17625
|
-
const label = (0,utils_namespaceObject.propOr)('', 'label')(item);
|
|
17626
|
-
return label.toLowerCase().startsWith(inputValue.toLowerCase());
|
|
17627
|
-
});
|
|
17628
|
-
const firstSuggestionLabel = (0,utils_namespaceObject.propOr)('', 'label')(newFirstSuggestion);
|
|
17629
|
-
const humanSuggestionLabel = inputValue.concat(firstSuggestionLabel.slice(inputValue.length));
|
|
17630
|
-
setFirstSuggestion(humanSuggestionLabel);
|
|
17631
|
-
} else {
|
|
17632
|
-
setFirstSuggestion('');
|
|
17633
|
-
if (isMultiple) {
|
|
17634
|
-
setInputValue('');
|
|
17635
|
-
}
|
|
17636
|
-
}
|
|
17637
|
-
}, [inputValue, items, selected]);
|
|
17638
|
-
const processSingleSelected = ({
|
|
17639
|
-
optionsWithKeyLocal = {},
|
|
17640
|
-
selectedLocal = []
|
|
17641
|
-
}) => {
|
|
17642
|
-
if (!isMultiple && selectedLocal.length && Object.keys(optionsWithKeyLocal).length) {
|
|
17643
|
-
const currentOption = optionsWithKeyLocal[selectedLocal[0]];
|
|
17644
|
-
const optionText = currentOption && (currentOption.children || currentOption.label || currentOption.value);
|
|
17645
|
-
setInputValue(`${optionText}`);
|
|
17694
|
+
return '';
|
|
17695
|
+
}, [inputValue, filteredChildren]);
|
|
17696
|
+
const setIsOpen = open => {
|
|
17697
|
+
if (!open) {
|
|
17698
|
+
form.trigger();
|
|
17646
17699
|
}
|
|
17700
|
+
_setIsOpen(open);
|
|
17647
17701
|
};
|
|
17648
|
-
const
|
|
17649
|
-
|
|
17702
|
+
const handleChange = ({
|
|
17703
|
+
value,
|
|
17704
|
+
shouldClose = true,
|
|
17705
|
+
resetInput = true
|
|
17650
17706
|
}) => {
|
|
17651
|
-
|
|
17652
|
-
const
|
|
17653
|
-
|
|
17654
|
-
|
|
17655
|
-
|
|
17656
|
-
|
|
17657
|
-
|
|
17658
|
-
|
|
17659
|
-
|
|
17660
|
-
|
|
17661
|
-
setOptionsWithKey(keyedOptions);
|
|
17662
|
-
setItems(childItems);
|
|
17663
|
-
processSingleSelected({
|
|
17664
|
-
optionsWithKeyLocal: keyedOptions,
|
|
17665
|
-
selectedLocal
|
|
17666
|
-
});
|
|
17667
|
-
setFirstRender(false);
|
|
17668
|
-
};
|
|
17669
|
-
const handleOnEmptyChange = newIsEmptyValue => {
|
|
17670
|
-
if (newIsEmptyValue !== isEmpty) {
|
|
17671
|
-
setIsEmpty(newIsEmptyValue);
|
|
17672
|
-
onEmptyChange?.(newIsEmptyValue);
|
|
17707
|
+
if (isDisabled || value == null) return;
|
|
17708
|
+
const alreadySelected = selected.includes(value);
|
|
17709
|
+
const updatedSelected = isMultiple ? alreadySelected ? selected.filter(item => item !== value) : [...selected, value] : alreadySelected ? [] : [value];
|
|
17710
|
+
const fieldValue = isMultiple ? updatedSelected : updatedSelected[0];
|
|
17711
|
+
setSelected(updatedSelected);
|
|
17712
|
+
setValue?.(name, fieldValue);
|
|
17713
|
+
form.clearErrors(name);
|
|
17714
|
+
if (resetInput) {
|
|
17715
|
+
const rawInputValue = isMultiple ? null : updatedSelected.length ? String(optionsWithKey[value]?.label) : null;
|
|
17716
|
+
setRawInput(rawInputValue);
|
|
17673
17717
|
}
|
|
17674
|
-
|
|
17675
|
-
|
|
17676
|
-
if (!isDisabled) {
|
|
17677
|
-
setIsOpen(open);
|
|
17718
|
+
if (shouldClose) {
|
|
17719
|
+
setIsOpen(false);
|
|
17678
17720
|
}
|
|
17721
|
+
onChange?.(value, !alreadySelected);
|
|
17722
|
+
onEmptyChange?.(updatedSelected.length === 0);
|
|
17679
17723
|
};
|
|
17680
|
-
const
|
|
17681
|
-
if (isDisabled
|
|
17682
|
-
|
|
17683
|
-
|
|
17684
|
-
|
|
17685
|
-
|
|
17686
|
-
if (isMultiple) {
|
|
17687
|
-
setSelected(currentSelected => isChangingItemSelected ? currentSelected.filter(current => current !== changingValue) : [...currentSelected, changingValue]);
|
|
17688
|
-
setInputValue('');
|
|
17689
|
-
} else {
|
|
17690
|
-
if (selected[0] === changingValue) {
|
|
17691
|
-
setSelected([]);
|
|
17692
|
-
setInputValue('');
|
|
17693
|
-
} else {
|
|
17694
|
-
setSelected([changingValue]);
|
|
17695
|
-
}
|
|
17696
|
-
}
|
|
17724
|
+
const handleClearAll = e => {
|
|
17725
|
+
if (isDisabled) return;
|
|
17726
|
+
e.preventDefault();
|
|
17727
|
+
e.stopPropagation();
|
|
17728
|
+
setSelected([]);
|
|
17729
|
+
setRawInput(null);
|
|
17697
17730
|
setIsOpen(false);
|
|
17698
|
-
|
|
17731
|
+
setValue?.(name, undefined);
|
|
17732
|
+
form.trigger(name);
|
|
17699
17733
|
inputRef.current?.focus();
|
|
17700
|
-
|
|
17701
|
-
|
|
17702
|
-
useFormResult.trigger(name);
|
|
17703
|
-
onChange?.(changingValue, isNewSelected);
|
|
17734
|
+
onClearAll?.();
|
|
17735
|
+
onEmptyChange?.(true);
|
|
17704
17736
|
};
|
|
17705
|
-
const
|
|
17706
|
-
|
|
17737
|
+
const handleInputChange = e => {
|
|
17738
|
+
const input = e.target.value;
|
|
17739
|
+
setRawInput(input);
|
|
17740
|
+
if (!autoSelect || !filterOptions) return;
|
|
17741
|
+
const match = findExactMatch(input, optionsWithKey);
|
|
17742
|
+
if (match) {
|
|
17743
|
+
handleChange({
|
|
17744
|
+
value: match.value,
|
|
17745
|
+
shouldClose: false
|
|
17746
|
+
});
|
|
17707
17747
|
return;
|
|
17708
17748
|
}
|
|
17709
|
-
|
|
17710
|
-
|
|
17711
|
-
|
|
17712
|
-
|
|
17713
|
-
|
|
17714
|
-
|
|
17715
|
-
|
|
17716
|
-
|
|
17717
|
-
onClearAll?.();
|
|
17749
|
+
// unset selected value if not fully matched
|
|
17750
|
+
if (!isMultiple && selected.length > 0) {
|
|
17751
|
+
handleChange({
|
|
17752
|
+
value: selected[0],
|
|
17753
|
+
shouldClose: false,
|
|
17754
|
+
resetInput: false
|
|
17755
|
+
});
|
|
17756
|
+
}
|
|
17718
17757
|
};
|
|
17719
|
-
const handleInputClick =
|
|
17758
|
+
const handleInputClick = e => {
|
|
17759
|
+
e.stopPropagation();
|
|
17760
|
+
e.preventDefault();
|
|
17720
17761
|
if (!isDisabled) {
|
|
17721
17762
|
inputRef.current?.focus();
|
|
17722
17763
|
setIsOpen(true);
|
|
17723
17764
|
}
|
|
17724
|
-
event.stopPropagation();
|
|
17725
|
-
event.preventDefault();
|
|
17726
17765
|
};
|
|
17727
|
-
const handleInputKeyDown =
|
|
17728
|
-
|
|
17729
|
-
|
|
17730
|
-
|
|
17731
|
-
|
|
17732
|
-
|
|
17733
|
-
|
|
17734
|
-
|
|
17735
|
-
|
|
17736
|
-
if (foundItem) {
|
|
17737
|
-
setInputValue(`${foundItem?.label}`);
|
|
17766
|
+
const handleInputKeyDown = e => {
|
|
17767
|
+
const isEnterOrTab = ['Enter', 'Tab'].includes(e.code);
|
|
17768
|
+
if (isEnterOrTab && firstSuggestion && firstSuggestion !== inputValue) {
|
|
17769
|
+
const match = findExactMatch(firstSuggestion, optionsWithKey);
|
|
17770
|
+
if (match) {
|
|
17771
|
+
handleChange({
|
|
17772
|
+
value: match.value,
|
|
17773
|
+
shouldClose: false
|
|
17774
|
+
});
|
|
17738
17775
|
}
|
|
17739
|
-
|
|
17740
|
-
return
|
|
17741
|
-
}
|
|
17742
|
-
|
|
17743
|
-
|
|
17744
|
-
|
|
17745
|
-
|
|
17776
|
+
e.preventDefault();
|
|
17777
|
+
return;
|
|
17778
|
+
}
|
|
17779
|
+
if (isMultiple && e.code === 'Backspace' && selected.length && !inputValue) {
|
|
17780
|
+
const lastSelected = selected[selected.length - 1];
|
|
17781
|
+
handleChange({
|
|
17782
|
+
value: lastSelected,
|
|
17783
|
+
shouldClose: false
|
|
17784
|
+
});
|
|
17785
|
+
e.preventDefault();
|
|
17786
|
+
return;
|
|
17787
|
+
}
|
|
17788
|
+
if (!isOpen && firstSuggestion !== inputValue) {
|
|
17746
17789
|
setIsOpen(true);
|
|
17747
17790
|
}
|
|
17748
17791
|
};
|
|
17749
|
-
const
|
|
17750
|
-
|
|
17751
|
-
|
|
17752
|
-
|
|
17753
|
-
|
|
17792
|
+
const handleRemoveSelectedClick = value => e => {
|
|
17793
|
+
e.stopPropagation();
|
|
17794
|
+
handleChange({
|
|
17795
|
+
value
|
|
17796
|
+
});
|
|
17797
|
+
onRemoveSelectedClick?.(value);
|
|
17798
|
+
form.trigger(name);
|
|
17754
17799
|
};
|
|
17755
|
-
const
|
|
17756
|
-
|
|
17757
|
-
|
|
17758
|
-
|
|
17800
|
+
const handleOpenChange = (open, event, reason) => {
|
|
17801
|
+
if (isDisabled || reason === 'reference-press') {
|
|
17802
|
+
return;
|
|
17803
|
+
}
|
|
17804
|
+
setIsOpen(open);
|
|
17805
|
+
if (!isMultiple && selected.length > 0) {
|
|
17806
|
+
const selectedValue = selected[0];
|
|
17807
|
+
const label = optionsWithKey[selectedValue]?.label;
|
|
17808
|
+
setRawInput(label ? String(label) : null);
|
|
17809
|
+
return;
|
|
17810
|
+
}
|
|
17811
|
+
setRawInput(null);
|
|
17759
17812
|
};
|
|
17813
|
+
const status = (() => {
|
|
17814
|
+
if (form.formState.errors[name]) return 'error';
|
|
17815
|
+
if (error) return 'error';
|
|
17816
|
+
if (success) return 'success';
|
|
17817
|
+
return 'basic';
|
|
17818
|
+
})();
|
|
17760
17819
|
return {
|
|
17761
17820
|
isOpen,
|
|
17762
17821
|
isDisabled,
|
|
@@ -17777,18 +17836,18 @@ const useTypeahead = ({
|
|
|
17777
17836
|
inputValue,
|
|
17778
17837
|
validationSchema,
|
|
17779
17838
|
status,
|
|
17839
|
+
error: error ?? form.formState.errors[name],
|
|
17780
17840
|
placeholder,
|
|
17781
17841
|
options: items,
|
|
17782
|
-
useFormResult,
|
|
17842
|
+
useFormResult: form,
|
|
17783
17843
|
register,
|
|
17784
17844
|
setValue,
|
|
17785
|
-
|
|
17845
|
+
onChange,
|
|
17786
17846
|
handleClearAll,
|
|
17787
17847
|
handleOpenChange,
|
|
17788
17848
|
handleInputChange,
|
|
17789
17849
|
handleInputClick,
|
|
17790
17850
|
handleInputKeyDown,
|
|
17791
|
-
handleSelectedClick,
|
|
17792
17851
|
handleRemoveSelectedClick
|
|
17793
17852
|
};
|
|
17794
17853
|
};
|
|
@@ -17902,7 +17961,7 @@ const MultipleTrigger = () => {
|
|
|
17902
17961
|
const theme = (0,react_namespaceObject.useTheme)();
|
|
17903
17962
|
const context = useTypeaheadContext();
|
|
17904
17963
|
const typeaheadInputAdditionalProps = {};
|
|
17905
|
-
if (!context.selectedItems.length && !!context.placeholder) {
|
|
17964
|
+
if (!context.selectedItems.length && !context.inputValue && !!context.placeholder) {
|
|
17906
17965
|
typeaheadInputAdditionalProps.placeholder = context.placeholder;
|
|
17907
17966
|
}
|
|
17908
17967
|
return (0,jsx_runtime_namespaceObject.jsxs)((external_react_default()).Fragment, {
|
|
@@ -17910,7 +17969,7 @@ const MultipleTrigger = () => {
|
|
|
17910
17969
|
const currentOption = context.optionsWithKey[selectedItem];
|
|
17911
17970
|
const optionText = currentOption ? currentOption.children || currentOption.label || currentOption.value : '';
|
|
17912
17971
|
return (0,jsx_runtime_namespaceObject.jsxs)(TypeaheadItem, {
|
|
17913
|
-
onClick:
|
|
17972
|
+
onClick: e => e.stopPropagation(),
|
|
17914
17973
|
isDisabled: context.isDisabled,
|
|
17915
17974
|
children: [(0,jsx_runtime_namespaceObject.jsx)(TypeaheadItemLabel, {
|
|
17916
17975
|
isDisabled: context.isDisabled,
|
|
@@ -17985,7 +18044,7 @@ const SingleTrigger = () => {
|
|
|
17985
18044
|
const context = useTypeaheadContext();
|
|
17986
18045
|
const theme = (0,react_namespaceObject.useTheme)();
|
|
17987
18046
|
const typeaheadInputAdditionalProps = {};
|
|
17988
|
-
if (!context.selectedItems.length && !!context.placeholder) {
|
|
18047
|
+
if (!context.selectedItems.length && !context.inputValue && !!context.placeholder) {
|
|
17989
18048
|
typeaheadInputAdditionalProps.placeholder = context.placeholder;
|
|
17990
18049
|
}
|
|
17991
18050
|
return (0,jsx_runtime_namespaceObject.jsxs)(TypeaheadInputsGroupWrapper, {
|
|
@@ -18125,6 +18184,7 @@ const Typeahead = ({
|
|
|
18125
18184
|
name = 'typeahead-search',
|
|
18126
18185
|
label,
|
|
18127
18186
|
selectedItems,
|
|
18187
|
+
defaultSelectedItems,
|
|
18128
18188
|
isOpen,
|
|
18129
18189
|
isDisabled,
|
|
18130
18190
|
isMultiple,
|
|
@@ -18142,8 +18202,6 @@ const Typeahead = ({
|
|
|
18142
18202
|
optionsClassName,
|
|
18143
18203
|
wrapperClassName,
|
|
18144
18204
|
width = 300,
|
|
18145
|
-
setValue,
|
|
18146
|
-
register,
|
|
18147
18205
|
onChange,
|
|
18148
18206
|
onEmptyChange,
|
|
18149
18207
|
onClearAll,
|
|
@@ -18154,6 +18212,7 @@ const Typeahead = ({
|
|
|
18154
18212
|
const hookResult = useTypeahead({
|
|
18155
18213
|
name,
|
|
18156
18214
|
selectedItems,
|
|
18215
|
+
defaultSelectedItems,
|
|
18157
18216
|
isOpen,
|
|
18158
18217
|
isDisabled,
|
|
18159
18218
|
isMultiple,
|
|
@@ -18167,8 +18226,6 @@ const Typeahead = ({
|
|
|
18167
18226
|
success,
|
|
18168
18227
|
validationSchema,
|
|
18169
18228
|
placeholder,
|
|
18170
|
-
setValue,
|
|
18171
|
-
register,
|
|
18172
18229
|
onChange,
|
|
18173
18230
|
onEmptyChange,
|
|
18174
18231
|
renderOption,
|
|
@@ -18216,7 +18273,7 @@ const Typeahead = ({
|
|
|
18216
18273
|
status: hookResult.status,
|
|
18217
18274
|
disabled: isDisabled,
|
|
18218
18275
|
"data-testid": "helper-text",
|
|
18219
|
-
children: error ? error?.message : helperText
|
|
18276
|
+
children: hookResult.error ? hookResult.error?.message?.toString() : helperText
|
|
18220
18277
|
})]
|
|
18221
18278
|
})
|
|
18222
18279
|
});
|
|
@@ -19094,6 +19151,7 @@ const SelectWidget = props => {
|
|
|
19094
19151
|
placeholder,
|
|
19095
19152
|
onChange,
|
|
19096
19153
|
onBlur,
|
|
19154
|
+
onFocus,
|
|
19097
19155
|
onChangeOverride,
|
|
19098
19156
|
value
|
|
19099
19157
|
} = props;
|
|
@@ -19108,43 +19166,44 @@ const SelectWidget = props => {
|
|
|
19108
19166
|
const handleBlur = ({
|
|
19109
19167
|
target
|
|
19110
19168
|
}) => onBlur(id, target && target.value);
|
|
19169
|
+
const handleFocus = ({
|
|
19170
|
+
target
|
|
19171
|
+
}) => onFocus(id, target && target.value);
|
|
19111
19172
|
const onEmptyChange = isEmpty => {
|
|
19112
19173
|
if (isEmpty) {
|
|
19113
19174
|
handleChange();
|
|
19114
19175
|
}
|
|
19115
19176
|
};
|
|
19116
|
-
const register = fieldName => ({
|
|
19117
|
-
onBlur: handleBlur,
|
|
19118
|
-
onChange: handleChange,
|
|
19119
|
-
name: fieldName,
|
|
19120
|
-
ref: () => {}
|
|
19121
|
-
});
|
|
19122
19177
|
const items = Array.isArray(enumOptions) ? enumOptions : [];
|
|
19123
19178
|
const selectedItems = selectedIndex ? [items[Number(selectedIndex)].value] : [];
|
|
19124
|
-
return (0,jsx_runtime_namespaceObject.jsx)(
|
|
19125
|
-
|
|
19126
|
-
|
|
19127
|
-
|
|
19128
|
-
|
|
19129
|
-
|
|
19130
|
-
|
|
19131
|
-
|
|
19132
|
-
|
|
19133
|
-
|
|
19134
|
-
|
|
19135
|
-
|
|
19136
|
-
|
|
19137
|
-
|
|
19138
|
-
|
|
19139
|
-
|
|
19140
|
-
|
|
19141
|
-
|
|
19142
|
-
|
|
19143
|
-
|
|
19144
|
-
|
|
19145
|
-
|
|
19146
|
-
|
|
19147
|
-
|
|
19179
|
+
return (0,jsx_runtime_namespaceObject.jsx)("div", {
|
|
19180
|
+
id: id,
|
|
19181
|
+
onBlur: handleBlur,
|
|
19182
|
+
onFocus: handleFocus,
|
|
19183
|
+
children: (0,jsx_runtime_namespaceObject.jsx)(Typeahead, {
|
|
19184
|
+
width: "100%",
|
|
19185
|
+
selectedItems: selectedItems,
|
|
19186
|
+
isDisabled: disabled,
|
|
19187
|
+
name: name
|
|
19188
|
+
// RJSF provides placeholder as empty string
|
|
19189
|
+
,
|
|
19190
|
+
placeholder: placeholder || undefined,
|
|
19191
|
+
onChange: handleChange,
|
|
19192
|
+
onEmptyChange: onEmptyChange,
|
|
19193
|
+
renderOption: ({
|
|
19194
|
+
label,
|
|
19195
|
+
input
|
|
19196
|
+
}) => highlightInputMatch(label, input),
|
|
19197
|
+
children: items.map(({
|
|
19198
|
+
label,
|
|
19199
|
+
value
|
|
19200
|
+
}) => (0,jsx_runtime_namespaceObject.jsx)(TypeaheadOption_TypeaheadOption, {
|
|
19201
|
+
value: value,
|
|
19202
|
+
label: label || value,
|
|
19203
|
+
isDisabled: disabled || Array.isArray(enumDisabled) && enumDisabled.includes(value),
|
|
19204
|
+
children: label || value
|
|
19205
|
+
}, value))
|
|
19206
|
+
})
|
|
19148
19207
|
});
|
|
19149
19208
|
};
|
|
19150
19209
|
;// ./src/components/JsonSchemaForm/widgets/PasswordWidget.tsx
|