@expcat/tigercat-react 1.3.3 → 1.4.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.
- package/dist/{chunk-3SV6J7I5.mjs → chunk-2L7QEOFD.mjs} +34 -25
- package/dist/{chunk-FNJDBFKM.mjs → chunk-2LYV6NBJ.mjs} +6 -1
- package/dist/{chunk-EEWHWEYO.js → chunk-2RBHQBSG.js} +2 -2
- package/dist/{chunk-Y5RQN5BO.mjs → chunk-376X7SDZ.mjs} +2 -2
- package/dist/{chunk-UXUYCWQC.js → chunk-3EDASNTG.js} +5 -5
- package/dist/{chunk-NPTXXUXF.mjs → chunk-3RBRWBUG.mjs} +9 -7
- package/dist/{chunk-PUZDW7NR.js → chunk-4AMSYFYC.js} +134 -20
- package/dist/{chunk-IG75YSX3.mjs → chunk-4MONGWU5.mjs} +4 -6
- package/dist/{chunk-3CJFNG54.mjs → chunk-56CTXEJS.mjs} +1 -1
- package/dist/{chunk-TMON4MPO.js → chunk-5ALMTE35.js} +9 -7
- package/dist/{chunk-MSHCPJIJ.mjs → chunk-6BOSSZM3.mjs} +8 -9
- package/dist/{chunk-SIY6FDKJ.js → chunk-7CHTTM6D.js} +339 -314
- package/dist/{chunk-RF2BA2N6.js → chunk-7PXALKLM.js} +4 -4
- package/dist/{chunk-DLKUDB2R.js → chunk-AF2AEZKM.js} +15 -3
- package/dist/{chunk-FB34UWF7.mjs → chunk-AVLIUHOS.mjs} +101 -40
- package/dist/{chunk-TSJYAEFZ.js → chunk-B63GEB2Y.js} +358 -305
- package/dist/{chunk-CFPKK5WW.js → chunk-BA6TJQZL.js} +12 -12
- package/dist/{chunk-LMTUM3J3.js → chunk-BEM7XG2L.js} +2 -4
- package/dist/{chunk-MB6U72CI.js → chunk-BEZO5IE4.js} +2 -2
- package/dist/{chunk-5OHVTGHS.mjs → chunk-BN4ZKCAI.mjs} +368 -315
- package/dist/{chunk-UHFHOTNI.js → chunk-BRA3PO53.js} +6 -7
- package/dist/{chunk-M7HBWFQO.js → chunk-BROIZ266.js} +11 -1
- package/dist/{chunk-SDZOVRVR.mjs → chunk-CAQPYJFA.mjs} +350 -325
- package/dist/{chunk-BFAZZUD6.js → chunk-CC5GFX6F.js} +5 -22
- package/dist/{chunk-LQT6ZGME.mjs → chunk-CME2IFUT.mjs} +15 -3
- package/dist/{chunk-KQ5I7PRM.js → chunk-CNNEUJR2.js} +28 -14
- package/dist/{chunk-EF5ZTNHX.js → chunk-D5MQBUP2.js} +16 -4
- package/dist/{chunk-RQXY2MGX.mjs → chunk-D7UR526A.mjs} +231 -184
- package/dist/{chunk-CBYJXDW4.js → chunk-DBMC6FPU.js} +16 -4
- package/dist/{chunk-WQ4FOHOU.mjs → chunk-DEIVWO2D.mjs} +3 -5
- package/dist/{chunk-7QZ4XT2P.mjs → chunk-DVEK5SO6.mjs} +3 -8
- package/dist/{chunk-TC6JLEGZ.js → chunk-EJKOUI26.js} +24 -7
- package/dist/{chunk-4GITZKAH.mjs → chunk-EPJ6W4VI.mjs} +14 -2
- package/dist/{chunk-KYP7U6FK.js → chunk-FZHBVHQ6.js} +34 -25
- package/dist/{chunk-WVVXZKNI.js → chunk-GDPU5MYA.js} +3 -8
- package/dist/{chunk-2GQCFTD7.mjs → chunk-H4MPPCTB.mjs} +23 -4
- package/dist/{chunk-YOAYDEWW.mjs → chunk-HHMYERHY.mjs} +3 -20
- package/dist/{chunk-LRPPXU74.mjs → chunk-I7FEGKX2.mjs} +19 -5
- package/dist/{chunk-F6IXIH6B.mjs → chunk-IZGXDHPB.mjs} +24 -5
- package/dist/{chunk-GQFVVAEF.js → chunk-J6OZWT3P.js} +5 -5
- package/dist/{chunk-IGAMV6ML.mjs → chunk-KDXKF6B2.mjs} +1 -1
- package/dist/{chunk-A42OLED6.mjs → chunk-KED5S2WG.mjs} +13 -2
- package/dist/{chunk-BJQIYELW.mjs → chunk-KGMVRIYC.mjs} +5 -5
- package/dist/{chunk-6GYT3EZD.mjs → chunk-KXT2TP6A.mjs} +3 -4
- package/dist/{chunk-BBLVRLXT.js → chunk-KYNWNTGO.js} +230 -146
- package/dist/{chunk-M73NMNZX.js → chunk-L24PPXLV.js} +17 -5
- package/dist/chunk-L3WPA2RP.js +25 -0
- package/dist/{chunk-V4JIZN3E.mjs → chunk-L6KSO66F.mjs} +4 -12
- package/dist/{chunk-4LX5UGPQ.js → chunk-LJRCEB7F.js} +168 -121
- package/dist/{chunk-F7H4ALKN.js → chunk-LZG24TDB.js} +8 -9
- package/dist/{chunk-ZYJTHGQW.js → chunk-M3FVPPMM.js} +9 -13
- package/dist/{chunk-GN3TSQWW.mjs → chunk-M6YXUNOU.mjs} +2 -2
- package/dist/{chunk-I373B74W.js → chunk-MC26ORSN.js} +102 -41
- package/dist/{chunk-5HFHHFQS.mjs → chunk-MTIGGMHG.mjs} +17 -5
- package/dist/{chunk-DKT2EYVM.mjs → chunk-MV2JQ6XQ.mjs} +3 -6
- package/dist/{chunk-HR5GBE3P.js → chunk-NDGA3N6H.js} +19 -7
- package/dist/{chunk-BO6QGXMN.mjs → chunk-NEZ445D4.mjs} +9 -9
- package/dist/{chunk-4U5HSR2H.js → chunk-NVI2P7VH.js} +3 -4
- package/dist/{chunk-NVEIVIAW.mjs → chunk-OFRKYQOZ.mjs} +133 -19
- package/dist/{chunk-AW5M3EL4.js → chunk-OS6M3IZF.js} +62 -12
- package/dist/{chunk-3ZNZLGQO.mjs → chunk-OXQOKKTP.mjs} +6 -7
- package/dist/{chunk-NMEVQPOD.js → chunk-PHAJXRGE.js} +2 -4
- package/dist/{chunk-WG3YS2QV.js → chunk-PT5T5F4H.js} +13 -2
- package/dist/{chunk-WNLUUD5N.mjs → chunk-QIL24WZD.mjs} +8 -12
- package/dist/{chunk-ZFMMAYSX.js → chunk-QLATA4UB.js} +4 -6
- package/dist/{chunk-KIYNHQGW.mjs → chunk-RVLV63SI.mjs} +41 -20
- package/dist/{chunk-3QPCQH62.mjs → chunk-RYNLPRUM.mjs} +1 -1
- package/dist/{chunk-6GIJ7NFV.mjs → chunk-SDZKL3IB.mjs} +3 -5
- package/dist/{chunk-G5USITWF.js → chunk-SH4BZYXO.js} +27 -8
- package/dist/{chunk-L5AMVEQL.mjs → chunk-SLEXEH7R.mjs} +60 -10
- package/dist/{chunk-JLRRXRZO.js → chunk-SQONS5PH.js} +4 -7
- package/dist/chunk-SQTOVSDU.mjs +692 -0
- package/dist/{chunk-3ZQMHXRY.js → chunk-TEYL5X56.js} +39 -18
- package/dist/{chunk-KGSDDVRC.mjs → chunk-TNTOSFGN.mjs} +4 -4
- package/dist/{chunk-CY5GRTAX.js → chunk-UAM3RQY4.js} +24 -5
- package/dist/{chunk-XRNKHQTL.js → chunk-UEAXYZSE.js} +3 -2
- package/dist/{chunk-7ISEWLA3.js → chunk-UKQMF3JV.js} +21 -6
- package/dist/{chunk-ITVLIR7T.mjs → chunk-ULWT6W6M.mjs} +13 -20
- package/dist/{chunk-M5GSLKUX.mjs → chunk-VAIWWELW.mjs} +15 -3
- package/dist/{chunk-4SO4LANY.js → chunk-VC26SAXB.js} +340 -274
- package/dist/{chunk-SKMZTW3K.js → chunk-WCTNQYXO.js} +16 -23
- package/dist/{chunk-KXNWY2Q7.mjs → chunk-WFWEMXO7.mjs} +241 -157
- package/dist/chunk-WHYHLUXG.mjs +25 -0
- package/dist/{chunk-ONTRGV5T.js → chunk-WZUADPYB.js} +6 -14
- package/dist/{chunk-N4PP3ENO.js → chunk-XTQUPDRI.js} +2 -2
- package/dist/{chunk-XATXFVKR.mjs → chunk-Y7K27DVV.mjs} +4 -3
- package/dist/{chunk-WI4N5DD3.mjs → chunk-YH57D4AV.mjs} +16 -4
- package/dist/{chunk-3MRP3XYI.js → chunk-YRVAF2ID.js} +7 -2
- package/dist/{chunk-5XE5VBDS.mjs → chunk-YSGM22AH.mjs} +11 -1
- package/dist/{chunk-6TR7JB6C.js → chunk-ZDNQGS4O.js} +4 -4
- package/dist/{chunk-CHBUNQIJ.mjs → chunk-ZQSMJS2Q.mjs} +23 -6
- package/dist/{chunk-QQFLRNI3.mjs → chunk-ZRZB3C5J.mjs} +18 -3
- package/dist/components/ActivityFeed.js +4 -3
- package/dist/components/ActivityFeed.mjs +3 -2
- package/dist/components/Cascader.d.mts +3 -1
- package/dist/components/Cascader.d.ts +3 -1
- package/dist/components/Cascader.js +3 -2
- package/dist/components/Cascader.mjs +2 -1
- package/dist/components/ChatWindow.js +5 -5
- package/dist/components/ChatWindow.mjs +4 -4
- package/dist/components/Checkbox.js +4 -4
- package/dist/components/Checkbox.mjs +3 -3
- package/dist/components/CheckboxGroup.js +3 -3
- package/dist/components/CheckboxGroup.mjs +2 -2
- package/dist/components/CommentThread.js +4 -4
- package/dist/components/CommentThread.mjs +3 -3
- package/dist/components/CropUpload.js +4 -4
- package/dist/components/CropUpload.mjs +3 -3
- package/dist/components/DataTableWithToolbar.d.mts +2 -2
- package/dist/components/DataTableWithToolbar.d.ts +2 -2
- package/dist/components/DataTableWithToolbar.js +11 -11
- package/dist/components/DataTableWithToolbar.mjs +10 -10
- package/dist/components/DatePicker.d.mts +1 -0
- package/dist/components/DatePicker.d.ts +1 -0
- package/dist/components/DatePicker.js +3 -2
- package/dist/components/DatePicker.mjs +2 -1
- package/dist/components/Drawer.js +3 -3
- package/dist/components/Drawer.mjs +2 -2
- package/dist/components/FileManager.d.mts +2 -1
- package/dist/components/FileManager.d.ts +2 -1
- package/dist/components/FileManager.js +3 -2
- package/dist/components/FileManager.mjs +2 -1
- package/dist/components/Form.js +3 -2
- package/dist/components/Form.mjs +2 -1
- package/dist/components/FormItem.js +4 -3
- package/dist/components/FormItem.mjs +3 -2
- package/dist/components/FormWizard.js +4 -4
- package/dist/components/FormWizard.mjs +3 -3
- package/dist/components/Image.js +4 -4
- package/dist/components/Image.mjs +3 -3
- package/dist/components/ImageGroup.js +3 -3
- package/dist/components/ImageGroup.mjs +2 -2
- package/dist/components/ImagePreview.js +2 -2
- package/dist/components/ImagePreview.mjs +1 -1
- package/dist/components/ImageViewer.d.mts +1 -1
- package/dist/components/ImageViewer.d.ts +1 -1
- package/dist/components/ImageViewer.js +2 -2
- package/dist/components/ImageViewer.mjs +1 -1
- package/dist/components/InfiniteScroll.d.mts +2 -0
- package/dist/components/InfiniteScroll.d.ts +2 -0
- package/dist/components/InfiniteScroll.js +3 -2
- package/dist/components/InfiniteScroll.mjs +2 -1
- package/dist/components/Input.js +3 -2
- package/dist/components/Input.mjs +2 -1
- package/dist/components/InputNumber.js +3 -2
- package/dist/components/InputNumber.mjs +2 -1
- package/dist/components/List.d.mts +6 -2
- package/dist/components/List.d.ts +6 -2
- package/dist/components/List.js +3 -2
- package/dist/components/List.mjs +2 -1
- package/dist/components/Loading.js +3 -2
- package/dist/components/Loading.mjs +2 -1
- package/dist/components/MarkdownEditor.js +3 -3
- package/dist/components/MarkdownEditor.mjs +2 -2
- package/dist/components/Mentions.js +2 -2
- package/dist/components/Mentions.mjs +1 -1
- package/dist/components/Menu.d.mts +8 -80
- package/dist/components/Menu.d.ts +8 -80
- package/dist/components/Menu.js +2 -2
- package/dist/components/Menu.mjs +1 -1
- package/dist/components/MenuItem.d.mts +6 -2
- package/dist/components/MenuItem.d.ts +6 -2
- package/dist/components/MenuItem.js +2 -2
- package/dist/components/MenuItem.mjs +1 -1
- package/dist/components/MenuItemGroup.d.mts +6 -2
- package/dist/components/MenuItemGroup.d.ts +6 -2
- package/dist/components/MenuItemGroup.js +2 -2
- package/dist/components/MenuItemGroup.mjs +1 -1
- package/dist/components/Message.js +2 -2
- package/dist/components/Message.mjs +1 -1
- package/dist/components/Modal.js +3 -3
- package/dist/components/Modal.mjs +2 -2
- package/dist/components/Notification.js +2 -2
- package/dist/components/Notification.mjs +1 -1
- package/dist/components/NotificationCenter.js +5 -4
- package/dist/components/NotificationCenter.mjs +4 -3
- package/dist/components/NumberKeyboard.js +3 -2
- package/dist/components/NumberKeyboard.mjs +2 -1
- package/dist/components/Radio.js +4 -4
- package/dist/components/Radio.mjs +3 -3
- package/dist/components/RadioGroup.js +3 -3
- package/dist/components/RadioGroup.mjs +2 -2
- package/dist/components/RichTextEditor.js +3 -3
- package/dist/components/RichTextEditor.mjs +2 -2
- package/dist/components/Select.d.mts +3 -1
- package/dist/components/Select.d.ts +3 -1
- package/dist/components/Select.js +3 -2
- package/dist/components/Select.mjs +2 -1
- package/dist/components/Signature.d.mts +1 -0
- package/dist/components/Signature.d.ts +1 -0
- package/dist/components/Signature.js +3 -2
- package/dist/components/Signature.mjs +2 -1
- package/dist/components/Spotlight.js +4 -2
- package/dist/components/Spotlight.mjs +3 -1
- package/dist/components/Steps.js +2 -2
- package/dist/components/Steps.mjs +1 -1
- package/dist/components/StepsItem.js +2 -2
- package/dist/components/StepsItem.mjs +1 -1
- package/dist/components/SubMenu.d.mts +6 -2
- package/dist/components/SubMenu.d.ts +6 -2
- package/dist/components/SubMenu.js +2 -2
- package/dist/components/SubMenu.mjs +1 -1
- package/dist/components/Table.d.mts +2 -2
- package/dist/components/Table.d.ts +2 -2
- package/dist/components/Table.js +9 -9
- package/dist/components/Table.mjs +8 -8
- package/dist/components/Textarea.js +3 -3
- package/dist/components/Textarea.mjs +2 -2
- package/dist/components/TimePicker.d.mts +1 -0
- package/dist/components/TimePicker.d.ts +1 -0
- package/dist/components/TimePicker.js +4 -2
- package/dist/components/TimePicker.mjs +3 -1
- package/dist/components/Tour.js +3 -2
- package/dist/components/Tour.mjs +2 -1
- package/dist/components/Transfer.d.mts +3 -1
- package/dist/components/Transfer.d.ts +3 -1
- package/dist/components/Transfer.js +3 -2
- package/dist/components/Transfer.mjs +2 -1
- package/dist/components/Tree.d.mts +3 -1
- package/dist/components/Tree.d.ts +3 -1
- package/dist/components/Tree.js +3 -2
- package/dist/components/Tree.mjs +2 -1
- package/dist/components/TreeSelect.d.mts +3 -1
- package/dist/components/TreeSelect.d.ts +3 -1
- package/dist/components/TreeSelect.js +3 -2
- package/dist/components/TreeSelect.mjs +2 -1
- package/dist/components/Upload.js +3 -2
- package/dist/components/Upload.mjs +2 -1
- package/dist/components/VirtualTable.d.mts +3 -2
- package/dist/components/VirtualTable.d.ts +3 -2
- package/dist/components/VirtualTable.js +3 -2
- package/dist/components/VirtualTable.mjs +2 -1
- package/dist/index.d.mts +33 -7
- package/dist/index.d.ts +33 -7
- package/dist/index.js +54 -54
- package/dist/index.mjs +53 -53
- package/dist/{types-CHmCMNEM.d.ts → types-0oVwMXtR.d.mts} +1 -1
- package/dist/{types-CHmCMNEM.d.mts → types-0oVwMXtR.d.ts} +1 -1
- package/dist/types-DaC4a0Ny.d.mts +80 -0
- package/dist/types-DaC4a0Ny.d.ts +80 -0
- package/package.json +2 -2
- package/dist/chunk-UKGQ7256.js +0 -12
- package/dist/chunk-UQMPEMY7.mjs +0 -12
- package/dist/chunk-VNVGSPBI.mjs +0 -626
- package/dist/{chunk-OZD75CLT.js → chunk-ANBNSUSR.js} +3 -3
- package/dist/{chunk-I2AUOICV.mjs → chunk-M3MOSUZO.mjs} +3 -3
- package/dist/{chunk-UMZ3PMUJ.js → chunk-SXHCMZ6U.js} +2 -2
- package/dist/{chunk-BWDQZSAB.mjs → chunk-WTSG7QXK.mjs} +3 -3
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkL3WPA2RPjs = require('./chunk-L3WPA2RP.js');
|
|
4
|
+
|
|
5
|
+
// src/components/InputNumber.tsx
|
|
2
6
|
var _react = require('react');
|
|
3
7
|
|
|
4
8
|
|
|
@@ -18,6 +22,8 @@ var _react = require('react');
|
|
|
18
22
|
|
|
19
23
|
|
|
20
24
|
|
|
25
|
+
|
|
26
|
+
|
|
21
27
|
|
|
22
28
|
|
|
23
29
|
var _tigercatcore = require('@expcat/tigercat-core');
|
|
@@ -47,32 +53,22 @@ var InputNumber = ({
|
|
|
47
53
|
onBlur,
|
|
48
54
|
className
|
|
49
55
|
}) => {
|
|
50
|
-
const isControlled = controlledValue !== void 0;
|
|
51
56
|
const inputRef = _react.useRef.call(void 0, null);
|
|
52
57
|
const repeatControllerRef = _react.useRef.call(void 0, _tigercatcore.createRafRepeatActionController.call(void 0, ));
|
|
53
58
|
const repeatValueRef = _react.useRef.call(void 0, null);
|
|
54
59
|
const suppressNextClickRef = _react.useRef.call(void 0, false);
|
|
55
60
|
const [focused, setFocused] = _react.useState.call(void 0, false);
|
|
56
|
-
const [
|
|
57
|
-
|
|
61
|
+
const [currentValue, setValue] = _chunkL3WPA2RPjs.useControlledState.call(void 0,
|
|
62
|
+
controlledValue,
|
|
63
|
+
_nullishCoalesce(_nullishCoalesce(defaultValue, () => ( controlledValue)), () => ( null)),
|
|
64
|
+
onChange
|
|
58
65
|
);
|
|
59
66
|
const [displayValue, setDisplayValue] = _react.useState.call(void 0, "");
|
|
60
|
-
const currentValue = isControlled ? _nullishCoalesce(controlledValue, () => ( null)) : internalValue;
|
|
61
67
|
const toDisplayValue = _react.useCallback.call(void 0,
|
|
62
|
-
(val) => {
|
|
63
|
-
if (val === null || val === void 0) return "";
|
|
64
|
-
if (formatter) return formatter(val);
|
|
65
|
-
if (precision !== void 0) return val.toFixed(precision);
|
|
66
|
-
return String(val);
|
|
67
|
-
},
|
|
68
|
+
(val) => _tigercatcore.formatInputNumberDisplay.call(void 0, val, { formatter, precision }),
|
|
68
69
|
[formatter, precision]
|
|
69
70
|
);
|
|
70
|
-
const parseValue = (str) => {
|
|
71
|
-
if (str === "" || str === "-") return null;
|
|
72
|
-
if (parser) return parser(str);
|
|
73
|
-
const num = Number(str);
|
|
74
|
-
return Number.isNaN(num) ? null : num;
|
|
75
|
-
};
|
|
71
|
+
const parseValue = (str) => _tigercatcore.parseInputNumberValue.call(void 0, str, { parser });
|
|
76
72
|
_react.useEffect.call(void 0, () => {
|
|
77
73
|
if (!focused) {
|
|
78
74
|
setDisplayValue(toDisplayValue(currentValue));
|
|
@@ -92,10 +88,7 @@ var InputNumber = ({
|
|
|
92
88
|
finalVal = _tigercatcore.formatPrecision.call(void 0, finalVal, precision);
|
|
93
89
|
}
|
|
94
90
|
}
|
|
95
|
-
|
|
96
|
-
setInternalValue(finalVal);
|
|
97
|
-
}
|
|
98
|
-
_optionalChain([onChange, 'optionalCall', _ => _(finalVal)]);
|
|
91
|
+
setValue(finalVal);
|
|
99
92
|
setDisplayValue(toDisplayValue(finalVal));
|
|
100
93
|
};
|
|
101
94
|
const handleStep = (direction, baseValue = currentValue) => {
|
|
@@ -139,14 +132,14 @@ var InputNumber = ({
|
|
|
139
132
|
setFocused(false);
|
|
140
133
|
const parsed = parseValue(displayValue);
|
|
141
134
|
commitValue(parsed);
|
|
142
|
-
_optionalChain([onBlur, 'optionalCall',
|
|
135
|
+
_optionalChain([onBlur, 'optionalCall', _ => _(e)]);
|
|
143
136
|
};
|
|
144
137
|
const handleFocus = (e) => {
|
|
145
138
|
setFocused(true);
|
|
146
139
|
if (formatter && currentValue !== null) {
|
|
147
140
|
setDisplayValue(String(currentValue));
|
|
148
141
|
}
|
|
149
|
-
_optionalChain([onFocus, 'optionalCall',
|
|
142
|
+
_optionalChain([onFocus, 'optionalCall', _2 => _2(e)]);
|
|
150
143
|
};
|
|
151
144
|
const handleKeyDown = (e) => {
|
|
152
145
|
if (!keyboard || disabled || readonly) return;
|
|
@@ -1,31 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useTigerConfig
|
|
3
|
+
} from "./chunk-QAIBQHIO.mjs";
|
|
4
|
+
|
|
1
5
|
// src/components/Select.tsx
|
|
6
|
+
import {
|
|
7
|
+
classNames as classNames2,
|
|
8
|
+
selectDropdownBaseClasses,
|
|
9
|
+
selectSearchInputClasses
|
|
10
|
+
} from "@expcat/tigercat-core";
|
|
11
|
+
|
|
12
|
+
// src/components/Select/state.ts
|
|
2
13
|
import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
3
14
|
import {
|
|
4
15
|
classNames,
|
|
5
16
|
getSelectTriggerClasses,
|
|
6
|
-
getSelectOptionClasses,
|
|
7
17
|
selectBaseClasses,
|
|
8
|
-
selectDropdownBaseClasses,
|
|
9
|
-
selectGroupLabelClasses,
|
|
10
|
-
selectSearchInputClasses,
|
|
11
|
-
selectEmptyStateClasses,
|
|
12
|
-
isOptionGroup,
|
|
13
18
|
createSelectSearchDebouncer,
|
|
14
|
-
getCreateSelectOptionLabel,
|
|
15
19
|
flattenSelectOptions,
|
|
16
20
|
resolveCreatableSelectOption,
|
|
17
21
|
resolveSelectFilteredOptions,
|
|
18
22
|
findFirstEnabledIndex as pickerFindFirstEnabledIndex,
|
|
19
23
|
findLastEnabledIndex as pickerFindLastEnabledIndex,
|
|
20
24
|
findNextEnabledIndex as pickerFindNextEnabledIndex,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
closeSolidIcon20PathD,
|
|
24
|
-
checkSolidIcon20PathD
|
|
25
|
+
resolveLocaleText,
|
|
26
|
+
mergeTigerLocale
|
|
25
27
|
} from "@expcat/tigercat-core";
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
var SELECT_KEYS = /* @__PURE__ */ new Set([
|
|
29
|
+
"options",
|
|
30
|
+
"size",
|
|
31
|
+
"disabled",
|
|
32
|
+
"placeholder",
|
|
33
|
+
"searchable",
|
|
34
|
+
"clearable",
|
|
35
|
+
"noOptionsText",
|
|
36
|
+
"noDataText",
|
|
37
|
+
"maxTagCount",
|
|
38
|
+
"virtual",
|
|
39
|
+
"remote",
|
|
40
|
+
"searchDebounce",
|
|
41
|
+
"creatable",
|
|
42
|
+
"createOptionText",
|
|
43
|
+
"listHeight",
|
|
44
|
+
"onSearch",
|
|
45
|
+
"onCreate",
|
|
46
|
+
"className",
|
|
47
|
+
"value",
|
|
48
|
+
"onChange",
|
|
49
|
+
"multiple",
|
|
50
|
+
"locale"
|
|
51
|
+
]);
|
|
52
|
+
function useSelectState(props) {
|
|
29
53
|
const {
|
|
30
54
|
options = [],
|
|
31
55
|
size = "md",
|
|
@@ -33,8 +57,8 @@ var Select = (props) => {
|
|
|
33
57
|
placeholder = "Select an option",
|
|
34
58
|
searchable = false,
|
|
35
59
|
clearable = true,
|
|
36
|
-
noOptionsText
|
|
37
|
-
noDataText
|
|
60
|
+
noOptionsText,
|
|
61
|
+
noDataText,
|
|
38
62
|
maxTagCount,
|
|
39
63
|
remote = false,
|
|
40
64
|
searchDebounce = 0,
|
|
@@ -45,32 +69,15 @@ var Select = (props) => {
|
|
|
45
69
|
className,
|
|
46
70
|
value,
|
|
47
71
|
onChange,
|
|
48
|
-
multiple
|
|
72
|
+
multiple,
|
|
73
|
+
locale
|
|
49
74
|
} = props;
|
|
50
75
|
const isMultiple = multiple === true;
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"searchable",
|
|
57
|
-
"clearable",
|
|
58
|
-
"noOptionsText",
|
|
59
|
-
"noDataText",
|
|
60
|
-
"maxTagCount",
|
|
61
|
-
"virtual",
|
|
62
|
-
"remote",
|
|
63
|
-
"searchDebounce",
|
|
64
|
-
"creatable",
|
|
65
|
-
"createOptionText",
|
|
66
|
-
"listHeight",
|
|
67
|
-
"onSearch",
|
|
68
|
-
"onCreate",
|
|
69
|
-
"className",
|
|
70
|
-
"value",
|
|
71
|
-
"onChange",
|
|
72
|
-
"multiple"
|
|
73
|
-
]);
|
|
76
|
+
const config = useTigerConfig();
|
|
77
|
+
const mergedLocale = useMemo(
|
|
78
|
+
() => mergeTigerLocale(config.locale, locale),
|
|
79
|
+
[config.locale, locale]
|
|
80
|
+
);
|
|
74
81
|
const divProps = {};
|
|
75
82
|
for (const [k, v] of Object.entries(props)) {
|
|
76
83
|
if (!SELECT_KEYS.has(k)) divProps[k] = v;
|
|
@@ -402,158 +409,235 @@ var Select = (props) => {
|
|
|
402
409
|
document.removeEventListener("click", handleClickOutside);
|
|
403
410
|
};
|
|
404
411
|
}, [isOpen]);
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
412
|
+
return {
|
|
413
|
+
listboxId,
|
|
414
|
+
getOptionId,
|
|
415
|
+
isOpen,
|
|
416
|
+
searchQuery,
|
|
417
|
+
activeIndex,
|
|
418
|
+
setActiveIndex,
|
|
419
|
+
dropdownRef,
|
|
420
|
+
triggerRef,
|
|
421
|
+
searchInputRef,
|
|
422
|
+
isMultiple,
|
|
423
|
+
size,
|
|
424
|
+
disabled,
|
|
425
|
+
placeholder,
|
|
426
|
+
searchable,
|
|
427
|
+
clearable,
|
|
428
|
+
noDataText: resolveLocaleText(
|
|
429
|
+
"No options available",
|
|
430
|
+
noDataText,
|
|
431
|
+
mergedLocale?.common?.emptyText
|
|
432
|
+
),
|
|
433
|
+
noOptionsText: resolveLocaleText(
|
|
434
|
+
"No options found",
|
|
435
|
+
noOptionsText,
|
|
436
|
+
mergedLocale?.common?.emptyText
|
|
437
|
+
),
|
|
438
|
+
createOptionText,
|
|
439
|
+
className,
|
|
440
|
+
divProps,
|
|
441
|
+
searchPlaceholder: resolveLocaleText("Search...", mergedLocale?.common?.searchPlaceholder),
|
|
442
|
+
filteredOptions,
|
|
443
|
+
flatSelectableOptions,
|
|
444
|
+
creatableOption,
|
|
445
|
+
hasOptions: filteredOptions.length > 0,
|
|
446
|
+
optionsLength: options.length,
|
|
447
|
+
displayText,
|
|
448
|
+
showClearButton,
|
|
449
|
+
containerClasses: classNames(selectBaseClasses, className),
|
|
450
|
+
triggerClasses: getSelectTriggerClasses(size, disabled, isOpen),
|
|
451
|
+
isSelected,
|
|
452
|
+
selectOption,
|
|
453
|
+
clearSelection,
|
|
454
|
+
toggleDropdown,
|
|
455
|
+
handleSearchInput,
|
|
456
|
+
handleTriggerKeyDown,
|
|
457
|
+
handleDropdownKeyDown,
|
|
458
|
+
handleSearchKeyDown
|
|
441
459
|
};
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// src/components/Select/render-option.tsx
|
|
463
|
+
import {
|
|
464
|
+
getSelectOptionClasses,
|
|
465
|
+
selectGroupLabelClasses,
|
|
466
|
+
selectEmptyStateClasses,
|
|
467
|
+
isOptionGroup,
|
|
468
|
+
getCreateSelectOptionLabel
|
|
469
|
+
} from "@expcat/tigercat-core";
|
|
470
|
+
|
|
471
|
+
// src/components/Select/icons.tsx
|
|
472
|
+
import {
|
|
473
|
+
icon20ViewBox,
|
|
474
|
+
chevronDownSolidIcon20PathD,
|
|
475
|
+
closeSolidIcon20PathD,
|
|
476
|
+
checkSolidIcon20PathD
|
|
477
|
+
} from "@expcat/tigercat-core";
|
|
478
|
+
import { jsx } from "react/jsx-runtime";
|
|
479
|
+
var SelectIcon = ({ path, className }) => /* @__PURE__ */ jsx(
|
|
480
|
+
"svg",
|
|
481
|
+
{
|
|
482
|
+
className,
|
|
483
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
484
|
+
viewBox: icon20ViewBox,
|
|
485
|
+
fill: "currentColor",
|
|
486
|
+
children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", d: path, clipRule: "evenodd" })
|
|
487
|
+
}
|
|
488
|
+
);
|
|
489
|
+
var SelectCheckIcon = () => /* @__PURE__ */ jsx(
|
|
490
|
+
SelectIcon,
|
|
491
|
+
{
|
|
492
|
+
path: checkSolidIcon20PathD,
|
|
493
|
+
className: "w-5 h-5 text-[var(--tiger-select-check-icon,var(--tiger-primary,#2563eb))]"
|
|
494
|
+
}
|
|
495
|
+
);
|
|
496
|
+
var SelectClearIcon = () => /* @__PURE__ */ jsx(
|
|
497
|
+
SelectIcon,
|
|
498
|
+
{
|
|
499
|
+
path: closeSolidIcon20PathD,
|
|
500
|
+
className: "w-4 h-4 text-[var(--tiger-select-icon,var(--tiger-text-muted,#9ca3af))] hover:text-[var(--tiger-select-icon-hover,var(--tiger-text-muted,#6b7280))]"
|
|
501
|
+
}
|
|
502
|
+
);
|
|
503
|
+
var SelectChevronIcon = () => /* @__PURE__ */ jsx(
|
|
504
|
+
SelectIcon,
|
|
505
|
+
{
|
|
506
|
+
path: chevronDownSolidIcon20PathD,
|
|
507
|
+
className: "w-5 h-5 text-[var(--tiger-select-icon,var(--tiger-text-muted,#9ca3af))] transition-transform"
|
|
508
|
+
}
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
// src/components/Select/render-option.tsx
|
|
512
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
513
|
+
function renderOption(ctx, option, index, displayLabel = option.label) {
|
|
514
|
+
const optionSelected = ctx.isSelected(option);
|
|
515
|
+
const optionActive = index === ctx.activeIndex;
|
|
516
|
+
return /* @__PURE__ */ jsx2(
|
|
517
|
+
"div",
|
|
518
|
+
{
|
|
519
|
+
id: ctx.getOptionId(index),
|
|
520
|
+
"data-option-index": index,
|
|
521
|
+
role: "option",
|
|
522
|
+
"aria-selected": optionSelected,
|
|
523
|
+
"aria-disabled": option.disabled ? true : void 0,
|
|
524
|
+
tabIndex: optionActive ? 0 : -1,
|
|
525
|
+
className: getSelectOptionClasses(optionSelected, !!option.disabled, ctx.size),
|
|
526
|
+
onMouseEnter: () => {
|
|
527
|
+
if (!option.disabled) {
|
|
528
|
+
ctx.setActiveIndex(index);
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
onClick: () => ctx.selectOption(option),
|
|
532
|
+
children: /* @__PURE__ */ jsxs("span", { className: "flex items-center justify-between w-full", children: [
|
|
533
|
+
/* @__PURE__ */ jsx2("span", { children: displayLabel }),
|
|
534
|
+
optionSelected && /* @__PURE__ */ jsx2(SelectCheckIcon, {})
|
|
535
|
+
] })
|
|
536
|
+
},
|
|
537
|
+
option.value
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
function renderOptions(ctx) {
|
|
541
|
+
if (!ctx.hasOptions && !ctx.creatableOption) {
|
|
542
|
+
return /* @__PURE__ */ jsx2("div", { className: selectEmptyStateClasses, children: ctx.optionsLength === 0 ? ctx.noDataText : ctx.noOptionsText });
|
|
543
|
+
}
|
|
544
|
+
let optionIndex = -1;
|
|
545
|
+
const optionNodes = ctx.filteredOptions.map((item) => {
|
|
546
|
+
if (isOptionGroup(item)) {
|
|
547
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
548
|
+
/* @__PURE__ */ jsx2("div", { className: selectGroupLabelClasses, children: item.label }),
|
|
549
|
+
item.options.map((option) => {
|
|
550
|
+
optionIndex += 1;
|
|
551
|
+
return renderOption(ctx, option, optionIndex);
|
|
552
|
+
})
|
|
553
|
+
] }, item.label);
|
|
470
554
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
555
|
+
optionIndex += 1;
|
|
556
|
+
return renderOption(ctx, item, optionIndex);
|
|
557
|
+
});
|
|
558
|
+
if (ctx.creatableOption) {
|
|
559
|
+
optionIndex += 1;
|
|
560
|
+
optionNodes.push(
|
|
561
|
+
renderOption(
|
|
562
|
+
ctx,
|
|
563
|
+
ctx.creatableOption,
|
|
564
|
+
optionIndex,
|
|
565
|
+
getCreateSelectOptionLabel(ctx.creatableOption, ctx.createOptionText)
|
|
566
|
+
)
|
|
567
|
+
);
|
|
568
|
+
}
|
|
569
|
+
return optionNodes;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// src/components/Select.tsx
|
|
573
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
574
|
+
var Select = (props) => {
|
|
575
|
+
const ctx = useSelectState(props);
|
|
576
|
+
return /* @__PURE__ */ jsxs2("div", { ...ctx.divProps, className: ctx.containerClasses, children: [
|
|
577
|
+
/* @__PURE__ */ jsxs2(
|
|
476
578
|
"button",
|
|
477
579
|
{
|
|
478
|
-
ref: triggerRef,
|
|
580
|
+
ref: ctx.triggerRef,
|
|
479
581
|
type: "button",
|
|
480
|
-
className: triggerClasses,
|
|
481
|
-
disabled,
|
|
482
|
-
onClick: toggleDropdown,
|
|
483
|
-
onKeyDown: handleTriggerKeyDown,
|
|
582
|
+
className: ctx.triggerClasses,
|
|
583
|
+
disabled: ctx.disabled,
|
|
584
|
+
onClick: ctx.toggleDropdown,
|
|
585
|
+
onKeyDown: ctx.handleTriggerKeyDown,
|
|
484
586
|
"aria-haspopup": "listbox",
|
|
485
|
-
"aria-expanded": isOpen,
|
|
486
|
-
"aria-controls": listboxId,
|
|
487
|
-
"aria-activedescendant": isOpen && activeIndex >= 0 ? getOptionId(activeIndex) : void 0,
|
|
488
|
-
"data-state": isOpen ? "open" : "closed",
|
|
587
|
+
"aria-expanded": ctx.isOpen,
|
|
588
|
+
"aria-controls": ctx.listboxId,
|
|
589
|
+
"aria-activedescendant": ctx.isOpen && ctx.activeIndex >= 0 ? ctx.getOptionId(ctx.activeIndex) : void 0,
|
|
590
|
+
"data-state": ctx.isOpen ? "open" : "closed",
|
|
489
591
|
children: [
|
|
490
|
-
/* @__PURE__ */
|
|
592
|
+
/* @__PURE__ */ jsx3(
|
|
491
593
|
"span",
|
|
492
594
|
{
|
|
493
|
-
className:
|
|
595
|
+
className: classNames2(
|
|
494
596
|
"flex-1 text-left truncate",
|
|
495
|
-
displayText === placeholder && "text-[var(--tiger-select-placeholder,var(--tiger-text-muted,#9ca3af))]"
|
|
597
|
+
ctx.displayText === ctx.placeholder && "text-[var(--tiger-select-placeholder,var(--tiger-text-muted,#9ca3af))]"
|
|
496
598
|
),
|
|
497
|
-
children: displayText
|
|
599
|
+
children: ctx.displayText
|
|
498
600
|
}
|
|
499
601
|
),
|
|
500
|
-
/* @__PURE__ */
|
|
501
|
-
showClearButton && /* @__PURE__ */
|
|
602
|
+
/* @__PURE__ */ jsxs2("span", { className: "flex items-center gap-1", children: [
|
|
603
|
+
ctx.showClearButton && /* @__PURE__ */ jsx3(
|
|
502
604
|
"span",
|
|
503
605
|
{
|
|
504
606
|
className: "inline-flex",
|
|
505
607
|
"data-tiger-select-clear": true,
|
|
506
608
|
"aria-label": "Clear selection",
|
|
507
|
-
onClick: clearSelection,
|
|
508
|
-
children: /* @__PURE__ */
|
|
509
|
-
"svg",
|
|
510
|
-
{
|
|
511
|
-
className: "w-4 h-4 text-[var(--tiger-select-icon,var(--tiger-text-muted,#9ca3af))] hover:text-[var(--tiger-select-icon-hover,var(--tiger-text-muted,#6b7280))]",
|
|
512
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
513
|
-
viewBox: icon20ViewBox,
|
|
514
|
-
fill: "currentColor",
|
|
515
|
-
children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", d: closeSolidIcon20PathD, clipRule: "evenodd" })
|
|
516
|
-
}
|
|
517
|
-
)
|
|
609
|
+
onClick: ctx.clearSelection,
|
|
610
|
+
children: /* @__PURE__ */ jsx3(SelectClearIcon, {})
|
|
518
611
|
}
|
|
519
612
|
),
|
|
520
|
-
/* @__PURE__ */
|
|
521
|
-
"svg",
|
|
522
|
-
{
|
|
523
|
-
className: "w-5 h-5 text-[var(--tiger-select-icon,var(--tiger-text-muted,#9ca3af))] transition-transform",
|
|
524
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
525
|
-
viewBox: icon20ViewBox,
|
|
526
|
-
fill: "currentColor",
|
|
527
|
-
children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", d: chevronDownSolidIcon20PathD, clipRule: "evenodd" })
|
|
528
|
-
}
|
|
529
|
-
) })
|
|
613
|
+
/* @__PURE__ */ jsx3("span", { className: classNames2("inline-flex", ctx.isOpen && "rotate-180"), children: /* @__PURE__ */ jsx3(SelectChevronIcon, {}) })
|
|
530
614
|
] })
|
|
531
615
|
]
|
|
532
616
|
}
|
|
533
617
|
),
|
|
534
|
-
isOpen && /* @__PURE__ */
|
|
618
|
+
ctx.isOpen && /* @__PURE__ */ jsxs2(
|
|
535
619
|
"div",
|
|
536
620
|
{
|
|
537
|
-
ref: dropdownRef,
|
|
621
|
+
ref: ctx.dropdownRef,
|
|
538
622
|
className: selectDropdownBaseClasses,
|
|
539
623
|
role: "listbox",
|
|
540
|
-
id: listboxId,
|
|
541
|
-
"aria-multiselectable":
|
|
542
|
-
onKeyDown: handleDropdownKeyDown,
|
|
624
|
+
id: ctx.listboxId,
|
|
625
|
+
"aria-multiselectable": ctx.isMultiple ? true : void 0,
|
|
626
|
+
onKeyDown: ctx.handleDropdownKeyDown,
|
|
543
627
|
children: [
|
|
544
|
-
searchable && /* @__PURE__ */
|
|
628
|
+
ctx.searchable && /* @__PURE__ */ jsx3(
|
|
545
629
|
"input",
|
|
546
630
|
{
|
|
547
|
-
ref: searchInputRef,
|
|
631
|
+
ref: ctx.searchInputRef,
|
|
548
632
|
type: "text",
|
|
549
633
|
className: selectSearchInputClasses,
|
|
550
|
-
placeholder:
|
|
551
|
-
value: searchQuery,
|
|
552
|
-
onChange: handleSearchInput,
|
|
553
|
-
onKeyDown: handleSearchKeyDown
|
|
634
|
+
placeholder: ctx.searchPlaceholder,
|
|
635
|
+
value: ctx.searchQuery,
|
|
636
|
+
onChange: ctx.handleSearchInput,
|
|
637
|
+
onKeyDown: ctx.handleSearchKeyDown
|
|
554
638
|
}
|
|
555
639
|
),
|
|
556
|
-
renderOptions()
|
|
640
|
+
renderOptions(ctx)
|
|
557
641
|
]
|
|
558
642
|
}
|
|
559
643
|
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/hooks/useControlledState.ts
|
|
2
|
+
import { useCallback, useRef, useState } from "react";
|
|
3
|
+
function useControlledState(controlledValue, defaultValue, onChange) {
|
|
4
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
5
|
+
const isControlled = controlledValue !== void 0;
|
|
6
|
+
const value = isControlled ? controlledValue : internalValue;
|
|
7
|
+
const valueRef = useRef(value);
|
|
8
|
+
valueRef.current = value;
|
|
9
|
+
const isControlledRef = useRef(isControlled);
|
|
10
|
+
isControlledRef.current = isControlled;
|
|
11
|
+
const onChangeRef = useRef(onChange);
|
|
12
|
+
onChangeRef.current = onChange;
|
|
13
|
+
const setValue = useCallback((next, ...args) => {
|
|
14
|
+
const resolved = typeof next === "function" ? next(valueRef.current) : next;
|
|
15
|
+
if (!isControlledRef.current) {
|
|
16
|
+
setInternalValue(resolved);
|
|
17
|
+
}
|
|
18
|
+
onChangeRef.current?.(resolved, ...args);
|
|
19
|
+
}, []);
|
|
20
|
+
return [value, setValue];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
useControlledState
|
|
25
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkL3WPA2RPjs = require('./chunk-L3WPA2RP.js');
|
|
4
4
|
|
|
5
5
|
// src/components/RichTextEditor.tsx
|
|
6
6
|
var _react = require('react');
|
|
@@ -37,18 +37,11 @@ var RichTextEditor = ({
|
|
|
37
37
|
}) => {
|
|
38
38
|
const editorRef = _react.useRef.call(void 0, null);
|
|
39
39
|
const engineRef = _react.useRef.call(void 0, null);
|
|
40
|
-
const [currentContent,
|
|
40
|
+
const [currentContent, setContent] = _chunkL3WPA2RPjs.useControlledState.call(void 0, value, defaultValue, onChange);
|
|
41
|
+
const isControlled = value !== void 0;
|
|
41
42
|
const [activeFormats, setActiveFormats] = _react.useState.call(void 0, /* @__PURE__ */ new Set());
|
|
42
43
|
const toolbarItems = _nullishCoalesce(toolbar, () => ( _tigercatcore.defaultToolbar));
|
|
43
44
|
const empty = _tigercatcore.isContentEmpty.call(void 0, currentContent);
|
|
44
|
-
const onChangeRef = _react.useRef.call(void 0, onChange);
|
|
45
|
-
const setInternalValueRef = _react.useRef.call(void 0, setInternalValue);
|
|
46
|
-
const isControlledRef = _react.useRef.call(void 0, isControlled);
|
|
47
|
-
_react.useEffect.call(void 0, () => {
|
|
48
|
-
onChangeRef.current = onChange;
|
|
49
|
-
setInternalValueRef.current = setInternalValue;
|
|
50
|
-
isControlledRef.current = isControlled;
|
|
51
|
-
}, [onChange, setInternalValue, isControlled]);
|
|
52
45
|
_react.useEffect.call(void 0, () => {
|
|
53
46
|
if (!editorRef.current) return;
|
|
54
47
|
const factory = _nullishCoalesce(engine, () => ( _tigercatcore.builtinRichTextEngine));
|
|
@@ -60,8 +53,7 @@ var RichTextEditor = ({
|
|
|
60
53
|
placeholder,
|
|
61
54
|
toolbar: toolbarItems,
|
|
62
55
|
notifyChange(html) {
|
|
63
|
-
|
|
64
|
-
_optionalChain([onChangeRef, 'access', _ => _.current, 'optionalCall', _2 => _2(html)]);
|
|
56
|
+
setContent(html);
|
|
65
57
|
},
|
|
66
58
|
notifyActiveFormats(next) {
|
|
67
59
|
setActiveFormats(next);
|
|
@@ -79,7 +71,7 @@ var RichTextEditor = ({
|
|
|
79
71
|
}
|
|
80
72
|
}, [value, isControlled]);
|
|
81
73
|
_react.useEffect.call(void 0, () => {
|
|
82
|
-
_optionalChain([engineRef, 'access',
|
|
74
|
+
_optionalChain([engineRef, 'access', _ => _.current, 'optionalAccess', _2 => _2.setReadOnly, 'call', _3 => _3(readOnly, disabled)]);
|
|
83
75
|
}, [readOnly, disabled]);
|
|
84
76
|
const execButtonAction = _react.useCallback.call(void 0,
|
|
85
77
|
(btn) => {
|
|
@@ -88,7 +80,7 @@ var RichTextEditor = ({
|
|
|
88
80
|
btn.action(editorRef.current);
|
|
89
81
|
return;
|
|
90
82
|
}
|
|
91
|
-
_optionalChain([engineRef, 'access',
|
|
83
|
+
_optionalChain([engineRef, 'access', _4 => _4.current, 'optionalAccess', _5 => _5.exec, 'call', _6 => _6(btn.name)]);
|
|
92
84
|
},
|
|
93
85
|
[readOnly, disabled]
|
|
94
86
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkUAM3RQY4js = require('./chunk-UAM3RQY4.js');
|
|
4
4
|
|
|
5
5
|
// src/components/FormItem.tsx
|
|
6
6
|
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
@@ -43,7 +43,7 @@ var FormItem = ({
|
|
|
43
43
|
className,
|
|
44
44
|
condition
|
|
45
45
|
}) => {
|
|
46
|
-
const formContext =
|
|
46
|
+
const formContext = _chunkUAM3RQY4js.useFormContext.call(void 0, );
|
|
47
47
|
const [errorMessage, setErrorMessage] = _react.useState.call(void 0, "");
|
|
48
48
|
const [shakeTrigger, setShakeTrigger] = _react.useState.call(void 0, 0);
|
|
49
49
|
const prevFormErrorRef = _react.useRef.call(void 0, "");
|