@synnaxlabs/pluto 0.12.0 → 0.14.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/Center-8mBjm1cO.js +126 -0
- package/dist/{Center-gEKkAkdh.js.map → Center-8mBjm1cO.js.map} +1 -1
- package/dist/Center-ER_owvfX.cjs +2 -0
- package/dist/{Center-ZAcURh-3.cjs.map → Center-ER_owvfX.cjs.map} +1 -1
- package/dist/Header-9CR1VnwV.js +34 -0
- package/dist/{Header-7x6367IV.js.map → Header-9CR1VnwV.js.map} +1 -1
- package/dist/Header-PpcdP7hn.cjs +2 -0
- package/dist/{Header-5YX6FUn6.cjs.map → Header-PpcdP7hn.cjs.map} +1 -1
- package/dist/Item--h4UWJZo.js +80 -0
- package/dist/{Item-owLU4Xop.js.map → Item--h4UWJZo.js.map} +1 -1
- package/dist/Item-EBiM5yGJ.cjs +2 -0
- package/dist/{Item-HWzX7RK2.cjs.map → Item-EBiM5yGJ.cjs.map} +1 -1
- package/dist/Item-_og4CdwZ.cjs +2 -0
- package/dist/{Item-rkSKzZoh.cjs.map → Item-_og4CdwZ.cjs.map} +1 -1
- package/dist/Item-kbCoFEj2.js +137 -0
- package/dist/{Item-EDdYN2NK.js.map → Item-kbCoFEj2.js.map} +1 -1
- package/dist/Keyboard-IWRXgioJ.js +14 -0
- package/dist/{Keyboard-mE03PKwA.js.map → Keyboard-IWRXgioJ.js.map} +1 -1
- package/dist/Keyboard-bXNOi0bP.cjs +2 -0
- package/dist/{Keyboard-w372197S.cjs.map → Keyboard-bXNOi0bP.cjs.map} +1 -1
- package/dist/Link-16dbGK7G.cjs +2 -0
- package/dist/{Link-xlTZan29.cjs.map → Link-16dbGK7G.cjs.map} +1 -1
- package/dist/Link-fRQvqiYx.js +11 -0
- package/dist/{Link-laNlv47N.js.map → Link-fRQvqiYx.js.map} +1 -1
- package/dist/SelectLevel-DrdlLBOs.cjs +2 -0
- package/dist/{SelectLevel-bGb0dRXh.cjs.map → SelectLevel-DrdlLBOs.cjs.map} +1 -1
- package/dist/SelectLevel-Uod3Ez6y.js +121 -0
- package/dist/{SelectLevel-cewIWtOv.js.map → SelectLevel-Uod3Ez6y.js.map} +1 -1
- package/dist/Selector-8rTHUToj.cjs +2 -0
- package/dist/{Selector-hQLSIYum.cjs.map → Selector-8rTHUToj.cjs.map} +1 -1
- package/dist/Selector-R4SumEUV.js +233 -0
- package/dist/{Selector-R3lL41_i.js.map → Selector-R4SumEUV.js.map} +1 -1
- package/dist/Swatch--Prmb5q_.cjs +2 -0
- package/dist/Swatch--Prmb5q_.cjs.map +1 -0
- package/dist/Swatch-IH4OmVdd.js +82 -0
- package/dist/Swatch-IH4OmVdd.js.map +1 -0
- package/dist/TimeRangeChip-jI9Nn9z8.js +7384 -0
- package/dist/TimeRangeChip-jI9Nn9z8.js.map +1 -0
- package/dist/TimeRangeChip-jQH9NacG.cjs +50 -0
- package/dist/TimeRangeChip-jQH9NacG.cjs.map +1 -0
- package/dist/Toggle-HVxv8bv2.js +10648 -0
- package/dist/Toggle-HVxv8bv2.js.map +1 -0
- package/dist/Toggle-QnKinMl4.cjs +73 -0
- package/dist/Toggle-QnKinMl4.cjs.map +1 -0
- package/dist/Video-iiPAk_ej.cjs +2 -0
- package/dist/{Video-a7BUKvzF.cjs.map → Video-iiPAk_ej.cjs.map} +1 -1
- package/dist/Video-vyIORMaH.js +11 -0
- package/dist/{Video-Vpwp5ao1.js.map → Video-vyIORMaH.js.map} +1 -1
- package/dist/aether.cjs +1 -89
- package/dist/aether.cjs.map +1 -1
- package/dist/aether.js +76 -80
- package/dist/aether.js.map +1 -1
- package/dist/align.cjs +1 -9
- package/dist/align.cjs.map +1 -1
- package/dist/align.js +5 -5
- package/dist/button.cjs +1 -14
- package/dist/button.cjs.map +1 -1
- package/dist/button.js +9 -8
- package/dist/button.js.map +1 -1
- package/dist/color-9QRifwqk.js +9 -0
- package/dist/color-9QRifwqk.js.map +1 -0
- package/dist/color-gJTR__ef.cjs +2 -0
- package/dist/color-gJTR__ef.cjs.map +1 -0
- package/dist/color.cjs +2 -0
- package/dist/color.cjs.map +1 -0
- package/dist/color.js +16 -0
- package/dist/color.js.map +1 -0
- package/dist/component-LA8IXGSG.js +17961 -0
- package/dist/component-LA8IXGSG.js.map +1 -0
- package/dist/component-dgLAEMbt.cjs +23 -0
- package/dist/component-dgLAEMbt.cjs.map +1 -0
- package/dist/css-5RvvUhjr.js +6414 -0
- package/dist/{css-NTD4Xm8x.js.map → css-5RvvUhjr.js.map} +1 -1
- package/dist/css-s9KpanYu.cjs +8 -0
- package/dist/{css-V3VUT_Js.cjs.map → css-s9KpanYu.cjs.map} +1 -1
- package/dist/css.cjs +2 -0
- package/dist/css.cjs.map +1 -0
- package/dist/css.js +10 -0
- package/dist/css.js.map +1 -0
- package/dist/dimensions--C45ahLe.js +20 -0
- package/dist/{dimensions-guJ5PHmb.js.map → dimensions--C45ahLe.js.map} +1 -1
- package/dist/dimensions-HfZjDJQz.cjs +2 -0
- package/dist/{dimensions-Sej0Zly9.cjs.map → dimensions-HfZjDJQz.cjs.map} +1 -1
- package/dist/dropdown.cjs +1 -12
- package/dist/dropdown.cjs.map +1 -1
- package/dist/dropdown.js +7 -6
- package/dist/dropdown.js.map +1 -1
- package/dist/external--jsfNkbo.cjs +2 -0
- package/dist/external--jsfNkbo.cjs.map +1 -0
- package/dist/external-1DGLK9F2.js +17 -0
- package/dist/external-1DGLK9F2.js.map +1 -0
- package/dist/external-4h9H4Y_N.js +21 -0
- package/dist/external-4h9H4Y_N.js.map +1 -0
- package/dist/external-4uqucf0m.js +67 -0
- package/dist/{external-QuVTCnGl.js.map → external-4uqucf0m.js.map} +1 -1
- package/dist/external-A_eQgT5T.cjs +2 -0
- package/dist/external-A_eQgT5T.cjs.map +1 -0
- package/dist/external-FCO_hdNr.js +24 -0
- package/dist/external-FCO_hdNr.js.map +1 -0
- package/dist/external-HZ6f2KvU.cjs +2 -0
- package/dist/external-HZ6f2KvU.cjs.map +1 -0
- package/dist/external-LPdjowBG.cjs +2 -0
- package/dist/external-LPdjowBG.cjs.map +1 -0
- package/dist/external-O1b3FJKI.cjs +2 -0
- package/dist/external-O1b3FJKI.cjs.map +1 -0
- package/dist/external-RGdrJX7y.cjs +2 -0
- package/dist/{external-9Ncn2J9B.cjs.map → external-RGdrJX7y.cjs.map} +1 -1
- package/dist/external-WiHGqQPA.js +30 -0
- package/dist/external-WiHGqQPA.js.map +1 -0
- package/dist/external-eWu6hCLU.cjs +2 -0
- package/dist/external-eWu6hCLU.cjs.map +1 -0
- package/dist/external-kvAz85mu.js +18 -0
- package/dist/external-kvAz85mu.js.map +1 -0
- package/dist/external-mpVdVPF1.js +88 -0
- package/dist/external-mpVdVPF1.js.map +1 -0
- package/dist/external-nTDD8IMd.cjs +2 -0
- package/dist/external-nTDD8IMd.cjs.map +1 -0
- package/dist/external-phknItOL.js +15 -0
- package/dist/external-phknItOL.js.map +1 -0
- package/dist/external-rGcWjp84.cjs +2 -0
- package/dist/{external-zBiIxeDG.cjs.map → external-rGcWjp84.cjs.map} +1 -1
- package/dist/external-r_2-tYfC.js +88 -0
- package/dist/{external-up1sE3F6.js.map → external-r_2-tYfC.js.map} +1 -1
- package/dist/external-sHbzLUrP.js +17 -0
- package/dist/external-sHbzLUrP.js.map +1 -0
- package/dist/external-tZiYBM94.cjs +2 -0
- package/dist/external-tZiYBM94.cjs.map +1 -0
- package/dist/external-tnCo64yx.cjs +2 -0
- package/dist/external-tnCo64yx.cjs.map +1 -0
- package/dist/external-uR-7_68y.js +16 -0
- package/dist/external-uR-7_68y.js.map +1 -0
- package/dist/external-uSIsCKNG.js +15 -0
- package/dist/external-uSIsCKNG.js.map +1 -0
- package/dist/external-z6BLlxur.cjs +2 -0
- package/dist/external-z6BLlxur.cjs.map +1 -0
- package/dist/font-HpLrwPSD.js +16 -0
- package/dist/{font-t7KoGNFX.js.map → font-HpLrwPSD.js.map} +1 -1
- package/dist/font-yosRgv9n.cjs +2 -0
- package/dist/{font-wlgaMRYN.cjs.map → font-yosRgv9n.cjs.map} +1 -1
- package/dist/fontString-_dtZSiPk.cjs +2 -0
- package/dist/{fontString-i24UxKCQ.cjs.map → fontString-_dtZSiPk.cjs.map} +1 -1
- package/dist/fontString-lodjYTYz.js +12 -0
- package/dist/{fontString-RKvYIr5H.js.map → fontString-lodjYTYz.js.map} +1 -1
- package/dist/header.cjs +1 -14
- package/dist/header.cjs.map +1 -1
- package/dist/header.js +9 -8
- package/dist/header.js.map +1 -1
- package/dist/index.cjs +1 -1174
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +737 -930
- package/dist/index.js.map +1 -1
- package/dist/input/Input.stories.d.ts +1 -0
- package/dist/input/TextArea.d.ts +20 -0
- package/dist/input/external.d.ts +1 -0
- package/dist/input/types.d.ts +4 -2
- package/dist/input.cjs +1 -14
- package/dist/input.cjs.map +1 -1
- package/dist/input.js +9 -8
- package/dist/input.js.map +1 -1
- package/dist/jsx-runtime-NmMXPjeo.js +632 -0
- package/dist/{jsx-runtime-rX5tAIG2.js.map → jsx-runtime-NmMXPjeo.js.map} +1 -1
- package/dist/jsx-runtime-evvPGacs.cjs +28 -0
- package/dist/{jsx-runtime-N1ikfypN.cjs.map → jsx-runtime-evvPGacs.cjs.map} +1 -1
- package/dist/list.cjs +1 -26
- package/dist/list.cjs.map +1 -1
- package/dist/list.js +21 -19
- package/dist/list.js.map +1 -1
- package/dist/menu.cjs +1 -15
- package/dist/menu.cjs.map +1 -1
- package/dist/menu.js +10 -9
- package/dist/menu.js.map +1 -1
- package/dist/style.css +1 -3119
- package/dist/table-MJysJcCC.js +10312 -0
- package/dist/table-MJysJcCC.js.map +1 -0
- package/dist/table-NIrLpFOm.cjs +69 -0
- package/dist/table-NIrLpFOm.cjs.map +1 -0
- package/dist/tabs.cjs +1 -14
- package/dist/tabs.cjs.map +1 -1
- package/dist/tabs.js +9 -8
- package/dist/tabs.js.map +1 -1
- package/dist/text.cjs +1 -16
- package/dist/text.cjs.map +1 -1
- package/dist/text.js +11 -10
- package/dist/text.js.map +1 -1
- package/dist/theming.cjs +1 -15
- package/dist/theming.cjs.map +1 -1
- package/dist/theming.js +10 -9
- package/dist/theming.js.map +1 -1
- package/dist/tree.cjs +1 -25
- package/dist/tree.cjs.map +1 -1
- package/dist/tree.js +20 -18
- package/dist/tree.js.map +1 -1
- package/dist/triggers.cjs +1 -15
- package/dist/triggers.cjs.map +1 -1
- package/dist/triggers.js +10 -9
- package/dist/triggers.js.map +1 -1
- package/dist/useDrag-4o21IpGy.js +36 -0
- package/dist/{useDrag-rQt5hv4R.js.map → useDrag-4o21IpGy.js.map} +1 -1
- package/dist/useDrag-l_moa7e3.cjs +2 -0
- package/dist/{useDrag-KRQ7DTg1.cjs.map → useDrag-l_moa7e3.cjs.map} +1 -1
- package/dist/video.cjs +1 -9
- package/dist/video.cjs.map +1 -1
- package/dist/video.js +3 -3
- package/package.json +61 -51
- package/dist/Center-ZAcURh-3.cjs +0 -148
- package/dist/Center-gEKkAkdh.js +0 -149
- package/dist/Header-5YX6FUn6.cjs +0 -35
- package/dist/Header-7x6367IV.js +0 -36
- package/dist/Item-EDdYN2NK.js +0 -171
- package/dist/Item-HWzX7RK2.cjs +0 -170
- package/dist/Item-owLU4Xop.js +0 -97
- package/dist/Item-rkSKzZoh.cjs +0 -96
- package/dist/Keyboard-mE03PKwA.js +0 -14
- package/dist/Keyboard-w372197S.cjs +0 -13
- package/dist/Link-laNlv47N.js +0 -13
- package/dist/Link-xlTZan29.cjs +0 -12
- package/dist/SelectLevel-bGb0dRXh.cjs +0 -152
- package/dist/SelectLevel-cewIWtOv.js +0 -153
- package/dist/Selector-R3lL41_i.js +0 -267
- package/dist/Selector-hQLSIYum.cjs +0 -266
- package/dist/TimeRangeChip-XXXLMCrf.cjs +0 -9316
- package/dist/TimeRangeChip-XXXLMCrf.cjs.map +0 -1
- package/dist/TimeRangeChip-eDCX5pUC.js +0 -9301
- package/dist/TimeRangeChip-eDCX5pUC.js.map +0 -1
- package/dist/Toggle-eOKYw1OT.cjs +0 -13664
- package/dist/Toggle-eOKYw1OT.cjs.map +0 -1
- package/dist/Toggle-kLunfJtR.js +0 -13665
- package/dist/Toggle-kLunfJtR.js.map +0 -1
- package/dist/Video-Vpwp5ao1.js +0 -12
- package/dist/Video-a7BUKvzF.cjs +0 -11
- package/dist/component-joFaJiQW.cjs +0 -24719
- package/dist/component-joFaJiQW.cjs.map +0 -1
- package/dist/component-k78Jq9I7.js +0 -24720
- package/dist/component-k78Jq9I7.js.map +0 -1
- package/dist/css-NTD4Xm8x.js +0 -9206
- package/dist/css-V3VUT_Js.cjs +0 -9204
- package/dist/dimensions-Sej0Zly9.cjs +0 -26
- package/dist/dimensions-guJ5PHmb.js +0 -27
- package/dist/external-2Aicsb3l.js +0 -88
- package/dist/external-2Aicsb3l.js.map +0 -1
- package/dist/external-9Ncn2J9B.cjs +0 -93
- package/dist/external-9RCzxzgZ.js +0 -30
- package/dist/external-9RCzxzgZ.js.map +0 -1
- package/dist/external-9pS8-DvV.js +0 -15
- package/dist/external-9pS8-DvV.js.map +0 -1
- package/dist/external-KxlyA74C.js +0 -20
- package/dist/external-KxlyA74C.js.map +0 -1
- package/dist/external-OSLzuRs1.cjs +0 -14
- package/dist/external-OSLzuRs1.cjs.map +0 -1
- package/dist/external-PS3nzqUn.cjs +0 -23
- package/dist/external-PS3nzqUn.cjs.map +0 -1
- package/dist/external-QRmqSjV0.js +0 -18
- package/dist/external-QRmqSjV0.js.map +0 -1
- package/dist/external-QuVTCnGl.js +0 -71
- package/dist/external-U5HRPaDI.cjs +0 -17
- package/dist/external-U5HRPaDI.cjs.map +0 -1
- package/dist/external-_CtRDtih.js +0 -17
- package/dist/external-_CtRDtih.js.map +0 -1
- package/dist/external-eQU48hM4.cjs +0 -87
- package/dist/external-eQU48hM4.cjs.map +0 -1
- package/dist/external-kbDFnfuk.js +0 -24
- package/dist/external-kbDFnfuk.js.map +0 -1
- package/dist/external-oX1JmOFf.js +0 -17
- package/dist/external-oX1JmOFf.js.map +0 -1
- package/dist/external-oZe6tF4A.cjs +0 -14
- package/dist/external-oZe6tF4A.cjs.map +0 -1
- package/dist/external-tVcmKSsT.cjs +0 -19
- package/dist/external-tVcmKSsT.cjs.map +0 -1
- package/dist/external-up1sE3F6.js +0 -94
- package/dist/external-uvx0b-Jw.cjs +0 -16
- package/dist/external-uvx0b-Jw.cjs.map +0 -1
- package/dist/external-vXBQOmKv.js +0 -15
- package/dist/external-vXBQOmKv.js.map +0 -1
- package/dist/external-yiqRIIvW.cjs +0 -16
- package/dist/external-yiqRIIvW.cjs.map +0 -1
- package/dist/external-zBiIxeDG.cjs +0 -70
- package/dist/external-zw9fckWT.cjs +0 -29
- package/dist/external-zw9fckWT.cjs.map +0 -1
- package/dist/font-t7KoGNFX.js +0 -17
- package/dist/font-wlgaMRYN.cjs +0 -16
- package/dist/fontString-RKvYIr5H.js +0 -13
- package/dist/fontString-i24UxKCQ.cjs +0 -12
- package/dist/jsx-runtime-N1ikfypN.cjs +0 -931
- package/dist/jsx-runtime-rX5tAIG2.js +0 -932
- package/dist/table-8MFXzE4C.js +0 -13664
- package/dist/table-8MFXzE4C.js.map +0 -1
- package/dist/table-VNkSG_Cj.cjs +0 -13661
- package/dist/table-VNkSG_Cj.cjs.map +0 -1
- package/dist/useDrag-KRQ7DTg1.cjs +0 -48
- package/dist/useDrag-rQt5hv4R.js +0 -49
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item-
|
|
1
|
+
{"version":3,"file":"Item-_og4CdwZ.cjs","sources":["../src/input/HelpText.tsx","../src/input/Label.tsx","../src/util/case.ts","../src/input/Item.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { CSS } from \"@/css\";\nimport { type Status } from \"@/status\";\nimport { Text } from \"@/text\";\n\nimport \"@/input/HelpText.css\";\n\n/** Props for the {@link HelpText} component. */\nexport interface HelpTextProps extends Omit<Text.TextProps<\"small\">, \"level\" | \"ref\"> {\n variant?: Status.Variant;\n}\n\n/**\n * Help text for an input component. We generally recommend using Input.Item with a\n * 'helpText' prop instead of this component. This component is useful for low-level\n * control over the help text element.\n *\n * @param props - Props for the help text component. Unlisted props are passed to the\n * underlying text element.\n * @param props.variant - The variant of the help text.\n * \"success\" | \"error\" | \"warning\" | \"info\" | \"loading\" | \"disabled\n * @default \"info\"\n */\nexport const HelpText = ({\n className,\n variant = \"error\",\n ...props\n}: HelpTextProps): ReactElement => (\n <Text.Text<\"small\">\n className={CSS(\n CSS.B(\"input-help-text\"),\n CSS.BM(\"input-help-text\", variant),\n className,\n )}\n level=\"small\"\n {...props}\n />\n);\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type DetailedHTMLProps, type HTMLAttributes, type ReactElement } from \"react\";\n\nimport { CSS } from \"@/css\";\n\nimport \"@/input/Label.css\";\n\n/** Props for the {@link Label} component. */\nexport interface LabelProps\n extends DetailedHTMLProps<HTMLAttributes<HTMLLabelElement>, HTMLLabelElement> {}\n\n/**\n * A thin, styled wrapper for an input label. We generally recommend using Input.Item\n * with a 'label' prop instead of this component. This component is useful for\n * low-level control over the label element.\n *\n * @param props - Props for the label component. Unlisted props are passed to the\n * underlying label element.\n */\nexport const Label = ({ className, ...props }: LabelProps): ReactElement => {\n return <label className={CSS(CSS.B(\"input-label\"), className)} {...props} />;\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nexport const camelToTitle = (str: string): string =>\n str.replace(/([A-Z])/g, \" $1\").replace(/^./, (str) => str.toUpperCase());\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { direction } from \"@synnaxlabs/x\";\nimport {\n type UseControllerProps,\n useController,\n type FieldValues,\n type FieldPath,\n} from \"react-hook-form\";\n\nimport { Align } from \"@/align\";\nimport { CSS } from \"@/css\";\nimport { HelpText } from \"@/input/HelpText\";\nimport { Label } from \"@/input/Label\";\nimport { type Control, type Value } from \"@/input/types\";\nimport { camelToTitle } from \"@/util/case\";\n\nimport { type RenderProp } from \"..\";\n\nimport \"@/input/Item.css\";\n\ninterface ItemExtensionProps extends Align.SpaceExtensionProps {\n label?: string;\n showLabel?: boolean;\n helpText?: string;\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport interface ItemProps extends Align.SpaceProps {\n label?: string;\n showLabel?: boolean;\n helpText?: string;\n}\n\nconst maybeDefaultAlignment = (\n align?: Align.Alignment,\n dir: direction.Crude = \"x\",\n): Align.Alignment => {\n if (align != null) return align;\n return direction.construct(dir) === \"y\" ? \"stretch\" : \"center\";\n};\n\nexport const Item = ({\n label,\n showLabel = true,\n helpText,\n direction = \"y\",\n className,\n children,\n align,\n size = \"small\",\n ...props\n}: ItemProps): ReactElement => {\n let inputAndHelp: ReactElement;\n if (direction === \"x\")\n inputAndHelp = (\n <Align.Space direction=\"y\" size=\"small\">\n {children}\n {helpText != null && <HelpText>{helpText}</HelpText>}\n </Align.Space>\n );\n else\n inputAndHelp = (\n <>\n {children}\n {helpText != null && <HelpText>{helpText}</HelpText>}\n </>\n );\n\n return (\n <Align.Space\n className={CSS(CSS.B(\"input-item\"), className)}\n direction={direction}\n size={size}\n align={maybeDefaultAlignment(align, direction)}\n {...props}\n >\n {showLabel && <Label>{label}</Label>}\n {inputAndHelp}\n </Align.Space>\n );\n};\n\nexport type ItemControlledProps<\n I extends Value = string | number,\n O extends Value = I,\n F extends FieldValues = FieldValues,\n TName extends FieldPath<F> = FieldPath<F>,\n> = ItemExtensionProps &\n UseControllerProps<F, TName> & {\n children: RenderProp<Control<I, O>>;\n };\n\nexport const ItemControlled = <\n I extends Value = string | number,\n O extends Value = I,\n F extends FieldValues = FieldValues,\n TName extends FieldPath<F> = FieldPath<F>,\n>({\n name,\n rules,\n control,\n shouldUnregister,\n defaultValue,\n label,\n children,\n ...props\n}: ItemControlledProps<I, O, F, TName>): ReactElement => {\n const { field, fieldState } = useController<F, TName>({\n control,\n rules,\n name,\n shouldUnregister,\n });\n if (label == null) label = camelToTitle(name);\n return (\n <Item ref={field.ref} label={label} helpText={fieldState.error?.message} {...props}>\n {children({ value: field.value, onChange: field.onChange })}\n </Item>\n );\n};\n"],"names":["HelpText","className","variant","props","jsx","Text.Text","CSS","Label","camelToTitle","str","maybeDefaultAlignment","align","dir","direction","Item","label","showLabel","helpText","children","size","inputAndHelp","Align.Space","jsxs","Fragment","ItemControlled","name","rules","control","shouldUnregister","defaultValue","field","fieldState","useController","_a"],"mappings":"mPAiCO,MAAMA,EAAW,CAAC,CACvB,UAAAC,EACA,QAAAC,EAAU,QACV,GAAGC,CACL,IACEC,EAAA,kBAAA,IAACC,EAAK,KAAL,CACC,UAAWC,EAAA,IACTA,EAAA,IAAI,EAAE,iBAAiB,EACvBA,MAAI,GAAG,kBAAmBJ,CAAO,EACjCD,CACF,EACA,MAAM,QACL,GAAGE,CAAA,CACN,ECnBWI,EAAQ,CAAC,CAAE,UAAAN,EAAW,GAAGE,KAC7BC,EAAA,kBAAA,IAAC,QAAM,CAAA,UAAWE,EAAI,IAAAA,EAAA,IAAI,EAAE,aAAa,EAAGL,CAAS,EAAI,GAA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AG,CAAA,CACD,EACD,OAAIb,GAAS,OAAMA,EAAQP,EAAaiB,CAAI,GAE1CrB,wBAACU,GAAK,IAAKgB,EAAM,IAAK,MAAAf,EAAc,UAAUkB,EAAAF,EAAW,QAAX,YAAAE,EAAkB,QAAU,GAAG9B,EAC1E,SAAAe,EAAS,CAAE,MAAOY,EAAM,MAAO,SAAUA,EAAM,QAAU,CAAA,CAC5D,CAAA,CAEJ"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { j as m } from "./jsx-runtime-NmMXPjeo.js";
|
|
2
|
+
import { forwardRef as b, useRef as v, useState as y, createContext as L, useContext as O } from "react";
|
|
3
|
+
import { x as p, C as i, u as B, b as C } from "./css-5RvvUhjr.js";
|
|
4
|
+
import { a9 as R, B as j, I as A } from "./Toggle-HVxv8bv2.js";
|
|
5
|
+
import { L as _ } from "./Link-fRQvqiYx.js";
|
|
6
|
+
const f = {
|
|
7
|
+
visible: !1,
|
|
8
|
+
keys: [],
|
|
9
|
+
xy: p.ZERO
|
|
10
|
+
}, h = i.BM("context", "selected"), w = i.BE("context", "target"), E = i.BE("menu-context", "container"), D = (n) => {
|
|
11
|
+
let t = n;
|
|
12
|
+
for (; t != null && !t.classList.contains(w); ) {
|
|
13
|
+
if (t.classList.contains(E))
|
|
14
|
+
return n;
|
|
15
|
+
t = t.parentElement;
|
|
16
|
+
}
|
|
17
|
+
return t;
|
|
18
|
+
}, X = (n) => {
|
|
19
|
+
var c;
|
|
20
|
+
const t = D(n), o = ((c = t.parentElement) == null ? void 0 : c.querySelectorAll(`.${h}`)) ?? [];
|
|
21
|
+
return [t, ...Array.from(o)];
|
|
22
|
+
}, Z = () => {
|
|
23
|
+
const n = v(null), [t, o] = y(f), c = (e, s) => {
|
|
24
|
+
const l = p.construct(e);
|
|
25
|
+
"preventDefault" in e ? (e.preventDefault(), e.stopPropagation(), s = s ?? B(X(e.target).map((u) => u.id))) : s = [], o({ visible: !0, keys: s, xy: l });
|
|
26
|
+
}, a = (e) => {
|
|
27
|
+
n.current = e, e != null && o((s) => {
|
|
28
|
+
if (s.visible) {
|
|
29
|
+
const [l, u] = C.positionSoVisible(
|
|
30
|
+
e,
|
|
31
|
+
window.document.documentElement
|
|
32
|
+
);
|
|
33
|
+
if (u)
|
|
34
|
+
return { ...s, xy: C.topLeft(l) };
|
|
35
|
+
}
|
|
36
|
+
return s;
|
|
37
|
+
});
|
|
38
|
+
}, r = () => o(f);
|
|
39
|
+
return R(n, r), {
|
|
40
|
+
...t,
|
|
41
|
+
close: r,
|
|
42
|
+
open: c,
|
|
43
|
+
ref: a
|
|
44
|
+
};
|
|
45
|
+
}, g = ({
|
|
46
|
+
children: n,
|
|
47
|
+
menu: t,
|
|
48
|
+
visible: o,
|
|
49
|
+
open: c,
|
|
50
|
+
close: a,
|
|
51
|
+
xy: r,
|
|
52
|
+
keys: e,
|
|
53
|
+
className: s,
|
|
54
|
+
...l
|
|
55
|
+
}, u) => {
|
|
56
|
+
const d = o ? t == null ? void 0 : t({ keys: e }) : null;
|
|
57
|
+
return /* @__PURE__ */ m.jsxs(
|
|
58
|
+
"div",
|
|
59
|
+
{
|
|
60
|
+
className: i(E, s, i.inheritDims()),
|
|
61
|
+
onContextMenu: c,
|
|
62
|
+
...l,
|
|
63
|
+
children: [
|
|
64
|
+
n,
|
|
65
|
+
d != null && /* @__PURE__ */ m.jsx(
|
|
66
|
+
"div",
|
|
67
|
+
{
|
|
68
|
+
className: i(i.B("menu-context"), i.bordered()),
|
|
69
|
+
ref: u,
|
|
70
|
+
style: { left: r.x, top: r.y },
|
|
71
|
+
onClick: a,
|
|
72
|
+
children: d
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}, q = b(g);
|
|
79
|
+
q.displayName = "ContextMenu";
|
|
80
|
+
const I = L({
|
|
81
|
+
onClick: () => {
|
|
82
|
+
},
|
|
83
|
+
selected: ""
|
|
84
|
+
}), z = () => O(I), H = ({
|
|
85
|
+
children: n,
|
|
86
|
+
onChange: t,
|
|
87
|
+
level: o,
|
|
88
|
+
iconSpacing: c,
|
|
89
|
+
value: a = ""
|
|
90
|
+
}) => {
|
|
91
|
+
const r = (e) => t == null ? void 0 : t(e);
|
|
92
|
+
return /* @__PURE__ */ m.jsx(
|
|
93
|
+
I.Provider,
|
|
94
|
+
{
|
|
95
|
+
value: { onClick: r, selected: a, level: o, iconSpacing: c },
|
|
96
|
+
children: n
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
}, x = (n, t) => (
|
|
100
|
+
// eslint-disable-next-line react/display-name
|
|
101
|
+
(o) => {
|
|
102
|
+
const { itemKey: c, className: a, onClick: r, size: e, ...s } = {
|
|
103
|
+
...t,
|
|
104
|
+
...o
|
|
105
|
+
}, { onClick: l, selected: u, level: d, iconSpacing: M } = z(), N = (S) => {
|
|
106
|
+
l(c), r == null || r(S);
|
|
107
|
+
}, k = u === c;
|
|
108
|
+
return (
|
|
109
|
+
// @ts-expect-error
|
|
110
|
+
/* @__PURE__ */ m.jsx(
|
|
111
|
+
n,
|
|
112
|
+
{
|
|
113
|
+
level: d,
|
|
114
|
+
...s,
|
|
115
|
+
onClick: N,
|
|
116
|
+
variant: "text",
|
|
117
|
+
className: i(i.B("menu-item"), i.selected(k), a),
|
|
118
|
+
size: e ?? M
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
), P = x(j, { noWrap: !0 }), W = x(A), $ = x(_, { noWrap: !0 }), T = P;
|
|
124
|
+
T.Icon = W;
|
|
125
|
+
T.Link = $;
|
|
126
|
+
export {
|
|
127
|
+
h as C,
|
|
128
|
+
T as I,
|
|
129
|
+
H as M,
|
|
130
|
+
w as a,
|
|
131
|
+
q as b,
|
|
132
|
+
P as c,
|
|
133
|
+
I as d,
|
|
134
|
+
z as e,
|
|
135
|
+
Z as u
|
|
136
|
+
};
|
|
137
|
+
//# sourceMappingURL=Item-kbCoFEj2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item-EDdYN2NK.js","sources":["../src/menu/ContextMenu.tsx","../src/menu/Menu.tsx","../src/menu/Item.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport {\n type ComponentPropsWithoutRef,\n type ForwardedRef,\n forwardRef,\n type ReactElement,\n type RefCallback,\n useRef,\n useState,\n} from \"react\";\n\nimport { box, unique, xy } from \"@synnaxlabs/x\";\n\nimport { CSS } from \"@/css\";\nimport { useClickOutside } from \"@/hooks\";\nimport { type RenderProp } from \"@/util/renderProp\";\n\nimport \"@/menu/ContextMenu.css\";\n\ninterface ContextMenuState {\n visible: boolean;\n keys: string[];\n xy: xy.XY;\n}\n\n/** Supported event types for triggering a context menu. */\nexport type ContextMenuEvent = xy.Client & {\n preventDefault: () => void;\n stopPropagation: () => void;\n target: Element;\n};\n\n/** Opens the context menu. See {@link Menu.useContextMenu} for more details. */\nexport type ContextMenuOpen = (\n pos: xy.Crude | ContextMenuEvent,\n keys?: string[],\n) => void;\n\n/** Return value for the {@Menu.useContextMenu} hook. */\nexport interface UseContextMenuReturn extends ContextMenuState {\n visible: boolean;\n close: () => void;\n open: ContextMenuOpen;\n ref: RefCallback<HTMLDivElement>;\n}\n\nconst INITIAL_STATE: ContextMenuState = {\n visible: false,\n keys: [],\n xy: xy.ZERO,\n};\n\nexport const CONTEXT_SELECTED = CSS.BM(\"context\", \"selected\");\nexport const CONTEXT_TARGET = CSS.BE(\"context\", \"target\");\nconst CONTEXT_MENU_CONTAINER = CSS.BE(\"menu-context\", \"container\");\n\nconst findTarget = (target: HTMLElement): HTMLElement => {\n let candidate = target;\n while (candidate != null && !candidate.classList.contains(CONTEXT_TARGET)) {\n if (candidate.classList.contains(CONTEXT_MENU_CONTAINER)) return target;\n candidate = candidate.parentElement as HTMLElement;\n }\n return candidate;\n};\n\nconst findSelected = (target_: HTMLElement): HTMLElement[] => {\n const target = findTarget(target_);\n const selected = (target.parentElement?.querySelectorAll(`.${CONTEXT_SELECTED}`) ??\n []) as HTMLElement[];\n return [target, ...Array.from(selected)];\n};\n\n/**\n * Menu.useContextMenu extracts the logic for toggling a context menu, allowing\n * the caller to control the menu's visibility and position.\n *\n * @returns visible - Whether the menu is visible.\n * @returns close - A function to close the menu.\n * @returns open - A function to open the menu. The function accepts an XY coordinate and\n * an optional set of keys to set as the selected menu items. It's important to note\n * that these keys override the default behavior of the menu, which is explained in\n * the documentation for {@link Menu.ContextMenu}.\n */\nexport const useContextMenu = (): UseContextMenuReturn => {\n const menuRef = useRef<HTMLDivElement | null>(null);\n const [state, setMenuState] = useState<ContextMenuState>(INITIAL_STATE);\n\n const handleOpen: ContextMenuOpen = (e, keys) => {\n const p = xy.construct(e);\n if (\"preventDefault\" in e) {\n e.preventDefault();\n // Prevent parent context menus from opening.\n e.stopPropagation();\n keys = keys ?? unique(findSelected(e.target as HTMLElement).map((el) => el.id));\n } else keys = [];\n setMenuState({ visible: true, keys, xy: p });\n };\n\n const refCallback = (el: HTMLDivElement): void => {\n menuRef.current = el;\n if (el == null) return;\n setMenuState((prev) => {\n if (prev.visible) {\n const [repositioned, changed] = box.positionSoVisible(\n el,\n window.document.documentElement,\n );\n if (changed) return { ...prev, xy: box.topLeft(repositioned) };\n }\n return prev;\n });\n };\n\n const hideMenu = (): void => setMenuState(INITIAL_STATE);\n\n useClickOutside(menuRef, hideMenu);\n\n return {\n ...state,\n close: hideMenu,\n open: handleOpen,\n ref: refCallback,\n };\n};\n\nexport interface ContextMenuMenuProps {\n keys: string[];\n}\n\nexport interface ContextMenuProps\n extends UseContextMenuReturn,\n ComponentPropsWithoutRef<\"div\"> {\n menu?: RenderProp<ContextMenuMenuProps>;\n}\n\nconst ContextMenuCore = (\n {\n children,\n menu,\n visible,\n open,\n close,\n xy,\n keys,\n className,\n ...props\n }: ContextMenuProps,\n ref: ForwardedRef<HTMLDivElement>,\n): ReactElement => {\n const menuC = visible ? menu?.({ keys }) : null;\n\n return (\n <div\n className={CSS(CONTEXT_MENU_CONTAINER, className, CSS.inheritDims())}\n onContextMenu={open}\n {...props}\n >\n {children}\n {menuC != null && (\n <div\n className={CSS(CSS.B(\"menu-context\"), CSS.bordered())}\n ref={ref}\n style={{ left: xy.x, top: xy.y }}\n onClick={close}\n >\n {menuC}\n </div>\n )}\n </div>\n );\n};\n\n/**\n * Menu.ContextMenu wraps a set of children with a context menu. When the user right\n * clicks within wrapped area, the provided menu will be shown. Menu.ContextMenu should\n * be used in conjunction with the Menu.useContextMenu hook.\n *\n * The rendered menu is provided with a set of keys that represent the HTML IDs of the\n * context target elements. The first target is evaluated by traversing the parents\n * of the element that was right clicked until an element with the class \"pluto-context-target\"\n * is found. If no such element is found, the right clicked element itself is used as\n * the target. Subsequent targets are found by querying all siblings of the first target\n * that have the \"pluto-context-selected\" class.\n *\n * @example <caption>Example DOM structure</caption>\n * <div id=\"pluto-menu-context__container\">\n * <div className=\"pluto-context-target\" id=\"1\">\n * <span>\n * <h2>I was right clicked!</h2>\n * </span>\n * </div>\n * <div className=\"pluto-context-target pluto-context-selected\" id=\"2\">\n * <div className=\"pluto-context-target\" id=\"3\">\n * </div>\n *\n * In the above example, the keys provided to the menu would be [\"1\", \"2\"].\n *\n * The target resolution logic is ideal for both single and multi-select scenarios,\n * such as lists that have several selected rows that should be acted upon together.\n *\n * @param props - Props for the component. Expects all return values from the\n * useContextMenu hook. All non-hook and unlisted props will be spread to the\n * underlying div component acting as the root element.\n * @param props.menu - The menu to show when the user right clicks.\n */\nexport const ContextMenu = forwardRef(ContextMenuCore);\nContextMenu.displayName = \"ContextMenu\";\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport {\n createContext,\n type PropsWithChildren,\n type ReactElement,\n useContext,\n} from \"react\";\n\nimport { type Input } from \"@/input\";\nimport { type Text } from \"@/text\";\nimport { type ComponentSize } from \"@/util/component\";\n\ninterface MenuContextValue {\n onClick: (key: string) => void;\n selected: string;\n level?: Text.Level;\n iconSpacing?: ComponentSize;\n}\n\nexport const MenuContext = createContext<MenuContextValue>({\n onClick: () => {},\n selected: \"\",\n});\n\nexport interface MenuProps\n extends Partial<Input.Control<string>>,\n PropsWithChildren,\n Pick<MenuContextValue, \"level\" | \"iconSpacing\"> {}\n\nexport const useMenuContext = (): MenuContextValue => useContext(MenuContext);\n\n/**\n * Menu is a modular component that allows you to create a menu with a list of items.\n * It satisfies the InputControl string interface, so it's selected value can be\n * controlled.\n *\n * @param props - Props for the component. All unlisted props will be spread to the\n * underlying Space component acting as the root element.\n * @param props.onChange - Callback executed when the selected item changes.\n * @param props.value - The selected item.\n */\nexport const Menu = ({\n children,\n onChange,\n level,\n iconSpacing,\n value = \"\",\n}: MenuProps): ReactElement => {\n const handleClick: MenuProps[\"onChange\"] = (key) => onChange?.(key);\n return (\n <MenuContext.Provider\n value={{ onClick: handleClick, selected: value, level, iconSpacing }}\n >\n {children}\n </MenuContext.Provider>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type FunctionComponent, type ReactElement } from \"react\";\n\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { useMenuContext } from \"@/menu/Menu\";\n\nimport \"@/menu/Item.css\";\n\nconst menuItemFactory =\n <E extends Pick<Button.ButtonProps, \"className\" | \"onClick\">>(\n Base: FunctionComponent<E>,\n defaultProps?: Partial<E>,\n ): FunctionComponent<E & { itemKey: string }> =>\n // eslint-disable-next-line react/display-name\n (props): ReactElement => {\n const { itemKey, className, onClick, size, ...rest } = {\n ...defaultProps,\n ...props,\n };\n\n const { onClick: ctxOnClick, selected, level, iconSpacing } = useMenuContext();\n\n const handleClick: Button.ButtonProps[\"onClick\"] = (e) => {\n ctxOnClick(itemKey);\n onClick?.(e);\n };\n const _selected = selected === itemKey;\n return (\n // @ts-expect-error\n <Base\n level={level}\n {...rest}\n onClick={handleClick}\n variant=\"text\"\n className={CSS(CSS.B(\"menu-item\"), CSS.selected(_selected), className)}\n size={size ?? iconSpacing}\n />\n );\n };\n\nexport interface ItemProps extends Button.ButtonProps {\n itemKey: string;\n}\nexport const CoreItem = menuItemFactory(Button.Button, { noWrap: true });\n\nexport interface ItemIconProps extends Button.IconProps {\n itemKey: string;\n}\nconst ItemIcon = menuItemFactory(Button.Icon);\n\nconst ItemLink = menuItemFactory(Button.Link, { noWrap: true });\nexport interface MenuItemLinkProps extends Button.LinkProps {\n itemKey: string;\n}\n\ntype CoreItemType = typeof CoreItem;\n\nexport interface ItemType extends CoreItemType {\n Icon: typeof ItemIcon;\n Link: typeof ItemLink;\n}\n\n/**\n * Menu.Item renders a menu item.\n *\n * @param props - Props for the component. Identical props to those of Use except\n * for the ones listed below.\n * @param props.itemKey - The key of the item. This is used to identify the item and\n * is passed to the onChange callback of the Menu.\n */\nexport const Item = CoreItem as ItemType;\nItem.Icon = ItemIcon;\nItem.Link = ItemLink;\n"],"names":["box","xy","jsxs","jsx","Button.Button","Button.Icon","Button.Link"],"mappings":";;;;;AAsDA,MAAM,gBAAkC;AAAA,EACtC,SAAS;AAAA,EACT,MAAM,CAAC;AAAA,EACP,IAAI,GAAG;AACT;AAEO,MAAM,mBAAmB,IAAI,GAAG,WAAW,UAAU;AACrD,MAAM,iBAAiB,IAAI,GAAG,WAAW,QAAQ;AACxD,MAAM,yBAAyB,IAAI,GAAG,gBAAgB,WAAW;AAEjE,MAAM,aA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ACA;AAAA;AAAA,EAGF,CAAC,UAAwB;AACvB,UAAM,EAAE,SAAS,WAAW,SAAS,MAAM,GAAG,SAAS;AAAA,MACrD,GAAG;AAAA,MACH,GAAG;AAAA,IAAA;AAGL,UAAM,EAAE,SAAS,YAAY,UAAU,OAAO,YAAA,IAAgB;AAExD,UAAA,cAA6C,CAAC,MAAM;AACxD,iBAAW,OAAO;AAClB,yCAAU;AAAA,IAAC;AAEb,UAAM,YAAY,aAAa;AAC/B;AAAA;AAAA,MAEEA,kCAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACC,GAAG;AAAA,UACJ,SAAS;AAAA,UACT,SAAQ;AAAA,UACR,WAAW,IAAI,IAAI,EAAE,WAAW,GAAG,IAAI,SAAS,SAAS,GAAG,SAAS;AAAA,UACrE,MAAM,QAAQ;AAAA,QAAA;AAAA,MAChB;AAAA;AAAA,EAEJ;AAAA;AAKK,MAAM,WAAW,gBAAgBC,QAAe,EAAE,QAAQ,MAAM;AAKvE,MAAM,WAAW,gBAAgBC,IAAW;AAE5C,MAAM,WAAW,gBAAgBC,MAAa,EAAE,QAAQ,KAAM,CAAA;AAoBvD,MAAM,OAAO;AACpB,KAAK,OAAO;AACZ,KAAK,OAAO;"}
|
|
1
|
+
{"version":3,"file":"Item-kbCoFEj2.js","sources":["../src/menu/ContextMenu.tsx","../src/menu/Menu.tsx","../src/menu/Item.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport {\n type ComponentPropsWithoutRef,\n type ForwardedRef,\n forwardRef,\n type ReactElement,\n type RefCallback,\n useRef,\n useState,\n} from \"react\";\n\nimport { box, unique, xy } from \"@synnaxlabs/x\";\n\nimport { CSS } from \"@/css\";\nimport { useClickOutside } from \"@/hooks\";\nimport { type RenderProp } from \"@/util/renderProp\";\n\nimport \"@/menu/ContextMenu.css\";\n\ninterface ContextMenuState {\n visible: boolean;\n keys: string[];\n xy: xy.XY;\n}\n\n/** Supported event types for triggering a context menu. */\nexport type ContextMenuEvent = xy.Client & {\n preventDefault: () => void;\n stopPropagation: () => void;\n target: Element;\n};\n\n/** Opens the context menu. See {@link Menu.useContextMenu} for more details. */\nexport type ContextMenuOpen = (\n pos: xy.Crude | ContextMenuEvent,\n keys?: string[],\n) => void;\n\n/** Return value for the {@Menu.useContextMenu} hook. */\nexport interface UseContextMenuReturn extends ContextMenuState {\n visible: boolean;\n close: () => void;\n open: ContextMenuOpen;\n ref: RefCallback<HTMLDivElement>;\n}\n\nconst INITIAL_STATE: ContextMenuState = {\n visible: false,\n keys: [],\n xy: xy.ZERO,\n};\n\nexport const CONTEXT_SELECTED = CSS.BM(\"context\", \"selected\");\nexport const CONTEXT_TARGET = CSS.BE(\"context\", \"target\");\nconst CONTEXT_MENU_CONTAINER = CSS.BE(\"menu-context\", \"container\");\n\nconst findTarget = (target: HTMLElement): HTMLElement => {\n let candidate = target;\n while (candidate != null && !candidate.classList.contains(CONTEXT_TARGET)) {\n if (candidate.classList.contains(CONTEXT_MENU_CONTAINER)) return target;\n candidate = candidate.parentElement as HTMLElement;\n }\n return candidate;\n};\n\nconst findSelected = (target_: HTMLElement): HTMLElement[] => {\n const target = findTarget(target_);\n const selected = (target.parentElement?.querySelectorAll(`.${CONTEXT_SELECTED}`) ??\n []) as HTMLElement[];\n return [target, ...Array.from(selected)];\n};\n\n/**\n * Menu.useContextMenu extracts the logic for toggling a context menu, allowing\n * the caller to control the menu's visibility and position.\n *\n * @returns visible - Whether the menu is visible.\n * @returns close - A function to close the menu.\n * @returns open - A function to open the menu. The function accepts an XY coordinate and\n * an optional set of keys to set as the selected menu items. It's important to note\n * that these keys override the default behavior of the menu, which is explained in\n * the documentation for {@link Menu.ContextMenu}.\n */\nexport const useContextMenu = (): UseContextMenuReturn => {\n const menuRef = useRef<HTMLDivElement | null>(null);\n const [state, setMenuState] = useState<ContextMenuState>(INITIAL_STATE);\n\n const handleOpen: ContextMenuOpen = (e, keys) => {\n const p = xy.construct(e);\n if (\"preventDefault\" in e) {\n e.preventDefault();\n // Prevent parent context menus from opening.\n e.stopPropagation();\n keys = keys ?? unique(findSelected(e.target as HTMLElement).map((el) => el.id));\n } else keys = [];\n setMenuState({ visible: true, keys, xy: p });\n };\n\n const refCallback = (el: HTMLDivElement): void => {\n menuRef.current = el;\n if (el == null) return;\n setMenuState((prev) => {\n if (prev.visible) {\n const [repositioned, changed] = box.positionSoVisible(\n el,\n window.document.documentElement,\n );\n if (changed) return { ...prev, xy: box.topLeft(repositioned) };\n }\n return prev;\n });\n };\n\n const hideMenu = (): void => setMenuState(INITIAL_STATE);\n\n useClickOutside(menuRef, hideMenu);\n\n return {\n ...state,\n close: hideMenu,\n open: handleOpen,\n ref: refCallback,\n };\n};\n\nexport interface ContextMenuMenuProps {\n keys: string[];\n}\n\nexport interface ContextMenuProps\n extends UseContextMenuReturn,\n ComponentPropsWithoutRef<\"div\"> {\n menu?: RenderProp<ContextMenuMenuProps>;\n}\n\nconst ContextMenuCore = (\n {\n children,\n menu,\n visible,\n open,\n close,\n xy,\n keys,\n className,\n ...props\n }: ContextMenuProps,\n ref: ForwardedRef<HTMLDivElement>,\n): ReactElement => {\n const menuC = visible ? menu?.({ keys }) : null;\n\n return (\n <div\n className={CSS(CONTEXT_MENU_CONTAINER, className, CSS.inheritDims())}\n onContextMenu={open}\n {...props}\n >\n {children}\n {menuC != null && (\n <div\n className={CSS(CSS.B(\"menu-context\"), CSS.bordered())}\n ref={ref}\n style={{ left: xy.x, top: xy.y }}\n onClick={close}\n >\n {menuC}\n </div>\n )}\n </div>\n );\n};\n\n/**\n * Menu.ContextMenu wraps a set of children with a context menu. When the user right\n * clicks within wrapped area, the provided menu will be shown. Menu.ContextMenu should\n * be used in conjunction with the Menu.useContextMenu hook.\n *\n * The rendered menu is provided with a set of keys that represent the HTML IDs of the\n * context target elements. The first target is evaluated by traversing the parents\n * of the element that was right clicked until an element with the class \"pluto-context-target\"\n * is found. If no such element is found, the right clicked element itself is used as\n * the target. Subsequent targets are found by querying all siblings of the first target\n * that have the \"pluto-context-selected\" class.\n *\n * @example <caption>Example DOM structure</caption>\n * <div id=\"pluto-menu-context__container\">\n * <div className=\"pluto-context-target\" id=\"1\">\n * <span>\n * <h2>I was right clicked!</h2>\n * </span>\n * </div>\n * <div className=\"pluto-context-target pluto-context-selected\" id=\"2\">\n * <div className=\"pluto-context-target\" id=\"3\">\n * </div>\n *\n * In the above example, the keys provided to the menu would be [\"1\", \"2\"].\n *\n * The target resolution logic is ideal for both single and multi-select scenarios,\n * such as lists that have several selected rows that should be acted upon together.\n *\n * @param props - Props for the component. Expects all return values from the\n * useContextMenu hook. All non-hook and unlisted props will be spread to the\n * underlying div component acting as the root element.\n * @param props.menu - The menu to show when the user right clicks.\n */\nexport const ContextMenu = forwardRef(ContextMenuCore);\nContextMenu.displayName = \"ContextMenu\";\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport {\n createContext,\n type PropsWithChildren,\n type ReactElement,\n useContext,\n} from \"react\";\n\nimport { type Input } from \"@/input\";\nimport { type Text } from \"@/text\";\nimport { type ComponentSize } from \"@/util/component\";\n\ninterface MenuContextValue {\n onClick: (key: string) => void;\n selected: string;\n level?: Text.Level;\n iconSpacing?: ComponentSize;\n}\n\nexport const MenuContext = createContext<MenuContextValue>({\n onClick: () => {},\n selected: \"\",\n});\n\nexport interface MenuProps\n extends Partial<Input.Control<string>>,\n PropsWithChildren,\n Pick<MenuContextValue, \"level\" | \"iconSpacing\"> {}\n\nexport const useMenuContext = (): MenuContextValue => useContext(MenuContext);\n\n/**\n * Menu is a modular component that allows you to create a menu with a list of items.\n * It satisfies the InputControl string interface, so it's selected value can be\n * controlled.\n *\n * @param props - Props for the component. All unlisted props will be spread to the\n * underlying Space component acting as the root element.\n * @param props.onChange - Callback executed when the selected item changes.\n * @param props.value - The selected item.\n */\nexport const Menu = ({\n children,\n onChange,\n level,\n iconSpacing,\n value = \"\",\n}: MenuProps): ReactElement => {\n const handleClick: MenuProps[\"onChange\"] = (key) => onChange?.(key);\n return (\n <MenuContext.Provider\n value={{ onClick: handleClick, selected: value, level, iconSpacing }}\n >\n {children}\n </MenuContext.Provider>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type FunctionComponent, type ReactElement } from \"react\";\n\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { useMenuContext } from \"@/menu/Menu\";\n\nimport \"@/menu/Item.css\";\n\nconst menuItemFactory =\n <E extends Pick<Button.ButtonProps, \"className\" | \"onClick\">>(\n Base: FunctionComponent<E>,\n defaultProps?: Partial<E>,\n ): FunctionComponent<E & { itemKey: string }> =>\n // eslint-disable-next-line react/display-name\n (props): ReactElement => {\n const { itemKey, className, onClick, size, ...rest } = {\n ...defaultProps,\n ...props,\n };\n\n const { onClick: ctxOnClick, selected, level, iconSpacing } = useMenuContext();\n\n const handleClick: Button.ButtonProps[\"onClick\"] = (e) => {\n ctxOnClick(itemKey);\n onClick?.(e);\n };\n const _selected = selected === itemKey;\n return (\n // @ts-expect-error\n <Base\n level={level}\n {...rest}\n onClick={handleClick}\n variant=\"text\"\n className={CSS(CSS.B(\"menu-item\"), CSS.selected(_selected), className)}\n size={size ?? iconSpacing}\n />\n );\n };\n\nexport interface ItemProps extends Button.ButtonProps {\n itemKey: string;\n}\nexport const CoreItem = menuItemFactory(Button.Button, { noWrap: true });\n\nexport interface ItemIconProps extends Button.IconProps {\n itemKey: string;\n}\nconst ItemIcon = menuItemFactory(Button.Icon);\n\nconst ItemLink = menuItemFactory(Button.Link, { noWrap: true });\nexport interface MenuItemLinkProps extends Button.LinkProps {\n itemKey: string;\n}\n\ntype CoreItemType = typeof CoreItem;\n\nexport interface ItemType extends CoreItemType {\n Icon: typeof ItemIcon;\n Link: typeof ItemLink;\n}\n\n/**\n * Menu.Item renders a menu item.\n *\n * @param props - Props for the component. Identical props to those of Use except\n * for the ones listed below.\n * @param props.itemKey - The key of the item. This is used to identify the item and\n * is passed to the onChange callback of the Menu.\n */\nexport const Item = CoreItem as ItemType;\nItem.Icon = ItemIcon;\nItem.Link = ItemLink;\n"],"names":["INITIAL_STATE","xy","CONTEXT_SELECTED","CSS","CONTEXT_TARGET","CONTEXT_MENU_CONTAINER","findTarget","target","candidate","findSelected","target_","selected","_a","useContextMenu","menuRef","useRef","state","setMenuState","useState","handleOpen","keys","p","unique","el","refCallback","prev","repositioned","changed","box","hideMenu","useClickOutside","ContextMenuCore","children","menu","visible","open","close","className","props","ref","menuC","jsxs","jsx","ContextMenu","forwardRef","MenuContext","createContext","useMenuContext","useContext","Menu","onChange","level","iconSpacing","value","handleClick","key","menuItemFactory","Base","defaultProps","itemKey","onClick","size","rest","ctxOnClick","e","_selected","CoreItem","Button.Button","ItemIcon","Button.Icon","ItemLink","Button.Link","Item"],"mappings":";;;;;AAsDA,MAAMA,IAAkC;AAAA,EACtC,SAAS;AAAA,EACT,MAAM,CAAC;AAAA,EACP,IAAIC,EAAG;AACT,GAEaC,IAAmBC,EAAI,GAAG,WAAW,UAAU,GAC/CC,IAAiBD,EAAI,GAAG,WAAW,QAAQ,GAClDE,IAAyBF,EAAI,GAAG,gBAAgB,WAAW,GAE3DG,IAAa,CAACC,MAAqC;AACvD,MAAIC,IAAYD;AAChB,SAAOC,KAAa,QAAQ,CAACA,EAAU,UAAU,SAASJ,CAAc,KAAG;AACrE,QAAAI,EAAU,UAAU,SA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O,aAAAC,EAAY;AAAA,MAElE,UAAApB;AAAA,IAAA;AAAA,EAAA;AAGP,GC/CMwB,IACJ,CACEC,GACAC;AAAA;AAAA,EAGF,CAACpB,MAAwB;AACvB,UAAM,EAAE,SAAAqB,GAAS,WAAAtB,GAAW,SAAAuB,GAAS,MAAAC,GAAM,GAAGC,MAAS;AAAA,MACrD,GAAGJ;AAAA,MACH,GAAGpB;AAAA,IAAA,GAGC,EAAE,SAASyB,GAAY,UAAApD,GAAU,OAAAwC,GAAO,aAAAC,EAAA,IAAgBL,KAExDO,IAA6C,CAACU,MAAM;AACxD,MAAAD,EAAWJ,CAAO,GAClBC,KAAA,QAAAA,EAAUI;AAAA,IAAC,GAEPC,IAAYtD,MAAagD;AAC/B;AAAA;AAAA,MAEEjB,gBAAAA,EAAA;AAAA,QAACe;AAAA,QAAA;AAAA,UACC,OAAAN;AAAA,UACC,GAAGW;AAAA,UACJ,SAASR;AAAA,UACT,SAAQ;AAAA,UACR,WAAWnD,EAAIA,EAAI,EAAE,WAAW,GAAGA,EAAI,SAAS8D,CAAS,GAAG5B,CAAS;AAAA,UACrE,MAAMwB,KAAQT;AAAA,QAAA;AAAA,MAChB;AAAA;AAAA,EAEJ;AAAA,GAKWc,IAAWV,EAAgBW,GAAe,EAAE,QAAQ,IAAM,GAKjEC,IAAWZ,EAAgBa,CAAW,GAEtCC,IAAWd,EAAgBe,GAAa,EAAE,QAAQ,GAAM,CAAA,GAoBjDC,IAAON;AACpBM,EAAK,OAAOJ;AACZI,EAAK,OAAOF;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { j as t } from "./jsx-runtime-NmMXPjeo.js";
|
|
2
|
+
import { C as o } from "./css-5RvvUhjr.js";
|
|
3
|
+
import { g as a } from "./Toggle-HVxv8bv2.js";
|
|
4
|
+
const p = ({
|
|
5
|
+
className: r,
|
|
6
|
+
...s
|
|
7
|
+
}) => (
|
|
8
|
+
// @ts-expect-error
|
|
9
|
+
/* @__PURE__ */ t.jsx(a, { className: o(r, o.BM("text", "keyboard")), ...s })
|
|
10
|
+
);
|
|
11
|
+
export {
|
|
12
|
+
p as K
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=Keyboard-IWRXgioJ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Keyboard-
|
|
1
|
+
{"version":3,"file":"Keyboard-IWRXgioJ.js","sources":["../src/text/Keyboard.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { CSS } from \"@/css\";\nimport { type TextProps, Text } from \"@/text/Text\";\nimport { type Level } from \"@/text/types\";\n\nimport \"@/text/Keyboard.css\";\n\nexport type KeyboardProps<L extends Level = \"h1\"> = TextProps<L>;\n\nexport const Keyboard = <L extends Level = \"p\">({\n className,\n ...props\n}: KeyboardProps<L>): ReactElement => (\n // @ts-expect-error\n <Text<L> className={CSS(className, CSS.BM(\"text\", \"keyboard\"))} {...props} />\n);\n"],"names":["Keyboard","className","props","jsx","Text","CSS"],"mappings":";;;AAmBO,MAAMA,IAAW,CAAwB;AAAA,EAC9C,WAAAC;AAAA,EACA,GAAGC;AACL;AAAA;AAAA,EAEGC,gBAAAA,EAAAA,IAAAC,GAAA,EAAQ,WAAWC,EAAIJ,GAAWI,EAAI,GAAG,QAAQ,UAAU,CAAC,GAAI,GAAGH,EAAO,CAAA;AAAA;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const r=require("./jsx-runtime-evvPGacs.cjs"),e=require("./css-s9KpanYu.cjs"),o=require("./Toggle-QnKinMl4.cjs"),c=({className:s,...t})=>r.jsxRuntimeExports.jsx(o.Text,{className:e.CSS(s,e.CSS.BM("text","keyboard")),...t});exports.Keyboard=c;
|
|
2
|
+
//# sourceMappingURL=Keyboard-bXNOi0bP.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Keyboard-
|
|
1
|
+
{"version":3,"file":"Keyboard-bXNOi0bP.cjs","sources":["../src/text/Keyboard.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { CSS } from \"@/css\";\nimport { type TextProps, Text } from \"@/text/Text\";\nimport { type Level } from \"@/text/types\";\n\nimport \"@/text/Keyboard.css\";\n\nexport type KeyboardProps<L extends Level = \"h1\"> = TextProps<L>;\n\nexport const Keyboard = <L extends Level = \"p\">({\n className,\n ...props\n}: KeyboardProps<L>): ReactElement => (\n // @ts-expect-error\n <Text<L> className={CSS(className, CSS.BM(\"text\", \"keyboard\"))} {...props} />\n);\n"],"names":["Keyboard","className","props","jsx","Text","CSS"],"mappings":"8HAmBaA,EAAW,CAAwB,CAC9C,UAAAC,EACA,GAAGC,CACL,IAEGC,EAAAA,kBAAAA,IAAAC,EAAAA,KAAA,CAAQ,UAAWC,EAAAA,IAAIJ,EAAWI,EAAAA,IAAI,GAAG,OAAQ,UAAU,CAAC,EAAI,GAAGH,CAAO,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link-
|
|
1
|
+
{"version":3,"file":"Link-16dbGK7G.cjs","sources":["../src/button/Link.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { Button, type ButtonProps } from \"@/button/Button\";\nimport { type Text } from \"@/text\";\n\n/** Props for the {@link Link} component. */\nexport interface LinkProps<L extends Text.Level = \"h1\">\n extends ButtonProps,\n Pick<Text.LinkProps<L>, \"href\" | \"target\"> {}\n/**\n * Use.Link renders a button that looks like a link and redirects to the given href\n * when clicked.\n *\n * @param props - Props for the component. Identical to the props for the Use component,\n * excluding 'variant', and adding the following:\n * @param props.href - The URL to redirect to when the button is clicked.\n * @param props.target - The target of the link. Defaults to \"_self\".\n */\n\nexport const Link = <L extends Text.Level = \"h1\">({\n href,\n target,\n ...props\n}: LinkProps<L>): ReactElement => {\n // @ts-expect-error\n return <Button<\"a\"> el=\"a\" href={href} {...props} />;\n};\n"],"names":["Link","href","target","props","Button"],"mappings":"8FA4BaA,EAAO,CAA8B,CAChD,KAAAC,EACA,OAAAC,EACA,GAAGC,CACL,4BAEUC,EAAY,OAAA,CAAA,GAAG,IAAI,KAAAH,EAAa,GAAGE,CAAO,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { j as o } from "./jsx-runtime-NmMXPjeo.js";
|
|
2
|
+
import { B as s } from "./Toggle-HVxv8bv2.js";
|
|
3
|
+
const n = ({
|
|
4
|
+
href: t,
|
|
5
|
+
target: a,
|
|
6
|
+
...r
|
|
7
|
+
}) => /* @__PURE__ */ o.jsx(s, { el: "a", href: t, ...r });
|
|
8
|
+
export {
|
|
9
|
+
n as L
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=Link-fRQvqiYx.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link-
|
|
1
|
+
{"version":3,"file":"Link-fRQvqiYx.js","sources":["../src/button/Link.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { Button, type ButtonProps } from \"@/button/Button\";\nimport { type Text } from \"@/text\";\n\n/** Props for the {@link Link} component. */\nexport interface LinkProps<L extends Text.Level = \"h1\">\n extends ButtonProps,\n Pick<Text.LinkProps<L>, \"href\" | \"target\"> {}\n/**\n * Use.Link renders a button that looks like a link and redirects to the given href\n * when clicked.\n *\n * @param props - Props for the component. Identical to the props for the Use component,\n * excluding 'variant', and adding the following:\n * @param props.href - The URL to redirect to when the button is clicked.\n * @param props.target - The target of the link. Defaults to \"_self\".\n */\n\nexport const Link = <L extends Text.Level = \"h1\">({\n href,\n target,\n ...props\n}: LinkProps<L>): ReactElement => {\n // @ts-expect-error\n return <Button<\"a\"> el=\"a\" href={href} {...props} />;\n};\n"],"names":["Link","href","target","props","Button"],"mappings":";;AA4BO,MAAMA,IAAO,CAA8B;AAAA,EAChD,MAAAC;AAAA,EACA,QAAAC;AAAA,EACA,GAAGC;AACL,4BAEUC,GAAY,EAAA,IAAG,KAAI,MAAAH,GAAa,GAAGE,EAAO,CAAA;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const x=require("./jsx-runtime-evvPGacs.cjs"),p=require("./Toggle-QnKinMl4.cjs"),B=require("./Center-ER_owvfX.cjs"),j=require("react"),b=require("./css-s9KpanYu.cjs");require("./component-dgLAEMbt.cjs");const m=({data:t=[],value:e=[],allowMultiple:c=!0,allowNone:i=!0,replaceOnSingle:h=!1,onChange:o})=>{const u=j.useRef(null),S=p.useHeldRef({triggers:[["Shift"]],loose:!0}),k=j.useCallback(n=>{let r=[];const R=u.current;if(!c)r=e.includes(n)?[]:[n];else if(S.current.held&&R!==null){const[f,y]=[t.findIndex(l=>l.key===n),t.findIndex(l=>l.key===R)].sort((l,g)=>l-g),d=t.slice(f,y+1).map(({key:l})=>l);d.slice(1,d.length-1).every(l=>e.includes(l))&&e.includes(n)?r=e.filter(l=>!d.includes(l)):r=[...e,...d],u.current=null}else u.current=n,h?r=e.includes(n)&&e.length===1?[]:[n]:e.includes(n)?r=e.filter(f=>f!==n):r=[...e,n];const a=b.unique(r);!i&&a.length===0||(a.length===0&&(u.current=null),o(b.unique(r),{entries:t.filter(({key:f})=>r.includes(f)),clicked:n}))},[o,e,t,c]),s=j.useCallback(()=>o([],{entries:[],clicked:null}),[o]);return{onSelect:k,clear:s}},q=({children:t=E,value:e,onChange:c,entryRenderKey:i="key",allowNone:h=!1,allowMultiple:o=!1,data:u,...S})=>{const{onSelect:k}=m({allowMultiple:o,allowNone:h,data:u,value:[e],onChange:([s])=>c(s)});return x.jsxRuntimeExports.jsx(B.Pack,{...S,children:u.map(s=>t({key:s.key,onClick:()=>k(s.key),selected:s.key===e,entry:s,title:s[i]}))})},E=({key:t,onClick:e,selected:c,title:i})=>x.jsxRuntimeExports.jsx(p.Button,{onClick:e,variant:c?"filled":"outlined",children:i},t),L=[{key:"h2",label:"XL"},{key:"h3",label:"L"},{key:"h4",label:"M"},{key:"p",label:"S"},{key:"small",label:"XS"}],A=({key:t,entry:e,onClick:c,selected:i})=>x.jsxRuntimeExports.jsx(p.Button,{variant:i?"filled":"outlined",onClick:c,children:e.label},t),C=({children:t=A,...e})=>x.jsxRuntimeExports.jsx(q,{...e,data:L,children:t});exports.Button=q;exports.SelectLevel=C;exports.useSelectMultiple=m;
|
|
2
|
+
//# sourceMappingURL=SelectLevel-DrdlLBOs.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectLevel-bGb0dRXh.cjs","sources":["../src/hooks/useSelectMultiple.ts","../src/select/Button.tsx","../src/text/SelectLevel.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { useCallback, useRef } from \"react\";\n\nimport { type Key, type KeyedRecord, unique } from \"@synnaxlabs/x\";\n\nimport { Triggers } from \"@/triggers\";\n\n/**\n * Extra information passed as an additional argument to the `onChange` callback.\n * of the {@link useSelectMultiple} hook.\n */\nexport interface UseSelectMultipleOnChangeExtra<\n K extends Key = Key,\n E extends KeyedRecord<K, E> = KeyedRecord<K>,\n> {\n /** The key of the entry that was last clicked. */\n clicked: K | null;\n /** The entries that are currently selected. */\n entries: E[];\n}\n\n/** Props for the {@link useSelectMultiple} hook. */\nexport interface UseSelectMultipleProps<\n K extends Key = Key,\n E extends KeyedRecord<K, E> = KeyedRecord<K>,\n> {\n data: E[];\n allowMultiple?: boolean;\n allowNone?: boolean;\n replaceOnSingle?: boolean;\n value: K[];\n onChange: (next: K[], extra: UseSelectMultipleOnChangeExtra<K, E>) => void;\n}\n\n/** Return value for the {@link useSelectMultiple} hook. */\nexport interface UseSelectMultipleReturn<\n K extends Key = Key,\n E extends KeyedRecord<K, E> = KeyedRecord<K>,\n> {\n onSelect: (key: K) => void;\n clear: () => void;\n}\n\n/**\n * Implements generic multiple selection over a collection of keyed records. The hook\n * does not maintain internal selection state, but instead relies on the `value` and\n * `onChange` props to manage the selection state. This allows the hook to be used\n * with any selection state implementation, such as a React state hook or a Redux\n * store.\n *\n * The hook also supports shift-selection of a range. This means that the data passed in\n * must be in the same order/cardinality as the data that is displayed.\n *\n * It's important to note that the hook implements the InputControl interface, which\n * means that it can be used as a controlled input in a form.\n *\n * @param props - The props for the hook.\n * @param props.data - The data to select from.\n * @param props.value - The current selection state.\n * @param props.onChange - The callback to invoke when the selection state changes.\n * @param props.allowMultiple - Whether to allow multiple selections.\n *\n * @returns transform - A transform that can be used to add a `selected` property to\n * each record in the data.\n * @returns onSelect - A callback that can be used to select a record. This should\n * probably be passed to the `onClick` corresponding to each record.\n * @returns clear - A callback that can be used to clear the selection.\n */\nexport const useSelectMultiple = <\n K extends Key = Key,\n E extends KeyedRecord<K, E> = KeyedRecord<K>,\n>({\n data = [],\n value = [],\n allowMultiple = true,\n allowNone = true,\n replaceOnSingle = false,\n onChange,\n}: UseSelectMultipleProps<K, E>): UseSelectMultipleReturn<K, E> => {\n const shiftValueRef = useRef<K | null>(null);\n const shift = Triggers.useHeldRef({ triggers: [[\"Shift\"]], loose: true });\n\n const handleSelect = useCallback(\n (key: K): void => {\n let nextSelected: K[] = [];\n const shiftValue = shiftValueRef.current;\n if (!allowMultiple) {\n nextSelected = value.includes(key) ? [] : [key];\n } else if (shift.current.held && shiftValue !== null) {\n // We might select in reverse order, so we need to sort the indexes.\n const [start, end] = [\n data.findIndex((v) => v.key === key),\n data.findIndex((v) => v.key === shiftValue),\n ].sort((a, b) => a - b);\n const nextKeys = data.slice(start, end + 1).map(({ key }) => key);\n // We already deselect the shiftSelected key, so we don't included it\n // when checking whether to select or deselect the entire range.\n if (\n nextKeys.slice(1, nextKeys.length - 1).every((k) => value.includes(k)) &&\n value.includes(key)\n )\n nextSelected = value.filter((k) => !nextKeys.includes(k));\n else nextSelected = [...value, ...nextKeys];\n shiftValueRef.current = null;\n } else {\n shiftValueRef.current = key;\n if (replaceOnSingle)\n nextSelected = value.includes(key) && value.length === 1 ? [] : [key];\n else if (value.includes(key)) nextSelected = value.filter((k) => k !== key);\n else nextSelected = [...value, key];\n }\n const v = unique(nextSelected);\n if (!allowNone && v.length === 0) return;\n if (v.length === 0) shiftValueRef.current = null;\n onChange(unique(nextSelected), {\n entries: data.filter(({ key }) => nextSelected.includes(key)),\n clicked: key,\n });\n },\n [onChange, value, data, allowMultiple],\n );\n\n const clear = useCallback(\n (): void => onChange([], { entries: [], clicked: null }),\n [onChange],\n );\n\n return { onSelect: handleSelect, clear };\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Key, type KeyedRenderableRecord } from \"@synnaxlabs/x\";\n\nimport { Align } from \"@/align\";\nimport { Button as CoreButton } from \"@/button\";\nimport {\n type UseSelectMultipleProps,\n useSelectMultiple,\n} from \"@/hooks/useSelectMultiple\";\nimport { type Input } from \"@/input\";\nimport { type RenderProp } from \"@/util/renderProp\";\n\nexport interface ButtonOptionProps<\n K extends Key = Key,\n E extends KeyedRenderableRecord<K, E> = KeyedRenderableRecord<K>,\n> extends Pick<CoreButton.ButtonProps, \"onClick\"> {\n key: K;\n selected: boolean;\n entry: E;\n title: E[keyof E];\n}\n\nexport interface ButtonProps<\n K extends Key = Key,\n E extends KeyedRenderableRecord<K, E> = KeyedRenderableRecord<K>,\n> extends Input.Control<K>,\n Omit<Align.PackProps, \"children\" | \"onChange\">,\n Pick<UseSelectMultipleProps, \"allowNone\" | \"allowMultiple\"> {\n children?: RenderProp<ButtonOptionProps<K, E>>;\n entryRenderKey?: keyof E;\n data: E[];\n}\n\nexport const Button = <\n K extends Key = Key,\n E extends KeyedRenderableRecord<K, E> = KeyedRenderableRecord<K>,\n>({\n children = defaultSelectButtonOption,\n value,\n onChange,\n entryRenderKey = \"key\",\n allowNone = false,\n allowMultiple = false,\n data,\n ...props\n}: ButtonProps<K, E>): JSX.Element => {\n const { onSelect } = useSelectMultiple({\n allowMultiple,\n allowNone,\n data,\n value: [value],\n onChange: ([v]) => onChange(v),\n });\n\n return (\n <Align.Pack {...props}>\n {data.map((e) => {\n return children({\n key: e.key,\n onClick: () => onSelect(e.key),\n selected: e.key === value,\n entry: e,\n title: e[entryRenderKey],\n });\n })}\n </Align.Pack>\n );\n};\n\nconst defaultSelectButtonOption = <\n K extends Key = Key,\n E extends KeyedRenderableRecord<K, E> = KeyedRenderableRecord<K>,\n>({\n key,\n onClick,\n selected,\n title,\n}: ButtonOptionProps<K, E>): JSX.Element => {\n return (\n <CoreButton.Button\n key={key}\n onClick={onClick}\n variant={selected ? \"filled\" : \"outlined\"}\n >\n {title}\n </CoreButton.Button>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { Button as CoreButton } from \"@/button\";\nimport { Button, type ButtonOptionProps, type ButtonProps } from \"@/select/Button\";\nimport { type Level } from \"@/text/types\";\n\ninterface Entry {\n key: Level;\n label: string;\n}\n\nexport interface SelectLevelProps\n extends Omit<ButtonProps<Level, Entry>, \"data\" | \"entryRenderKey\"> {}\n\nconst DATA: Entry[] = [\n {\n key: \"h2\",\n label: \"XL\",\n },\n {\n key: \"h3\",\n label: \"L\",\n },\n {\n key: \"h4\",\n label: \"M\",\n },\n {\n key: \"p\",\n label: \"S\",\n },\n {\n key: \"small\",\n label: \"XS\",\n },\n];\n\nconst defaultSelectDirectionButton = ({\n key,\n entry,\n onClick,\n selected,\n}: ButtonOptionProps<Level, Entry>): ReactElement => {\n return (\n <CoreButton.Button\n key={key}\n variant={selected ? \"filled\" : \"outlined\"}\n onClick={onClick}\n >\n {entry.label}\n </CoreButton.Button>\n );\n};\n\nexport const SelectLevel = ({\n children = defaultSelectDirectionButton,\n ...props\n}: SelectLevelProps): ReactElement => {\n return (\n <Button {...props} data={DATA}>\n {children}\n </Button>\n );\n};\n"],"names":["useRef","Triggers.useHeldRef","useCallback","v","key","unique","jsx","Align.Pack","CoreButton.Button"],"mappings":";;;;;;;AA4EO,MAAM,oBAAoB,CAG/B;AAAA,EACA,OAAO,CAAC;AAAA,EACR,QAAQ,CAAC;AAAA,EACT,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB;AACF,MAAmE;AAC3D,QAAA,gBAAgBA,aAAiB,IAAI;AAC3C,QAAM,QAAQC,kBAAoB,EAAE,UAAU,CAAC,CAAC,OAAO,CAAC,GAAG,OAAO,KAAA,CAAM;AAExE,QAAM,eAAeC,MAAA;AAAA,IACnB,CAAC,QAAiB;AAChB,UAA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AAAA,EACT;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,EACT;AACF;AAEA,MAAM,+BAA+B,CAAC;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAqD;AAEjD,SAAAF,2BAAA,kBAAA;AAAA,IAACE,OAAW;AAAA,IAAX;AAAA,MAEC,SAAS,WAAW,WAAW;AAAA,MAC/B;AAAA,MAEC,UAAM,MAAA;AAAA,IAAA;AAAA,IAJF;AAAA,EAAA;AAOX;AAEO,MAAM,cAAc,CAAC;AAAA,EAC1B,WAAW;AAAA,EACX,GAAG;AACL,MAAsC;AACpC,0DACG,QAAQ,EAAA,GAAG,OAAO,MAAM,MACtB,SACH,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"SelectLevel-DrdlLBOs.cjs","sources":["../src/hooks/useSelectMultiple.ts","../src/select/Button.tsx","../src/text/SelectLevel.tsx"],"sourcesContent":["// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { useCallback, useRef } from \"react\";\n\nimport { type Key, type KeyedRecord, unique } from \"@synnaxlabs/x\";\n\nimport { Triggers } from \"@/triggers\";\n\n/**\n * Extra information passed as an additional argument to the `onChange` callback.\n * of the {@link useSelectMultiple} hook.\n */\nexport interface UseSelectMultipleOnChangeExtra<\n K extends Key = Key,\n E extends KeyedRecord<K, E> = KeyedRecord<K>,\n> {\n /** The key of the entry that was last clicked. */\n clicked: K | null;\n /** The entries that are currently selected. */\n entries: E[];\n}\n\n/** Props for the {@link useSelectMultiple} hook. */\nexport interface UseSelectMultipleProps<\n K extends Key = Key,\n E extends KeyedRecord<K, E> = KeyedRecord<K>,\n> {\n data: E[];\n allowMultiple?: boolean;\n allowNone?: boolean;\n replaceOnSingle?: boolean;\n value: K[];\n onChange: (next: K[], extra: UseSelectMultipleOnChangeExtra<K, E>) => void;\n}\n\n/** Return value for the {@link useSelectMultiple} hook. */\nexport interface UseSelectMultipleReturn<\n K extends Key = Key,\n E extends KeyedRecord<K, E> = KeyedRecord<K>,\n> {\n onSelect: (key: K) => void;\n clear: () => void;\n}\n\n/**\n * Implements generic multiple selection over a collection of keyed records. The hook\n * does not maintain internal selection state, but instead relies on the `value` and\n * `onChange` props to manage the selection state. This allows the hook to be used\n * with any selection state implementation, such as a React state hook or a Redux\n * store.\n *\n * The hook also supports shift-selection of a range. This means that the data passed in\n * must be in the same order/cardinality as the data that is displayed.\n *\n * It's important to note that the hook implements the InputControl interface, which\n * means that it can be used as a controlled input in a form.\n *\n * @param props - The props for the hook.\n * @param props.data - The data to select from.\n * @param props.value - The current selection state.\n * @param props.onChange - The callback to invoke when the selection state changes.\n * @param props.allowMultiple - Whether to allow multiple selections.\n *\n * @returns transform - A transform that can be used to add a `selected` property to\n * each record in the data.\n * @returns onSelect - A callback that can be used to select a record. This should\n * probably be passed to the `onClick` corresponding to each record.\n * @returns clear - A callback that can be used to clear the selection.\n */\nexport const useSelectMultiple = <\n K extends Key = Key,\n E extends KeyedRecord<K, E> = KeyedRecord<K>,\n>({\n data = [],\n value = [],\n allowMultiple = true,\n allowNone = true,\n replaceOnSingle = false,\n onChange,\n}: UseSelectMultipleProps<K, E>): UseSelectMultipleReturn<K, E> => {\n const shiftValueRef = useRef<K | null>(null);\n const shift = Triggers.useHeldRef({ triggers: [[\"Shift\"]], loose: true });\n\n const handleSelect = useCallback(\n (key: K): void => {\n let nextSelected: K[] = [];\n const shiftValue = shiftValueRef.current;\n if (!allowMultiple) {\n nextSelected = value.includes(key) ? [] : [key];\n } else if (shift.current.held && shiftValue !== null) {\n // We might select in reverse order, so we need to sort the indexes.\n const [start, end] = [\n data.findIndex((v) => v.key === key),\n data.findIndex((v) => v.key === shiftValue),\n ].sort((a, b) => a - b);\n const nextKeys = data.slice(start, end + 1).map(({ key }) => key);\n // We already deselect the shiftSelected key, so we don't included it\n // when checking whether to select or deselect the entire range.\n if (\n nextKeys.slice(1, nextKeys.length - 1).every((k) => value.includes(k)) &&\n value.includes(key)\n )\n nextSelected = value.filter((k) => !nextKeys.includes(k));\n else nextSelected = [...value, ...nextKeys];\n shiftValueRef.current = null;\n } else {\n shiftValueRef.current = key;\n if (replaceOnSingle)\n nextSelected = value.includes(key) && value.length === 1 ? [] : [key];\n else if (value.includes(key)) nextSelected = value.filter((k) => k !== key);\n else nextSelected = [...value, key];\n }\n const v = unique(nextSelected);\n if (!allowNone && v.length === 0) return;\n if (v.length === 0) shiftValueRef.current = null;\n onChange(unique(nextSelected), {\n entries: data.filter(({ key }) => nextSelected.includes(key)),\n clicked: key,\n });\n },\n [onChange, value, data, allowMultiple],\n );\n\n const clear = useCallback(\n (): void => onChange([], { entries: [], clicked: null }),\n [onChange],\n );\n\n return { onSelect: handleSelect, clear };\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type Key, type KeyedRenderableRecord } from \"@synnaxlabs/x\";\n\nimport { Align } from \"@/align\";\nimport { Button as CoreButton } from \"@/button\";\nimport {\n type UseSelectMultipleProps,\n useSelectMultiple,\n} from \"@/hooks/useSelectMultiple\";\nimport { type Input } from \"@/input\";\nimport { type RenderProp } from \"@/util/renderProp\";\n\nexport interface ButtonOptionProps<\n K extends Key = Key,\n E extends KeyedRenderableRecord<K, E> = KeyedRenderableRecord<K>,\n> extends Pick<CoreButton.ButtonProps, \"onClick\"> {\n key: K;\n selected: boolean;\n entry: E;\n title: E[keyof E];\n}\n\nexport interface ButtonProps<\n K extends Key = Key,\n E extends KeyedRenderableRecord<K, E> = KeyedRenderableRecord<K>,\n> extends Input.Control<K>,\n Omit<Align.PackProps, \"children\" | \"onChange\">,\n Pick<UseSelectMultipleProps, \"allowNone\" | \"allowMultiple\"> {\n children?: RenderProp<ButtonOptionProps<K, E>>;\n entryRenderKey?: keyof E;\n data: E[];\n}\n\nexport const Button = <\n K extends Key = Key,\n E extends KeyedRenderableRecord<K, E> = KeyedRenderableRecord<K>,\n>({\n children = defaultSelectButtonOption,\n value,\n onChange,\n entryRenderKey = \"key\",\n allowNone = false,\n allowMultiple = false,\n data,\n ...props\n}: ButtonProps<K, E>): JSX.Element => {\n const { onSelect } = useSelectMultiple({\n allowMultiple,\n allowNone,\n data,\n value: [value],\n onChange: ([v]) => onChange(v),\n });\n\n return (\n <Align.Pack {...props}>\n {data.map((e) => {\n return children({\n key: e.key,\n onClick: () => onSelect(e.key),\n selected: e.key === value,\n entry: e,\n title: e[entryRenderKey],\n });\n })}\n </Align.Pack>\n );\n};\n\nconst defaultSelectButtonOption = <\n K extends Key = Key,\n E extends KeyedRenderableRecord<K, E> = KeyedRenderableRecord<K>,\n>({\n key,\n onClick,\n selected,\n title,\n}: ButtonOptionProps<K, E>): JSX.Element => {\n return (\n <CoreButton.Button\n key={key}\n onClick={onClick}\n variant={selected ? \"filled\" : \"outlined\"}\n >\n {title}\n </CoreButton.Button>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { Button as CoreButton } from \"@/button\";\nimport { Button, type ButtonOptionProps, type ButtonProps } from \"@/select/Button\";\nimport { type Level } from \"@/text/types\";\n\ninterface Entry {\n key: Level;\n label: string;\n}\n\nexport interface SelectLevelProps\n extends Omit<ButtonProps<Level, Entry>, \"data\" | \"entryRenderKey\"> {}\n\nconst DATA: Entry[] = [\n {\n key: \"h2\",\n label: \"XL\",\n },\n {\n key: \"h3\",\n label: \"L\",\n },\n {\n key: \"h4\",\n label: \"M\",\n },\n {\n key: \"p\",\n label: \"S\",\n },\n {\n key: \"small\",\n label: \"XS\",\n },\n];\n\nconst defaultSelectDirectionButton = ({\n key,\n entry,\n onClick,\n selected,\n}: ButtonOptionProps<Level, Entry>): ReactElement => {\n return (\n <CoreButton.Button\n key={key}\n variant={selected ? \"filled\" : \"outlined\"}\n onClick={onClick}\n >\n {entry.label}\n </CoreButton.Button>\n );\n};\n\nexport const SelectLevel = ({\n children = defaultSelectDirectionButton,\n ...props\n}: SelectLevelProps): ReactElement => {\n return (\n <Button {...props} data={DATA}>\n {children}\n </Button>\n );\n};\n"],"names":["useSelectMultiple","data","value","allowMultiple","allowNone","replaceOnSingle","onChange","shiftValueRef","useRef","shift","Triggers.useHeldRef","handleSelect","useCallback","key","nextSelected","shiftValue","start","end","v","a","b","nextKeys","k","unique","clear","Button","children","defaultSelectButtonOption","entryRenderKey","props","onSelect","jsx","Align.Pack","e","onClick","selected","title","CoreButton.Button","DATA","defaultSelectDirectionButton","entry","SelectLevel"],"mappings":"wNA4EO,MAAMA,EAAoB,CAG/B,CACA,KAAAC,EAAO,CAAC,EACR,MAAAC,EAAQ,CAAC,EACT,cAAAC,EAAgB,GAChB,UAAAC,EAAY,GACZ,gBAAAC,EAAkB,GAClB,SAAAC,CACF,IAAmE,CAC3D,MAAAC,EAAgBC,SAAiB,IAAI,EACrCC,EAAQC,aAAoB,CAAE,SAAU,CAAC,CAAC,OAAO,CAAC,EAAG,MAAO,EAAA,CAAM,EAElEC,EAAeC,EAAA,YAClBC,GAAiB,CAChB,IAAIC,EAAoB,CAAA,EACxB,MAAMC,EAAaR,EAAc,QACjC,GAAI,CAACJ,EACHW,EAAeZ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KAAA,EAJF3B,CAAA,EASE4B,EAAc,CAAC,CAC1B,SAAAf,EAAWa,EACX,GAAGV,CACL,4BAEKJ,EAAQ,CAAA,GAAGI,EAAO,KAAMS,EACtB,SAAAZ,CACH,CAAA"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { j as m } from "./jsx-runtime-NmMXPjeo.js";
|
|
2
|
+
import { a7 as g, B as y } from "./Toggle-HVxv8bv2.js";
|
|
3
|
+
import { P as R } from "./Center-8mBjm1cO.js";
|
|
4
|
+
import { useRef as L, useCallback as k } from "react";
|
|
5
|
+
import { u as b } from "./css-5RvvUhjr.js";
|
|
6
|
+
import "./component-LA8IXGSG.js";
|
|
7
|
+
const A = ({
|
|
8
|
+
data: t = [],
|
|
9
|
+
value: e = [],
|
|
10
|
+
allowMultiple: i = !0,
|
|
11
|
+
allowNone: c = !0,
|
|
12
|
+
replaceOnSingle: a = !1,
|
|
13
|
+
onChange: u
|
|
14
|
+
}) => {
|
|
15
|
+
const o = L(null), h = g({ triggers: [["Shift"]], loose: !0 }), p = k(
|
|
16
|
+
(l) => {
|
|
17
|
+
let r = [];
|
|
18
|
+
const S = o.current;
|
|
19
|
+
if (!i)
|
|
20
|
+
r = e.includes(l) ? [] : [l];
|
|
21
|
+
else if (h.current.held && S !== null) {
|
|
22
|
+
const [f, j] = [
|
|
23
|
+
t.findIndex((n) => n.key === l),
|
|
24
|
+
t.findIndex((n) => n.key === S)
|
|
25
|
+
].sort((n, B) => n - B), d = t.slice(f, j + 1).map(({ key: n }) => n);
|
|
26
|
+
d.slice(1, d.length - 1).every((n) => e.includes(n)) && e.includes(l) ? r = e.filter((n) => !d.includes(n)) : r = [...e, ...d], o.current = null;
|
|
27
|
+
} else
|
|
28
|
+
o.current = l, a ? r = e.includes(l) && e.length === 1 ? [] : [l] : e.includes(l) ? r = e.filter((f) => f !== l) : r = [...e, l];
|
|
29
|
+
const x = b(r);
|
|
30
|
+
!c && x.length === 0 || (x.length === 0 && (o.current = null), u(b(r), {
|
|
31
|
+
entries: t.filter(({ key: f }) => r.includes(f)),
|
|
32
|
+
clicked: l
|
|
33
|
+
}));
|
|
34
|
+
},
|
|
35
|
+
[u, e, t, i]
|
|
36
|
+
), s = k(
|
|
37
|
+
() => u([], { entries: [], clicked: null }),
|
|
38
|
+
[u]
|
|
39
|
+
);
|
|
40
|
+
return { onSelect: p, clear: s };
|
|
41
|
+
}, D = ({
|
|
42
|
+
children: t = I,
|
|
43
|
+
value: e,
|
|
44
|
+
onChange: i,
|
|
45
|
+
entryRenderKey: c = "key",
|
|
46
|
+
allowNone: a = !1,
|
|
47
|
+
allowMultiple: u = !1,
|
|
48
|
+
data: o,
|
|
49
|
+
...h
|
|
50
|
+
}) => {
|
|
51
|
+
const { onSelect: p } = A({
|
|
52
|
+
allowMultiple: u,
|
|
53
|
+
allowNone: a,
|
|
54
|
+
data: o,
|
|
55
|
+
value: [e],
|
|
56
|
+
onChange: ([s]) => i(s)
|
|
57
|
+
});
|
|
58
|
+
return /* @__PURE__ */ m.jsx(R, { ...h, children: o.map((s) => t({
|
|
59
|
+
key: s.key,
|
|
60
|
+
onClick: () => p(s.key),
|
|
61
|
+
selected: s.key === e,
|
|
62
|
+
entry: s,
|
|
63
|
+
title: s[c]
|
|
64
|
+
})) });
|
|
65
|
+
}, I = ({
|
|
66
|
+
key: t,
|
|
67
|
+
onClick: e,
|
|
68
|
+
selected: i,
|
|
69
|
+
title: c
|
|
70
|
+
}) => /* @__PURE__ */ m.jsx(
|
|
71
|
+
y,
|
|
72
|
+
{
|
|
73
|
+
onClick: e,
|
|
74
|
+
variant: i ? "filled" : "outlined",
|
|
75
|
+
children: c
|
|
76
|
+
},
|
|
77
|
+
t
|
|
78
|
+
), P = [
|
|
79
|
+
{
|
|
80
|
+
key: "h2",
|
|
81
|
+
label: "XL"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
key: "h3",
|
|
85
|
+
label: "L"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
key: "h4",
|
|
89
|
+
label: "M"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
key: "p",
|
|
93
|
+
label: "S"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
key: "small",
|
|
97
|
+
label: "XS"
|
|
98
|
+
}
|
|
99
|
+
], V = ({
|
|
100
|
+
key: t,
|
|
101
|
+
entry: e,
|
|
102
|
+
onClick: i,
|
|
103
|
+
selected: c
|
|
104
|
+
}) => /* @__PURE__ */ m.jsx(
|
|
105
|
+
y,
|
|
106
|
+
{
|
|
107
|
+
variant: c ? "filled" : "outlined",
|
|
108
|
+
onClick: i,
|
|
109
|
+
children: e.label
|
|
110
|
+
},
|
|
111
|
+
t
|
|
112
|
+
), O = ({
|
|
113
|
+
children: t = V,
|
|
114
|
+
...e
|
|
115
|
+
}) => /* @__PURE__ */ m.jsx(D, { ...e, data: P, children: t });
|
|
116
|
+
export {
|
|
117
|
+
D as B,
|
|
118
|
+
O as S,
|
|
119
|
+
A as u
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=SelectLevel-Uod3Ez6y.js.map
|