@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
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { j as u } from "./jsx-runtime-NmMXPjeo.js";
|
|
2
|
+
import { forwardRef as p, createElement as E } from "react";
|
|
3
|
+
import { h as M, C as t } from "./css-5RvvUhjr.js";
|
|
4
|
+
const k = ({ el: e, children: a, ...s }, r) => E(e, { ...s, ref: r }, a), x = p(k), O = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5
|
+
__proto__: null,
|
|
6
|
+
Element: x
|
|
7
|
+
}, Symbol.toStringTag, { value: "Module" })), R = ["start", "center", "end", "stretch"], _ = [
|
|
8
|
+
"start",
|
|
9
|
+
"center",
|
|
10
|
+
"end",
|
|
11
|
+
"spaceBetween",
|
|
12
|
+
"spaceAround",
|
|
13
|
+
"spaceEvenly"
|
|
14
|
+
], g = (e, a) => a ?? (e === "right" || e === "bottom"), S = ({
|
|
15
|
+
style: e,
|
|
16
|
+
align: a,
|
|
17
|
+
className: s,
|
|
18
|
+
grow: r,
|
|
19
|
+
shrink: c,
|
|
20
|
+
empty: l = !1,
|
|
21
|
+
size: n = "medium",
|
|
22
|
+
justify: f = "start",
|
|
23
|
+
reverse: o,
|
|
24
|
+
direction: d = "y",
|
|
25
|
+
wrap: C = !1,
|
|
26
|
+
bordered: j = !1,
|
|
27
|
+
rounded: B = !1,
|
|
28
|
+
el: N = "div",
|
|
29
|
+
...w
|
|
30
|
+
}, y) => {
|
|
31
|
+
const i = M.construct(d);
|
|
32
|
+
o = g(d, o);
|
|
33
|
+
let m;
|
|
34
|
+
return l ? [n, m] = [0, 0] : typeof n == "number" && (m = `${n}rem`), e = {
|
|
35
|
+
gap: m,
|
|
36
|
+
flexDirection: h(i, o),
|
|
37
|
+
justifyContent: v[f],
|
|
38
|
+
alignItems: a,
|
|
39
|
+
flexWrap: C ? "wrap" : "nowrap",
|
|
40
|
+
...e
|
|
41
|
+
}, r != null && (e.flexGrow = Number(r)), c != null && (e.flexShrink = Number(c)), // @ts-expect-error
|
|
42
|
+
/* @__PURE__ */ u.jsx(
|
|
43
|
+
x,
|
|
44
|
+
{
|
|
45
|
+
el: N,
|
|
46
|
+
ref: y,
|
|
47
|
+
className: t(
|
|
48
|
+
t.B("space"),
|
|
49
|
+
t.dir(i),
|
|
50
|
+
t.bordered(j),
|
|
51
|
+
t.rounded(B),
|
|
52
|
+
typeof n == "string" && t.BM("space", n),
|
|
53
|
+
s
|
|
54
|
+
),
|
|
55
|
+
style: e,
|
|
56
|
+
...w
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
S.displayName = "Space";
|
|
61
|
+
const b = p(S), h = (e, a) => {
|
|
62
|
+
const s = e === "x" ? "row" : "column";
|
|
63
|
+
return a ? s + "-reverse" : s;
|
|
64
|
+
}, v = {
|
|
65
|
+
start: "flex-start",
|
|
66
|
+
center: "center",
|
|
67
|
+
end: "flex-end",
|
|
68
|
+
spaceBetween: "space-between",
|
|
69
|
+
spaceAround: "space-around",
|
|
70
|
+
spaceEvenly: "space-evenly"
|
|
71
|
+
}, A = ({
|
|
72
|
+
className: e,
|
|
73
|
+
size: a = "medium",
|
|
74
|
+
reverse: s = !1,
|
|
75
|
+
direction: r = "x",
|
|
76
|
+
bordered: c = !0,
|
|
77
|
+
rounded: l = !0,
|
|
78
|
+
shadow: n = !1,
|
|
79
|
+
...f
|
|
80
|
+
}, o) => (
|
|
81
|
+
// @ts-expect-error
|
|
82
|
+
/* @__PURE__ */ u.jsx(
|
|
83
|
+
b,
|
|
84
|
+
{
|
|
85
|
+
ref: o,
|
|
86
|
+
direction: r,
|
|
87
|
+
reverse: s,
|
|
88
|
+
className: t(
|
|
89
|
+
t.B("pack"),
|
|
90
|
+
n && t.BM("pack", "shadow"),
|
|
91
|
+
t.dir(r),
|
|
92
|
+
typeof a != "number" && t.BM("pack", a),
|
|
93
|
+
s && t.BM("pack", "reverse"),
|
|
94
|
+
e
|
|
95
|
+
),
|
|
96
|
+
bordered: c,
|
|
97
|
+
rounded: l,
|
|
98
|
+
...f,
|
|
99
|
+
empty: !0
|
|
100
|
+
}
|
|
101
|
+
)
|
|
102
|
+
), D = p(A), I = ({ className: e, justify: a = "center", align: s = "center", ...r }, c) => (
|
|
103
|
+
// @ts-expect-error
|
|
104
|
+
/* @__PURE__ */ u.jsx(
|
|
105
|
+
b,
|
|
106
|
+
{
|
|
107
|
+
ref: c,
|
|
108
|
+
justify: a,
|
|
109
|
+
align: s,
|
|
110
|
+
className: t(t.BM("space", "centered"), e),
|
|
111
|
+
...r
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
), J = p(I);
|
|
115
|
+
export {
|
|
116
|
+
R as A,
|
|
117
|
+
J as C,
|
|
118
|
+
x as E,
|
|
119
|
+
O as G,
|
|
120
|
+
_ as J,
|
|
121
|
+
D as P,
|
|
122
|
+
b as S,
|
|
123
|
+
I as a,
|
|
124
|
+
g as s
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=Center-8mBjm1cO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Center-gEKkAkdh.js","sources":["../src/generic/Generic.tsx","../src/align/Space.tsx","../src/align/Pack.tsx","../src/align/Center.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 ComponentPropsWithRef,\n createElement,\n type ForwardedRef,\n forwardRef,\n type ReactElement,\n} from \"react\";\n\nexport type JSXElementType = keyof JSX.IntrinsicElements;\n\nconst CoreElement = <E extends JSXElementType>(\n { el, children, ...props }: ElementProps<E>,\n ref: ForwardedRef<JSX.IntrinsicElements[E]>,\n): ReactElement => createElement(el, { ...props, ref }, children);\n\nexport type ElementProps<E extends JSXElementType> = ComponentPropsWithRef<E> & {\n el: E;\n};\n\n/**\n * Generic renders a component with the given element type .\n *\n * @param props - Props for the generic component. All props not defined below are passed to\n * the underlying element.\n * @param props.el - The element type to render.\n */\nexport const Element = forwardRef(CoreElement) as <E extends JSXElementType>(\n props: ElementProps<E>,\n) => ReactElement;\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 type CSSProperties,\n type ForwardedRef,\n type ReactElement,\n forwardRef,\n} from \"react\";\n\nimport { direction } from \"@synnaxlabs/x\";\n\nimport { CSS } from \"@/css\";\nimport { Generic } from \"@/generic\";\nimport { type ComponentSize } from \"@/util/component\";\n\nimport \"@/align/Space.css\";\n\n/** All possible alignments for the cross axis of a space */\nexport const ALIGNMENTS = [\"start\", \"center\", \"end\", \"stretch\"] as const;\n\n/** The alignments for the cross axis of a space */\nexport type Alignment = (typeof ALIGNMENTS)[number];\n\n/** All possible justifications for the main axis of a space */\nexport const JUSTIFICATIONS = [\n \"start\",\n \"center\",\n \"end\",\n \"spaceBetween\",\n \"spaceAround\",\n \"spaceEvenly\",\n] as const;\n\n/** The justification for the main axis of a space */\nexport type Justification = (typeof JUSTIFICATIONS)[number];\n\nexport type SpaceElementType =\n | \"div\"\n | \"header\"\n | \"nav\"\n | \"section\"\n | \"article\"\n | \"aside\"\n | \"footer\"\n | \"button\"\n | \"dialog\"\n | \"a\";\n\nexport interface SpaceExtensionProps {\n empty?: boolean;\n size?: ComponentSize | number;\n direction?: direction.Crude;\n reverse?: boolean;\n justify?: Justification;\n align?: Alignment;\n grow?: boolean | number;\n shrink?: boolean | number;\n wrap?: boolean;\n el?: SpaceElementType;\n bordered?: boolean;\n rounded?: boolean;\n}\n\nexport type SpaceProps<E extends SpaceElementType = \"div\"> = Omit<\n Generic.ElementProps<E>,\n \"el\"\n> &\n SpaceExtensionProps;\n\nexport const shouldReverse = (direction: direction.Crude, reverse?: boolean): boolean =>\n reverse ?? (direction === \"right\" || direction === \"bottom\");\n\nconst CoreSpace = <E extends SpaceElementType>(\n {\n style,\n align,\n className,\n grow,\n shrink,\n empty = false,\n size = \"medium\",\n justify = \"start\",\n reverse,\n direction: direction_ = \"y\",\n wrap = false,\n bordered = false,\n rounded = false,\n el = \"div\",\n ...props\n }: SpaceProps<E>,\n ref: ForwardedRef<JSX.IntrinsicElements[E]>,\n): ReactElement => {\n const dir = direction.construct(direction_);\n reverse = shouldReverse(direction_, reverse);\n\n let gap: number | string | undefined;\n if (empty) [size, gap] = [0, 0];\n else if (typeof size === \"number\") gap = `${size}rem`;\n\n style = {\n gap,\n flexDirection: flexDirection(dir, reverse),\n justifyContent: justifications[justify],\n alignItems: align,\n flexWrap: wrap ? \"wrap\" : \"nowrap\",\n ...style,\n };\n\n if (grow != null) style.flexGrow = Number(grow);\n if (shrink != null) style.flexShrink = Number(shrink);\n\n return (\n // @ts-expect-error\n <Generic.Element<E>\n el={el}\n ref={ref}\n className={CSS(\n CSS.B(\"space\"),\n CSS.dir(dir),\n CSS.bordered(bordered),\n CSS.rounded(rounded),\n typeof size === \"string\" && CSS.BM(\"space\", size),\n className,\n )}\n style={style}\n {...props}\n />\n );\n};\nCoreSpace.displayName = \"Space\";\n\n/**\n * A component that orients its children in a row or column and adds\n * space between them. This is essentially a thin wrapped around a\n * flex component that makes it more 'reacty' to use.\n *\n * @param props - The props for the component. All unlisted props will be passed\n * to the underlying root element.\n * @param props.align - The off axis alignment of the children. The 'off' axis is the\n * opposite direction of props.direction. For example, if direction is 'x', then the\n * off axis is 'y'. See the {@link Alignment} for available options.\n * @param props.justify - The main axis justification of the children. The 'main' axis\n * is the same direction as props.direction. For example, if direction is 'x', then the\n * main axis is 'x'. See the {@link Justification} for available options.\n * @param props.grow - A boolean or number value that determines if the space should\n * grow in the flex-box sense. A value of true will set css flex-grow to 1. A value of\n * false will leave the css flex-grow unset. A number value will set the css flex-grow\n * to that number.\n * @param props.size - A string or number value that determines the amount of spacing\n * between items. If set to \"small\", \"medium\", or \"large\", the spacing will be determined\n * by the theme. If set to a number, the spacing will be that number of rem.\n * @param props.wrap - A boolean value that determines if the space should wrap its\n * children.\n * @param props.el - The element type to render as. Defaults to 'div'.\n */\nexport const Space = forwardRef(CoreSpace) as <E extends SpaceElementType = \"div\">(\n props: SpaceProps<E>,\n) => ReactElement;\n\ntype FlexDirection = CSSProperties[\"flexDirection\"];\n\nconst flexDirection = (\n direction: direction.Direction,\n reverse: boolean,\n): FlexDirection => {\n const base = direction === \"x\" ? \"row\" : \"column\";\n return reverse ? ((base + \"-reverse\") as FlexDirection) : base;\n};\n\nconst justifications: Record<Justification, CSSProperties[\"justifyContent\"]> = {\n start: \"flex-start\",\n center: \"center\",\n end: \"flex-end\",\n spaceBetween: \"space-between\",\n spaceAround: \"space-around\",\n spaceEvenly: \"space-evenly\",\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 ForwardedRef, type ReactElement, forwardRef } from \"react\";\n\nimport { Space, type SpaceElementType, type SpaceProps } from \"@/align/Space\";\nimport { CSS } from \"@/css\";\n\nimport \"@/align/Pack.css\";\n\n/** Props for the {@link Pack} component. */\nexport type PackProps<E extends SpaceElementType = \"div\"> = Omit<\n SpaceProps<E>,\n \"empty\"\n> & {\n shadow?: boolean;\n};\n\nconst CorePack = <E extends SpaceElementType = \"div\">(\n {\n className,\n size = \"medium\",\n reverse = false,\n direction = \"x\",\n bordered = true,\n rounded = true,\n shadow = false,\n ...props\n }: PackProps<E>,\n // select the correct type for the ref\n ref: ForwardedRef<JSX.IntrinsicElements[E]>,\n): ReactElement => (\n // @ts-expect-error\n <Space<E>\n ref={ref}\n direction={direction}\n reverse={reverse}\n className={CSS(\n CSS.B(\"pack\"),\n shadow && CSS.BM(\"pack\", \"shadow\"),\n CSS.dir(direction),\n typeof size !== \"number\" && CSS.BM(\"pack\", size),\n reverse && CSS.BM(\"pack\", \"reverse\"),\n className,\n )}\n bordered={bordered}\n rounded={rounded}\n {...props}\n empty\n />\n);\n\n/**\n * Packs elements together, setting their size and styling the borders between them so\n * that they appear as a single element. This is useful for buttons that represent a\n * selection state, for example.\n *\n * @param props - The props for the pack. Any extra props will be passed to the\n * underlying Space component.\n * @param props.children - The children to pack together. These must satisfy the\n * {@link PackChildProps} interface.\n * @param props.direction - The direction to pack the children in. Defaults to\n * \"x\".\n * @param props.size - The size to set on the children. Any sizes already set on the\n * children will be overridden. Defaults to \"medium\".\n * @param props.el - The element type to use as the root element for the Pack.\n * Defaults to \"div\".\n */\nexport const Pack = forwardRef(CorePack) as <E extends SpaceElementType = \"div\">(\n props: PackProps<E>,\n) => ReactElement;\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 ForwardedRef, type ReactElement, forwardRef } from \"react\";\n\nimport { Space, type SpaceElementType, type SpaceProps } from \"@/align/Space\";\nimport { CSS } from \"@/css\";\n\nimport \"@/align/Center.css\";\n\nexport const CoreCenter = <E extends SpaceElementType = \"div\">(\n { className, justify = \"center\", align = \"center\", ...props }: SpaceProps<E>,\n ref: ForwardedRef<JSX.IntrinsicElements[E]>,\n): ReactElement => (\n // @ts-expect-error\n <Space<E>\n ref={ref}\n justify={justify}\n align={align}\n className={CSS(CSS.BM(\"space\", \"centered\"), className)}\n {...props}\n />\n);\n\n/**\n * An element whose width and height is 100% and whose alignment and justification\n * is centered. Props are the same as {@link Space}.\n */\nexport const Center = forwardRef(CoreCenter) as <E extends SpaceElementType = \"div\">(\n props: SpaceProps<E>,\n) => ReactElement;\n"],"names":["direction","jsx","Generic.Element"],"mappings":";;;AAmBA,MAAM,cAAc,CAClB,EAAE,IAAI,UAAU,GAAG,MAAM,GACzB,QACiB,cAAc,IAAI,EAAE,GAAG,OAAO,OAAO,QAAQ;AAanD,MAAA,UAAU,WAAW,WAAW;;;;;ACVtC,MAAM,aAAa,CAAC,SAAS,UAAU,OAAO,SAAS;AAMvD,MAAM,iBAAiB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAsCO,MAAM,gBAAgB,CAACA,YAA4B,YACxD,YAAYA,eAAc,WAAW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AAO,aAAgC;AAC5D;AAEA,MAAM,iBAAyE;AAAA,EAC7E,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,cAAc;AAAA,EACd,aAAa;AAAA,EACb,aAAa;AACf;AC/JA,MAAM,WAAW,CACf;AAAA,EACE;AAAA,EACA,OAAO;AAAA,EACP,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,UAAU;AAAA,EACV,SAAS;AAAA,EACT,GAAG;AACL,GAEA;AAAA;AAAA,EAGAC,kCAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA,QACT,IAAI,EAAE,MAAM;AAAA,QACZ,UAAU,IAAI,GAAG,QAAQ,QAAQ;AAAA,QACjC,IAAI,IAAI,SAAS;AAAA,QACjB,OAAO,SAAS,YAAY,IAAI,GAAG,QAAQ,IAAI;AAAA,QAC/C,WAAW,IAAI,GAAG,QAAQ,SAAS;AAAA,QACnC;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,MACC,GAAG;AAAA,MACJ,OAAK;AAAA,IAAA;AAAA,EACP;AAAA;AAmBW,MAAA,OAAO,WAAW,QAAQ;AC1D1B,MAAA,aAAa,CACxB,EAAE,WAAW,UAAU,UAAU,QAAQ,UAAU,GAAG,MAAA,GACtD;AAAA;AAAA,EAGAA,kCAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW,IAAI,IAAI,GAAG,SAAS,UAAU,GAAG,SAAS;AAAA,MACpD,GAAG;AAAA,IAAA;AAAA,EACN;AAAA;AAOW,MAAA,SAAS,WAAW,UAAU;"}
|
|
1
|
+
{"version":3,"file":"Center-8mBjm1cO.js","sources":["../src/generic/Generic.tsx","../src/align/Space.tsx","../src/align/Pack.tsx","../src/align/Center.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 ComponentPropsWithRef,\n createElement,\n type ForwardedRef,\n forwardRef,\n type ReactElement,\n} from \"react\";\n\nexport type JSXElementType = keyof JSX.IntrinsicElements;\n\nconst CoreElement = <E extends JSXElementType>(\n { el, children, ...props }: ElementProps<E>,\n ref: ForwardedRef<JSX.IntrinsicElements[E]>,\n): ReactElement => createElement(el, { ...props, ref }, children);\n\nexport type ElementProps<E extends JSXElementType> = ComponentPropsWithRef<E> & {\n el: E;\n};\n\n/**\n * Generic renders a component with the given element type .\n *\n * @param props - Props for the generic component. All props not defined below are passed to\n * the underlying element.\n * @param props.el - The element type to render.\n */\nexport const Element = forwardRef(CoreElement) as <E extends JSXElementType>(\n props: ElementProps<E>,\n) => ReactElement;\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 type CSSProperties,\n type ForwardedRef,\n type ReactElement,\n forwardRef,\n} from \"react\";\n\nimport { direction } from \"@synnaxlabs/x\";\n\nimport { CSS } from \"@/css\";\nimport { Generic } from \"@/generic\";\nimport { type ComponentSize } from \"@/util/component\";\n\nimport \"@/align/Space.css\";\n\n/** All possible alignments for the cross axis of a space */\nexport const ALIGNMENTS = [\"start\", \"center\", \"end\", \"stretch\"] as const;\n\n/** The alignments for the cross axis of a space */\nexport type Alignment = (typeof ALIGNMENTS)[number];\n\n/** All possible justifications for the main axis of a space */\nexport const JUSTIFICATIONS = [\n \"start\",\n \"center\",\n \"end\",\n \"spaceBetween\",\n \"spaceAround\",\n \"spaceEvenly\",\n] as const;\n\n/** The justification for the main axis of a space */\nexport type Justification = (typeof JUSTIFICATIONS)[number];\n\nexport type SpaceElementType =\n | \"div\"\n | \"header\"\n | \"nav\"\n | \"section\"\n | \"article\"\n | \"aside\"\n | \"footer\"\n | \"button\"\n | \"dialog\"\n | \"a\";\n\nexport interface SpaceExtensionProps {\n empty?: boolean;\n size?: ComponentSize | number;\n direction?: direction.Crude;\n reverse?: boolean;\n justify?: Justification;\n align?: Alignment;\n grow?: boolean | number;\n shrink?: boolean | number;\n wrap?: boolean;\n el?: SpaceElementType;\n bordered?: boolean;\n rounded?: boolean;\n}\n\nexport type SpaceProps<E extends SpaceElementType = \"div\"> = Omit<\n Generic.ElementProps<E>,\n \"el\"\n> &\n SpaceExtensionProps;\n\nexport const shouldReverse = (direction: direction.Crude, reverse?: boolean): boolean =>\n reverse ?? (direction === \"right\" || direction === \"bottom\");\n\nconst CoreSpace = <E extends SpaceElementType>(\n {\n style,\n align,\n className,\n grow,\n shrink,\n empty = false,\n size = \"medium\",\n justify = \"start\",\n reverse,\n direction: direction_ = \"y\",\n wrap = false,\n bordered = false,\n rounded = false,\n el = \"div\",\n ...props\n }: SpaceProps<E>,\n ref: ForwardedRef<JSX.IntrinsicElements[E]>,\n): ReactElement => {\n const dir = direction.construct(direction_);\n reverse = shouldReverse(direction_, reverse);\n\n let gap: number | string | undefined;\n if (empty) [size, gap] = [0, 0];\n else if (typeof size === \"number\") gap = `${size}rem`;\n\n style = {\n gap,\n flexDirection: flexDirection(dir, reverse),\n justifyContent: justifications[justify],\n alignItems: align,\n flexWrap: wrap ? \"wrap\" : \"nowrap\",\n ...style,\n };\n\n if (grow != null) style.flexGrow = Number(grow);\n if (shrink != null) style.flexShrink = Number(shrink);\n\n return (\n // @ts-expect-error\n <Generic.Element<E>\n el={el}\n ref={ref}\n className={CSS(\n CSS.B(\"space\"),\n CSS.dir(dir),\n CSS.bordered(bordered),\n CSS.rounded(rounded),\n typeof size === \"string\" && CSS.BM(\"space\", size),\n className,\n )}\n style={style}\n {...props}\n />\n );\n};\nCoreSpace.displayName = \"Space\";\n\n/**\n * A component that orients its children in a row or column and adds\n * space between them. This is essentially a thin wrapped around a\n * flex component that makes it more 'reacty' to use.\n *\n * @param props - The props for the component. All unlisted props will be passed\n * to the underlying root element.\n * @param props.align - The off axis alignment of the children. The 'off' axis is the\n * opposite direction of props.direction. For example, if direction is 'x', then the\n * off axis is 'y'. See the {@link Alignment} for available options.\n * @param props.justify - The main axis justification of the children. The 'main' axis\n * is the same direction as props.direction. For example, if direction is 'x', then the\n * main axis is 'x'. See the {@link Justification} for available options.\n * @param props.grow - A boolean or number value that determines if the space should\n * grow in the flex-box sense. A value of true will set css flex-grow to 1. A value of\n * false will leave the css flex-grow unset. A number value will set the css flex-grow\n * to that number.\n * @param props.size - A string or number value that determines the amount of spacing\n * between items. If set to \"small\", \"medium\", or \"large\", the spacing will be determined\n * by the theme. If set to a number, the spacing will be that number of rem.\n * @param props.wrap - A boolean value that determines if the space should wrap its\n * children.\n * @param props.el - The element type to render as. Defaults to 'div'.\n */\nexport const Space = forwardRef(CoreSpace) as <E extends SpaceElementType = \"div\">(\n props: SpaceProps<E>,\n) => ReactElement;\n\ntype FlexDirection = CSSProperties[\"flexDirection\"];\n\nconst flexDirection = (\n direction: direction.Direction,\n reverse: boolean,\n): FlexDirection => {\n const base = direction === \"x\" ? \"row\" : \"column\";\n return reverse ? ((base + \"-reverse\") as FlexDirection) : base;\n};\n\nconst justifications: Record<Justification, CSSProperties[\"justifyContent\"]> = {\n start: \"flex-start\",\n center: \"center\",\n end: \"flex-end\",\n spaceBetween: \"space-between\",\n spaceAround: \"space-around\",\n spaceEvenly: \"space-evenly\",\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 ForwardedRef, type ReactElement, forwardRef } from \"react\";\n\nimport { Space, type SpaceElementType, type SpaceProps } from \"@/align/Space\";\nimport { CSS } from \"@/css\";\n\nimport \"@/align/Pack.css\";\n\n/** Props for the {@link Pack} component. */\nexport type PackProps<E extends SpaceElementType = \"div\"> = Omit<\n SpaceProps<E>,\n \"empty\"\n> & {\n shadow?: boolean;\n};\n\nconst CorePack = <E extends SpaceElementType = \"div\">(\n {\n className,\n size = \"medium\",\n reverse = false,\n direction = \"x\",\n bordered = true,\n rounded = true,\n shadow = false,\n ...props\n }: PackProps<E>,\n // select the correct type for the ref\n ref: ForwardedRef<JSX.IntrinsicElements[E]>,\n): ReactElement => (\n // @ts-expect-error\n <Space<E>\n ref={ref}\n direction={direction}\n reverse={reverse}\n className={CSS(\n CSS.B(\"pack\"),\n shadow && CSS.BM(\"pack\", \"shadow\"),\n CSS.dir(direction),\n typeof size !== \"number\" && CSS.BM(\"pack\", size),\n reverse && CSS.BM(\"pack\", \"reverse\"),\n className,\n )}\n bordered={bordered}\n rounded={rounded}\n {...props}\n empty\n />\n);\n\n/**\n * Packs elements together, setting their size and styling the borders between them so\n * that they appear as a single element. This is useful for buttons that represent a\n * selection state, for example.\n *\n * @param props - The props for the pack. Any extra props will be passed to the\n * underlying Space component.\n * @param props.children - The children to pack together. These must satisfy the\n * {@link PackChildProps} interface.\n * @param props.direction - The direction to pack the children in. Defaults to\n * \"x\".\n * @param props.size - The size to set on the children. Any sizes already set on the\n * children will be overridden. Defaults to \"medium\".\n * @param props.el - The element type to use as the root element for the Pack.\n * Defaults to \"div\".\n */\nexport const Pack = forwardRef(CorePack) as <E extends SpaceElementType = \"div\">(\n props: PackProps<E>,\n) => ReactElement;\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 ForwardedRef, type ReactElement, forwardRef } from \"react\";\n\nimport { Space, type SpaceElementType, type SpaceProps } from \"@/align/Space\";\nimport { CSS } from \"@/css\";\n\nimport \"@/align/Center.css\";\n\nexport const CoreCenter = <E extends SpaceElementType = \"div\">(\n { className, justify = \"center\", align = \"center\", ...props }: SpaceProps<E>,\n ref: ForwardedRef<JSX.IntrinsicElements[E]>,\n): ReactElement => (\n // @ts-expect-error\n <Space<E>\n ref={ref}\n justify={justify}\n align={align}\n className={CSS(CSS.BM(\"space\", \"centered\"), className)}\n {...props}\n />\n);\n\n/**\n * An element whose width and height is 100% and whose alignment and justification\n * is centered. Props are the same as {@link Space}.\n */\nexport const Center = forwardRef(CoreCenter) as <E extends SpaceElementType = \"div\">(\n props: SpaceProps<E>,\n) => ReactElement;\n"],"names":["CoreElement","el","children","props","ref","createElement","Element","forwardRef","ALIGNMENTS","JUSTIFICATIONS","shouldReverse","direction","reverse","CoreSpace","style","align","className","grow","shrink","empty","size","justify","direction_","wrap","bordered","rounded","dir","gap","flexDirection","justifications","jsx","Generic.Element","CSS","Space","base","CorePack","shadow","Pack","CoreCenter","Center"],"mappings":";;;AAmBA,MAAMA,IAAc,CAClB,EAAE,IAAAC,GAAI,UAAAC,GAAU,GAAGC,EAAM,GACzBC,MACiBC,EAAcJ,GAAI,EAAE,GAAGE,GAAO,KAAAC,KAAOF,CAAQ,GAanDI,IAAUC,EAAWP,CAAW;;;8CCVhCQ,IAAa,CAAC,SAAS,UAAU,OAAO,SAAS,GAMjDC,IAAiB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAsCaC,IAAgB,CAACC,GAA4BC,MACxDA,MAAYD,MAAc,WAAWA,MAAc,WAE/CE,IAAY,CAChB;AAAA,EACE,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,MAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,MAAAC,IAAO;AAAA,EACP,SAAAC,IAAU;AAAA,EACV,SAAAT;AAAA,EACA,WAAWU,IAAa;AAAA,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.cjs"),S=require("react"),t=require("./css-s9KpanYu.cjs"),y=({el:e,children:r,...n},c)=>S.createElement(e,{...n,ref:c},r),d=S.forwardRef(y),M=Object.freeze(Object.defineProperty({__proto__:null,Element:d},Symbol.toStringTag,{value:"Module"})),k=["start","center","end","stretch"],T=["start","center","end","spaceBetween","spaceAround","spaceEvenly"],x=(e,r)=>r??(e==="right"||e==="bottom"),N=({style:e,align:r,className:n,grow:c,shrink:a,empty:l=!1,size:s="medium",justify:p="start",reverse:o,direction:m="y",wrap:j=!1,bordered:w=!1,rounded:E=!1,el:R="div",...B},I)=>{const C=t.direction$1.construct(m);o=x(m,o);let u;return l?[s,u]=[0,0]:typeof s=="number"&&(u=`${s}rem`),e={gap:u,flexDirection:v(C,o),justifyContent:A[p],alignItems:r,flexWrap:j?"wrap":"nowrap",...e},c!=null&&(e.flexGrow=Number(c)),a!=null&&(e.flexShrink=Number(a)),f.jsxRuntimeExports.jsx(d,{el:R,ref:I,className:t.CSS(t.CSS.B("space"),t.CSS.dir(C),t.CSS.bordered(w),t.CSS.rounded(E),typeof s=="string"&&t.CSS.BM("space",s),n),style:e,...B})};N.displayName="Space";const i=S.forwardRef(N),v=(e,r)=>{const n=e==="x"?"row":"column";return r?n+"-reverse":n},A={start:"flex-start",center:"center",end:"flex-end",spaceBetween:"space-between",spaceAround:"space-around",spaceEvenly:"space-evenly"},g=({className:e,size:r="medium",reverse:n=!1,direction:c="x",bordered:a=!0,rounded:l=!0,shadow:s=!1,...p},o)=>f.jsxRuntimeExports.jsx(i,{ref:o,direction:c,reverse:n,className:t.CSS(t.CSS.B("pack"),s&&t.CSS.BM("pack","shadow"),t.CSS.dir(c),typeof r!="number"&&t.CSS.BM("pack",r),n&&t.CSS.BM("pack","reverse"),e),bordered:a,rounded:l,...p,empty:!0}),h=S.forwardRef(g),b=({className:e,justify:r="center",align:n="center",...c},a)=>f.jsxRuntimeExports.jsx(i,{ref:a,justify:r,align:n,className:t.CSS(t.CSS.BM("space","centered"),e),...c}),G=S.forwardRef(b);exports.ALIGNMENTS=k;exports.Center=G;exports.CoreCenter=b;exports.Element=d;exports.Generic=M;exports.JUSTIFICATIONS=T;exports.Pack=h;exports.Space=i;exports.shouldReverse=x;
|
|
2
|
+
//# sourceMappingURL=Center-ER_owvfX.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Center-ZAcURh-3.cjs","sources":["../src/generic/Generic.tsx","../src/align/Space.tsx","../src/align/Pack.tsx","../src/align/Center.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 ComponentPropsWithRef,\n createElement,\n type ForwardedRef,\n forwardRef,\n type ReactElement,\n} from \"react\";\n\nexport type JSXElementType = keyof JSX.IntrinsicElements;\n\nconst CoreElement = <E extends JSXElementType>(\n { el, children, ...props }: ElementProps<E>,\n ref: ForwardedRef<JSX.IntrinsicElements[E]>,\n): ReactElement => createElement(el, { ...props, ref }, children);\n\nexport type ElementProps<E extends JSXElementType> = ComponentPropsWithRef<E> & {\n el: E;\n};\n\n/**\n * Generic renders a component with the given element type .\n *\n * @param props - Props for the generic component. All props not defined below are passed to\n * the underlying element.\n * @param props.el - The element type to render.\n */\nexport const Element = forwardRef(CoreElement) as <E extends JSXElementType>(\n props: ElementProps<E>,\n) => ReactElement;\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 type CSSProperties,\n type ForwardedRef,\n type ReactElement,\n forwardRef,\n} from \"react\";\n\nimport { direction } from \"@synnaxlabs/x\";\n\nimport { CSS } from \"@/css\";\nimport { Generic } from \"@/generic\";\nimport { type ComponentSize } from \"@/util/component\";\n\nimport \"@/align/Space.css\";\n\n/** All possible alignments for the cross axis of a space */\nexport const ALIGNMENTS = [\"start\", \"center\", \"end\", \"stretch\"] as const;\n\n/** The alignments for the cross axis of a space */\nexport type Alignment = (typeof ALIGNMENTS)[number];\n\n/** All possible justifications for the main axis of a space */\nexport const JUSTIFICATIONS = [\n \"start\",\n \"center\",\n \"end\",\n \"spaceBetween\",\n \"spaceAround\",\n \"spaceEvenly\",\n] as const;\n\n/** The justification for the main axis of a space */\nexport type Justification = (typeof JUSTIFICATIONS)[number];\n\nexport type SpaceElementType =\n | \"div\"\n | \"header\"\n | \"nav\"\n | \"section\"\n | \"article\"\n | \"aside\"\n | \"footer\"\n | \"button\"\n | \"dialog\"\n | \"a\";\n\nexport interface SpaceExtensionProps {\n empty?: boolean;\n size?: ComponentSize | number;\n direction?: direction.Crude;\n reverse?: boolean;\n justify?: Justification;\n align?: Alignment;\n grow?: boolean | number;\n shrink?: boolean | number;\n wrap?: boolean;\n el?: SpaceElementType;\n bordered?: boolean;\n rounded?: boolean;\n}\n\nexport type SpaceProps<E extends SpaceElementType = \"div\"> = Omit<\n Generic.ElementProps<E>,\n \"el\"\n> &\n SpaceExtensionProps;\n\nexport const shouldReverse = (direction: direction.Crude, reverse?: boolean): boolean =>\n reverse ?? (direction === \"right\" || direction === \"bottom\");\n\nconst CoreSpace = <E extends SpaceElementType>(\n {\n style,\n align,\n className,\n grow,\n shrink,\n empty = false,\n size = \"medium\",\n justify = \"start\",\n reverse,\n direction: direction_ = \"y\",\n wrap = false,\n bordered = false,\n rounded = false,\n el = \"div\",\n ...props\n }: SpaceProps<E>,\n ref: ForwardedRef<JSX.IntrinsicElements[E]>,\n): ReactElement => {\n const dir = direction.construct(direction_);\n reverse = shouldReverse(direction_, reverse);\n\n let gap: number | string | undefined;\n if (empty) [size, gap] = [0, 0];\n else if (typeof size === \"number\") gap = `${size}rem`;\n\n style = {\n gap,\n flexDirection: flexDirection(dir, reverse),\n justifyContent: justifications[justify],\n alignItems: align,\n flexWrap: wrap ? \"wrap\" : \"nowrap\",\n ...style,\n };\n\n if (grow != null) style.flexGrow = Number(grow);\n if (shrink != null) style.flexShrink = Number(shrink);\n\n return (\n // @ts-expect-error\n <Generic.Element<E>\n el={el}\n ref={ref}\n className={CSS(\n CSS.B(\"space\"),\n CSS.dir(dir),\n CSS.bordered(bordered),\n CSS.rounded(rounded),\n typeof size === \"string\" && CSS.BM(\"space\", size),\n className,\n )}\n style={style}\n {...props}\n />\n );\n};\nCoreSpace.displayName = \"Space\";\n\n/**\n * A component that orients its children in a row or column and adds\n * space between them. This is essentially a thin wrapped around a\n * flex component that makes it more 'reacty' to use.\n *\n * @param props - The props for the component. All unlisted props will be passed\n * to the underlying root element.\n * @param props.align - The off axis alignment of the children. The 'off' axis is the\n * opposite direction of props.direction. For example, if direction is 'x', then the\n * off axis is 'y'. See the {@link Alignment} for available options.\n * @param props.justify - The main axis justification of the children. The 'main' axis\n * is the same direction as props.direction. For example, if direction is 'x', then the\n * main axis is 'x'. See the {@link Justification} for available options.\n * @param props.grow - A boolean or number value that determines if the space should\n * grow in the flex-box sense. A value of true will set css flex-grow to 1. A value of\n * false will leave the css flex-grow unset. A number value will set the css flex-grow\n * to that number.\n * @param props.size - A string or number value that determines the amount of spacing\n * between items. If set to \"small\", \"medium\", or \"large\", the spacing will be determined\n * by the theme. If set to a number, the spacing will be that number of rem.\n * @param props.wrap - A boolean value that determines if the space should wrap its\n * children.\n * @param props.el - The element type to render as. Defaults to 'div'.\n */\nexport const Space = forwardRef(CoreSpace) as <E extends SpaceElementType = \"div\">(\n props: SpaceProps<E>,\n) => ReactElement;\n\ntype FlexDirection = CSSProperties[\"flexDirection\"];\n\nconst flexDirection = (\n direction: direction.Direction,\n reverse: boolean,\n): FlexDirection => {\n const base = direction === \"x\" ? \"row\" : \"column\";\n return reverse ? ((base + \"-reverse\") as FlexDirection) : base;\n};\n\nconst justifications: Record<Justification, CSSProperties[\"justifyContent\"]> = {\n start: \"flex-start\",\n center: \"center\",\n end: \"flex-end\",\n spaceBetween: \"space-between\",\n spaceAround: \"space-around\",\n spaceEvenly: \"space-evenly\",\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 ForwardedRef, type ReactElement, forwardRef } from \"react\";\n\nimport { Space, type SpaceElementType, type SpaceProps } from \"@/align/Space\";\nimport { CSS } from \"@/css\";\n\nimport \"@/align/Pack.css\";\n\n/** Props for the {@link Pack} component. */\nexport type PackProps<E extends SpaceElementType = \"div\"> = Omit<\n SpaceProps<E>,\n \"empty\"\n> & {\n shadow?: boolean;\n};\n\nconst CorePack = <E extends SpaceElementType = \"div\">(\n {\n className,\n size = \"medium\",\n reverse = false,\n direction = \"x\",\n bordered = true,\n rounded = true,\n shadow = false,\n ...props\n }: PackProps<E>,\n // select the correct type for the ref\n ref: ForwardedRef<JSX.IntrinsicElements[E]>,\n): ReactElement => (\n // @ts-expect-error\n <Space<E>\n ref={ref}\n direction={direction}\n reverse={reverse}\n className={CSS(\n CSS.B(\"pack\"),\n shadow && CSS.BM(\"pack\", \"shadow\"),\n CSS.dir(direction),\n typeof size !== \"number\" && CSS.BM(\"pack\", size),\n reverse && CSS.BM(\"pack\", \"reverse\"),\n className,\n )}\n bordered={bordered}\n rounded={rounded}\n {...props}\n empty\n />\n);\n\n/**\n * Packs elements together, setting their size and styling the borders between them so\n * that they appear as a single element. This is useful for buttons that represent a\n * selection state, for example.\n *\n * @param props - The props for the pack. Any extra props will be passed to the\n * underlying Space component.\n * @param props.children - The children to pack together. These must satisfy the\n * {@link PackChildProps} interface.\n * @param props.direction - The direction to pack the children in. Defaults to\n * \"x\".\n * @param props.size - The size to set on the children. Any sizes already set on the\n * children will be overridden. Defaults to \"medium\".\n * @param props.el - The element type to use as the root element for the Pack.\n * Defaults to \"div\".\n */\nexport const Pack = forwardRef(CorePack) as <E extends SpaceElementType = \"div\">(\n props: PackProps<E>,\n) => ReactElement;\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 ForwardedRef, type ReactElement, forwardRef } from \"react\";\n\nimport { Space, type SpaceElementType, type SpaceProps } from \"@/align/Space\";\nimport { CSS } from \"@/css\";\n\nimport \"@/align/Center.css\";\n\nexport const CoreCenter = <E extends SpaceElementType = \"div\">(\n { className, justify = \"center\", align = \"center\", ...props }: SpaceProps<E>,\n ref: ForwardedRef<JSX.IntrinsicElements[E]>,\n): ReactElement => (\n // @ts-expect-error\n <Space<E>\n ref={ref}\n justify={justify}\n align={align}\n className={CSS(CSS.BM(\"space\", \"centered\"), className)}\n {...props}\n />\n);\n\n/**\n * An element whose width and height is 100% and whose alignment and justification\n * is centered. Props are the same as {@link Space}.\n */\nexport const Center = forwardRef(CoreCenter) as <E extends SpaceElementType = \"div\">(\n props: SpaceProps<E>,\n) => ReactElement;\n"],"names":["createElement","forwardRef","direction","jsx","Generic.Element","CSS"],"mappings":";;;;AAmBA,MAAM,cAAc,CAClB,EAAE,IAAI,UAAU,GAAG,MAAM,GACzB,QACiBA,MAAAA,cAAc,IAAI,EAAE,GAAG,OAAO,OAAO,QAAQ;AAanD,MAAA,UAAUC,iBAAW,WAAW;;;;;ACVtC,MAAM,aAAa,CAAC,SAAS,UAAU,OAAO,SAAS;AAMvD,MAAM,iBAAiB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAsCO,MAAM,gBAAgB,CAACC,YAA4B,YACxD,YAAYA,eAAc,WAAWA,eAAc;AAErD,MAAM,YAAY,CAChB;AA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tsx","../src/align/Space.tsx","../src/align/Pack.tsx","../src/align/Center.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 ComponentPropsWithRef,\n createElement,\n type ForwardedRef,\n forwardRef,\n type ReactElement,\n} from \"react\";\n\nexport type JSXElementType = keyof JSX.IntrinsicElements;\n\nconst CoreElement = <E extends JSXElementType>(\n { el, children, ...props }: ElementProps<E>,\n ref: ForwardedRef<JSX.IntrinsicElements[E]>,\n): ReactElement => createElement(el, { ...props, ref }, children);\n\nexport type ElementProps<E extends JSXElementType> = ComponentPropsWithRef<E> & {\n el: E;\n};\n\n/**\n * Generic renders a component with the given element type .\n *\n * @param props - Props for the generic component. All props not defined below are passed to\n * the underlying element.\n * @param props.el - The element type to render.\n */\nexport const Element = forwardRef(CoreElement) as <E extends JSXElementType>(\n props: ElementProps<E>,\n) => ReactElement;\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 type CSSProperties,\n type ForwardedRef,\n type ReactElement,\n forwardRef,\n} from \"react\";\n\nimport { direction } from \"@synnaxlabs/x\";\n\nimport { CSS } from \"@/css\";\nimport { Generic } from \"@/generic\";\nimport { type ComponentSize } from \"@/util/component\";\n\nimport \"@/align/Space.css\";\n\n/** All possible alignments for the cross axis of a space */\nexport const ALIGNMENTS = [\"start\", \"center\", \"end\", \"stretch\"] as const;\n\n/** The alignments for the cross axis of a space */\nexport type Alignment = (typeof ALIGNMENTS)[number];\n\n/** All possible justifications for the main axis of a space */\nexport const JUSTIFICATIONS = [\n \"start\",\n \"center\",\n \"end\",\n \"spaceBetween\",\n \"spaceAround\",\n \"spaceEvenly\",\n] as const;\n\n/** The justification for the main axis of a space */\nexport type Justification = (typeof JUSTIFICATIONS)[number];\n\nexport type SpaceElementType =\n | \"div\"\n | \"header\"\n | \"nav\"\n | \"section\"\n | \"article\"\n | \"aside\"\n | \"footer\"\n | \"button\"\n | \"dialog\"\n | \"a\";\n\nexport interface SpaceExtensionProps {\n empty?: boolean;\n size?: ComponentSize | number;\n direction?: direction.Crude;\n reverse?: boolean;\n justify?: Justification;\n align?: Alignment;\n grow?: boolean | number;\n shrink?: boolean | number;\n wrap?: boolean;\n el?: SpaceElementType;\n bordered?: boolean;\n rounded?: boolean;\n}\n\nexport type SpaceProps<E extends SpaceElementType = \"div\"> = Omit<\n Generic.ElementProps<E>,\n \"el\"\n> &\n SpaceExtensionProps;\n\nexport const shouldReverse = (direction: direction.Crude, reverse?: boolean): boolean =>\n reverse ?? (direction === \"right\" || direction === \"bottom\");\n\nconst CoreSpace = <E extends SpaceElementType>(\n {\n style,\n align,\n className,\n grow,\n shrink,\n empty = false,\n size = \"medium\",\n justify = \"start\",\n reverse,\n direction: direction_ = \"y\",\n wrap = false,\n bordered = false,\n rounded = false,\n el = \"div\",\n ...props\n }: SpaceProps<E>,\n ref: ForwardedRef<JSX.IntrinsicElements[E]>,\n): ReactElement => {\n const dir = direction.construct(direction_);\n reverse = shouldReverse(direction_, reverse);\n\n let gap: number | string | undefined;\n if (empty) [size, gap] = [0, 0];\n else if (typeof size === \"number\") gap = `${size}rem`;\n\n style = {\n gap,\n flexDirection: flexDirection(dir, reverse),\n justifyContent: justifications[justify],\n alignItems: align,\n flexWrap: wrap ? \"wrap\" : \"nowrap\",\n ...style,\n };\n\n if (grow != null) style.flexGrow = Number(grow);\n if (shrink != null) style.flexShrink = Number(shrink);\n\n return (\n // @ts-expect-error\n <Generic.Element<E>\n el={el}\n ref={ref}\n className={CSS(\n CSS.B(\"space\"),\n CSS.dir(dir),\n CSS.bordered(bordered),\n CSS.rounded(rounded),\n typeof size === \"string\" && CSS.BM(\"space\", size),\n className,\n )}\n style={style}\n {...props}\n />\n );\n};\nCoreSpace.displayName = \"Space\";\n\n/**\n * A component that orients its children in a row or column and adds\n * space between them. This is essentially a thin wrapped around a\n * flex component that makes it more 'reacty' to use.\n *\n * @param props - The props for the component. All unlisted props will be passed\n * to the underlying root element.\n * @param props.align - The off axis alignment of the children. The 'off' axis is the\n * opposite direction of props.direction. For example, if direction is 'x', then the\n * off axis is 'y'. See the {@link Alignment} for available options.\n * @param props.justify - The main axis justification of the children. The 'main' axis\n * is the same direction as props.direction. For example, if direction is 'x', then the\n * main axis is 'x'. See the {@link Justification} for available options.\n * @param props.grow - A boolean or number value that determines if the space should\n * grow in the flex-box sense. A value of true will set css flex-grow to 1. A value of\n * false will leave the css flex-grow unset. A number value will set the css flex-grow\n * to that number.\n * @param props.size - A string or number value that determines the amount of spacing\n * between items. If set to \"small\", \"medium\", or \"large\", the spacing will be determined\n * by the theme. If set to a number, the spacing will be that number of rem.\n * @param props.wrap - A boolean value that determines if the space should wrap its\n * children.\n * @param props.el - The element type to render as. Defaults to 'div'.\n */\nexport const Space = forwardRef(CoreSpace) as <E extends SpaceElementType = \"div\">(\n props: SpaceProps<E>,\n) => ReactElement;\n\ntype FlexDirection = CSSProperties[\"flexDirection\"];\n\nconst flexDirection = (\n direction: direction.Direction,\n reverse: boolean,\n): FlexDirection => {\n const base = direction === \"x\" ? \"row\" : \"column\";\n return reverse ? ((base + \"-reverse\") as FlexDirection) : base;\n};\n\nconst justifications: Record<Justification, CSSProperties[\"justifyContent\"]> = {\n start: \"flex-start\",\n center: \"center\",\n end: \"flex-end\",\n spaceBetween: \"space-between\",\n spaceAround: \"space-around\",\n spaceEvenly: \"space-evenly\",\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 ForwardedRef, type ReactElement, forwardRef } from \"react\";\n\nimport { Space, type SpaceElementType, type SpaceProps } from \"@/align/Space\";\nimport { CSS } from \"@/css\";\n\nimport \"@/align/Pack.css\";\n\n/** Props for the {@link Pack} component. */\nexport type PackProps<E extends SpaceElementType = \"div\"> = Omit<\n SpaceProps<E>,\n \"empty\"\n> & {\n shadow?: boolean;\n};\n\nconst CorePack = <E extends SpaceElementType = \"div\">(\n {\n className,\n size = \"medium\",\n reverse = false,\n direction = \"x\",\n bordered = true,\n rounded = true,\n shadow = false,\n ...props\n }: PackProps<E>,\n // select the correct type for the ref\n ref: ForwardedRef<JSX.IntrinsicElements[E]>,\n): ReactElement => (\n // @ts-expect-error\n <Space<E>\n ref={ref}\n direction={direction}\n reverse={reverse}\n className={CSS(\n CSS.B(\"pack\"),\n shadow && CSS.BM(\"pack\", \"shadow\"),\n CSS.dir(direction),\n typeof size !== \"number\" && CSS.BM(\"pack\", size),\n reverse && CSS.BM(\"pack\", \"reverse\"),\n className,\n )}\n bordered={bordered}\n rounded={rounded}\n {...props}\n empty\n />\n);\n\n/**\n * Packs elements together, setting their size and styling the borders between them so\n * that they appear as a single element. This is useful for buttons that represent a\n * selection state, for example.\n *\n * @param props - The props for the pack. Any extra props will be passed to the\n * underlying Space component.\n * @param props.children - The children to pack together. These must satisfy the\n * {@link PackChildProps} interface.\n * @param props.direction - The direction to pack the children in. Defaults to\n * \"x\".\n * @param props.size - The size to set on the children. Any sizes already set on the\n * children will be overridden. Defaults to \"medium\".\n * @param props.el - The element type to use as the root element for the Pack.\n * Defaults to \"div\".\n */\nexport const Pack = forwardRef(CorePack) as <E extends SpaceElementType = \"div\">(\n props: PackProps<E>,\n) => ReactElement;\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 ForwardedRef, type ReactElement, forwardRef } from \"react\";\n\nimport { Space, type SpaceElementType, type SpaceProps } from \"@/align/Space\";\nimport { CSS } from \"@/css\";\n\nimport \"@/align/Center.css\";\n\nexport const CoreCenter = <E extends SpaceElementType = \"div\">(\n { className, justify = \"center\", align = \"center\", ...props }: SpaceProps<E>,\n ref: ForwardedRef<JSX.IntrinsicElements[E]>,\n): ReactElement => (\n // @ts-expect-error\n <Space<E>\n ref={ref}\n justify={justify}\n align={align}\n className={CSS(CSS.BM(\"space\", \"centered\"), className)}\n {...props}\n />\n);\n\n/**\n * An element whose width and height is 100% and whose alignment and justification\n * is centered. Props are the same as {@link Space}.\n */\nexport const Center = forwardRef(CoreCenter) as <E extends SpaceElementType = \"div\">(\n props: SpaceProps<E>,\n) => ReactElement;\n"],"names":["CoreElement","el","children","props","ref","createElement","Element","forwardRef","ALIGNMENTS","JUSTIFICATIONS","shouldReverse","direction","reverse","CoreSpace","style","align","className","grow","shrink","empty","size","justify","direction_","wrap","bordered","rounded","dir","gap","flexDirection","justifications","jsx","Generic.Element","CSS","Space","base","CorePack","shadow","Pack","CoreCenter","Center"],"mappings":"8GAmBMA,EAAc,CAClB,CAAE,GAAAC,EAAI,SAAAC,EAAU,GAAGC,CAAM,EACzBC,IACiBC,EAAAA,cAAcJ,EAAI,CAAE,GAAGE,EAAO,IAAAC,GAAOF,CAAQ,EAanDI,EAAUC,aAAWP,CAAW,yGCVhCQ,EAAa,CAAC,QAAS,SAAU,MAAO,SAAS,EAMjDC,EAAiB,CAC5B,QACA,SACA,MACA,eACA,cACA,aACF,EAsCaC,EAAgB,CAACC,EAA4BC,IACxDA,IAAYD,IAAc,SAAWA,IAAc,UAE/CE,EAAY,CAChB,CACE,MAAAC,EACA,MAAAC,EACA,UAAAC,EACA,KAAAC,EACA,OAAAC,EACA,MAAAC,EAAQ,GACR,KAAAC,EAAO,SACP,QAAAC,EAAU,QACV,QAAAT,EACA,UAAWU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,SAAAa,EAAW,GACX,QAAAC,EAAU,GACV,OAAAW,EAAS,GACT,GAAGjC,CACL,EAEAC,IAGA0B,EAAA,kBAAA,IAACG,EAAA,CACC,IAAA7B,EACA,UAAAO,EACA,QAAAC,EACA,UAAWoB,EAAA,IACTA,EAAA,IAAI,EAAE,MAAM,EACZI,GAAUJ,EAAA,IAAI,GAAG,OAAQ,QAAQ,EACjCA,EAAA,IAAI,IAAIrB,CAAS,EACjB,OAAOS,GAAS,UAAYY,EAAAA,IAAI,GAAG,OAAQZ,CAAI,EAC/CR,GAAWoB,EAAA,IAAI,GAAG,OAAQ,SAAS,EACnChB,CACF,EACA,SAAAQ,EACA,QAAAC,EACC,GAAGtB,EACJ,MAAK,EAAA,CACP,EAmBWkC,EAAO9B,aAAW4B,CAAQ,EC1D1BG,EAAa,CACxB,CAAE,UAAAtB,EAAW,QAAAK,EAAU,SAAU,MAAAN,EAAQ,SAAU,GAAGZ,CAAA,EACtDC,IAGA0B,EAAA,kBAAA,IAACG,EAAA,CACC,IAAA7B,EACA,QAAAiB,EACA,MAAAN,EACA,UAAWiB,EAAI,IAAAA,MAAI,GAAG,QAAS,UAAU,EAAGhB,CAAS,EACpD,GAAGb,CAAA,CACN,EAOWoC,EAAShC,aAAW+B,CAAU"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { j as o } from "./jsx-runtime-NmMXPjeo.js";
|
|
2
|
+
import { createContext as n, useContext as m } from "react";
|
|
3
|
+
import { S as x } from "./Center-8mBjm1cO.js";
|
|
4
|
+
import { C as e } from "./css-5RvvUhjr.js";
|
|
5
|
+
const s = n({
|
|
6
|
+
divided: !1,
|
|
7
|
+
level: "h1"
|
|
8
|
+
}), u = () => m(s), C = ({
|
|
9
|
+
children: r,
|
|
10
|
+
className: a,
|
|
11
|
+
level: d = "h1",
|
|
12
|
+
divided: t = !1,
|
|
13
|
+
...i
|
|
14
|
+
}) => /* @__PURE__ */ o.jsx(s.Provider, { value: { level: d, divided: t }, children: /* @__PURE__ */ o.jsx(
|
|
15
|
+
x,
|
|
16
|
+
{
|
|
17
|
+
el: "header",
|
|
18
|
+
direction: "x",
|
|
19
|
+
justify: "spaceBetween",
|
|
20
|
+
className: e(
|
|
21
|
+
e.B("header"),
|
|
22
|
+
e.bordered("bottom"),
|
|
23
|
+
t && e.BM("header", "divided"),
|
|
24
|
+
a
|
|
25
|
+
),
|
|
26
|
+
...i,
|
|
27
|
+
children: r
|
|
28
|
+
}
|
|
29
|
+
) });
|
|
30
|
+
export {
|
|
31
|
+
C as H,
|
|
32
|
+
u
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=Header-9CR1VnwV.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header-
|
|
1
|
+
{"version":3,"file":"Header-9CR1VnwV.js","sources":["../src/header/Header.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 createContext,\n type ReactElement,\n type ReactNode,\n useContext as reactUseContext,\n} from \"react\";\n\nimport { Align } from \"@/align\";\nimport { CSS } from \"@/css\";\nimport { type Text } from \"@/text\";\n\nimport \"@/header/Header.css\";\n\nexport interface HeaderProps extends Omit<Align.SpaceProps, \"children\" | \"el\"> {\n level?: Text.Level;\n divided?: boolean;\n children: ReactNode | [ReactNode, ReactNode];\n}\n\nexport interface ContextValue {\n divided: boolean;\n level: Text.Level;\n}\n\nconst Context = createContext<ContextValue>({\n divided: false,\n level: \"h1\",\n});\n\nexport const useContext = (): ContextValue => reactUseContext(Context);\n\n/**\n * The container for a module header.\n *\n * @param props - The component props. All unused props will be passed down to the\n * {@link Space} containing the header.\n * @param props.level - The font level for the header. See the {@link Typography.Text}\n * component for all possible levels. Default is \"h1.\"\n * @param props.icon - An optional icon to add add before the start of the header text.\n * @param props.actions - A list of actions to be rendered on the right side ofthe header.\n * If the action is a JSX element, it will be rendered directly, and if its of type\n * ButtonIconProps, a ButtonIconOnly will be rendered using the given props.\n * @param props.divided - If true, creates a divider between the start icon, header text,\n * and each action. Default is false.\n */\nexport const Header = ({\n children,\n className,\n level = \"h1\",\n divided = false,\n ...props\n}: HeaderProps): ReactElement => (\n <Context.Provider value={{ level, divided }}>\n <Align.Space\n el=\"header\"\n direction=\"x\"\n justify=\"spaceBetween\"\n className={CSS(\n CSS.B(\"header\"),\n CSS.bordered(\"bottom\"),\n divided && CSS.BM(\"header\", \"divided\"),\n className,\n )}\n {...props}\n >\n {children}\n </Align.Space>\n </Context.Provider>\n);\n"],"names":["Context","createContext","useContext","reactUseContext","Header","children","className","level","divided","props","jsx","Align.Space","CSS"],"mappings":";;;;AAiCA,MAAMA,IAAUC,EAA4B;AAAA,EAC1C,SAAS;AAAA,EACT,OAAO;AACT,CAAC,GAEYC,IAAa,MAAoBC,EAAgBH,CAAO,GAgBxDI,IAAS,CAAC;AAAA,EACrB,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,SAAAC,IAAU;AAAA,EACV,GAAGC;AACL,MACEC,gBAAAA,EAAA,IAACV,EAAQ,UAAR,EAAiB,OAAO,EAAE,OAAAO,GAAO,SAAAC,KAChC,UAAAE,gBAAAA,EAAA;AAAA,EAACC;AAAAA,EAAA;AAAA,IACC,IAAG;AAAA,IACH,WAAU;AAAA,IACV,SAAQ;AAAA,IACR,WAAWC;AAAA,MACTA,EAAI,EAAE,QAAQ;AAAA,MACdA,EAAI,SAAS,QAAQ;AAAA,MACrBJ,KAAWI,EAAI,GAAG,UAAU,SAAS;AAAA,MACrCN;AAAA,IACF;AAAA,IACC,GAAGG;AAAA,IAEH,UAAAJ;AAAA,EAAA;AACH,EACF,CAAA;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const s=require("./jsx-runtime-evvPGacs.cjs"),r=require("react"),d=require("./Center-ER_owvfX.cjs"),e=require("./css-s9KpanYu.cjs"),n=r.createContext({divided:!1,level:"h1"}),u=()=>r.useContext(n),x=({children:o,className:c,level:i="h1",divided:t=!1,...a})=>s.jsxRuntimeExports.jsx(n.Provider,{value:{level:i,divided:t},children:s.jsxRuntimeExports.jsx(d.Space,{el:"header",direction:"x",justify:"spaceBetween",className:e.CSS(e.CSS.B("header"),e.CSS.bordered("bottom"),t&&e.CSS.BM("header","divided"),c),...a,children:o})});exports.Header=x;exports.useContext=u;
|
|
2
|
+
//# sourceMappingURL=Header-PpcdP7hn.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header-
|
|
1
|
+
{"version":3,"file":"Header-PpcdP7hn.cjs","sources":["../src/header/Header.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 createContext,\n type ReactElement,\n type ReactNode,\n useContext as reactUseContext,\n} from \"react\";\n\nimport { Align } from \"@/align\";\nimport { CSS } from \"@/css\";\nimport { type Text } from \"@/text\";\n\nimport \"@/header/Header.css\";\n\nexport interface HeaderProps extends Omit<Align.SpaceProps, \"children\" | \"el\"> {\n level?: Text.Level;\n divided?: boolean;\n children: ReactNode | [ReactNode, ReactNode];\n}\n\nexport interface ContextValue {\n divided: boolean;\n level: Text.Level;\n}\n\nconst Context = createContext<ContextValue>({\n divided: false,\n level: \"h1\",\n});\n\nexport const useContext = (): ContextValue => reactUseContext(Context);\n\n/**\n * The container for a module header.\n *\n * @param props - The component props. All unused props will be passed down to the\n * {@link Space} containing the header.\n * @param props.level - The font level for the header. See the {@link Typography.Text}\n * component for all possible levels. Default is \"h1.\"\n * @param props.icon - An optional icon to add add before the start of the header text.\n * @param props.actions - A list of actions to be rendered on the right side ofthe header.\n * If the action is a JSX element, it will be rendered directly, and if its of type\n * ButtonIconProps, a ButtonIconOnly will be rendered using the given props.\n * @param props.divided - If true, creates a divider between the start icon, header text,\n * and each action. Default is false.\n */\nexport const Header = ({\n children,\n className,\n level = \"h1\",\n divided = false,\n ...props\n}: HeaderProps): ReactElement => (\n <Context.Provider value={{ level, divided }}>\n <Align.Space\n el=\"header\"\n direction=\"x\"\n justify=\"spaceBetween\"\n className={CSS(\n CSS.B(\"header\"),\n CSS.bordered(\"bottom\"),\n divided && CSS.BM(\"header\", \"divided\"),\n className,\n )}\n {...props}\n >\n {children}\n </Align.Space>\n </Context.Provider>\n);\n"],"names":["Context","createContext","useContext","reactUseContext","Header","children","className","level","divided","props","jsx","Align.Space","CSS"],"mappings":"iJAiCMA,EAAUC,EAAAA,cAA4B,CAC1C,QAAS,GACT,MAAO,IACT,CAAC,EAEYC,EAAa,IAAoBC,EAAA,WAAgBH,CAAO,EAgBxDI,EAAS,CAAC,CACrB,SAAAC,EACA,UAAAC,EACA,MAAAC,EAAQ,KACR,QAAAC,EAAU,GACV,GAAGC,CACL,IACEC,EAAA,kBAAA,IAACV,EAAQ,SAAR,CAAiB,MAAO,CAAE,MAAAO,EAAO,QAAAC,GAChC,SAAAE,EAAA,kBAAA,IAACC,EAAM,MAAN,CACC,GAAG,SACH,UAAU,IACV,QAAQ,eACR,UAAWC,EAAA,IACTA,EAAA,IAAI,EAAE,QAAQ,EACdA,EAAA,IAAI,SAAS,QAAQ,EACrBJ,GAAWI,EAAA,IAAI,GAAG,SAAU,SAAS,EACrCN,CACF,EACC,GAAGG,EAEH,SAAAJ,CAAA,CACH,CACF,CAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { j as r } from "./jsx-runtime-NmMXPjeo.js";
|
|
2
|
+
import { C as l, h as d } from "./css-5RvvUhjr.js";
|
|
3
|
+
import { useController as j } from "react-hook-form";
|
|
4
|
+
import { S as x } from "./Center-8mBjm1cO.js";
|
|
5
|
+
import { g as h } from "./Toggle-HVxv8bv2.js";
|
|
6
|
+
import "./component-LA8IXGSG.js";
|
|
7
|
+
import "react";
|
|
8
|
+
const f = ({
|
|
9
|
+
className: e,
|
|
10
|
+
variant: t = "error",
|
|
11
|
+
...s
|
|
12
|
+
}) => /* @__PURE__ */ r.jsx(
|
|
13
|
+
h,
|
|
14
|
+
{
|
|
15
|
+
className: l(
|
|
16
|
+
l.B("input-help-text"),
|
|
17
|
+
l.BM("input-help-text", t),
|
|
18
|
+
e
|
|
19
|
+
),
|
|
20
|
+
level: "small",
|
|
21
|
+
...s
|
|
22
|
+
}
|
|
23
|
+
), g = ({ className: e, ...t }) => /* @__PURE__ */ r.jsx("label", { className: l(l.B("input-label"), e), ...t }), C = (e) => e.replace(/([A-Z])/g, " $1").replace(/^./, (t) => t.toUpperCase()), S = (e, t = "x") => e ?? (d.construct(t) === "y" ? "stretch" : "center"), y = ({
|
|
24
|
+
label: e,
|
|
25
|
+
showLabel: t = !0,
|
|
26
|
+
helpText: s,
|
|
27
|
+
direction: a = "y",
|
|
28
|
+
className: u,
|
|
29
|
+
children: n,
|
|
30
|
+
align: c,
|
|
31
|
+
size: m = "small",
|
|
32
|
+
...o
|
|
33
|
+
}) => {
|
|
34
|
+
let i;
|
|
35
|
+
return a === "x" ? i = /* @__PURE__ */ r.jsxs(x, { direction: "y", size: "small", children: [
|
|
36
|
+
n,
|
|
37
|
+
s != null && /* @__PURE__ */ r.jsx(f, { children: s })
|
|
38
|
+
] }) : i = /* @__PURE__ */ r.jsxs(r.Fragment, { children: [
|
|
39
|
+
n,
|
|
40
|
+
s != null && /* @__PURE__ */ r.jsx(f, { children: s })
|
|
41
|
+
] }), /* @__PURE__ */ r.jsxs(
|
|
42
|
+
x,
|
|
43
|
+
{
|
|
44
|
+
className: l(l.B("input-item"), u),
|
|
45
|
+
direction: a,
|
|
46
|
+
size: m,
|
|
47
|
+
align: S(c, a),
|
|
48
|
+
...o,
|
|
49
|
+
children: [
|
|
50
|
+
t && /* @__PURE__ */ r.jsx(g, { children: e }),
|
|
51
|
+
i
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}, L = ({
|
|
56
|
+
name: e,
|
|
57
|
+
rules: t,
|
|
58
|
+
control: s,
|
|
59
|
+
shouldUnregister: a,
|
|
60
|
+
defaultValue: u,
|
|
61
|
+
label: n,
|
|
62
|
+
children: c,
|
|
63
|
+
...m
|
|
64
|
+
}) => {
|
|
65
|
+
var p;
|
|
66
|
+
const { field: o, fieldState: i } = j({
|
|
67
|
+
control: s,
|
|
68
|
+
rules: t,
|
|
69
|
+
name: e,
|
|
70
|
+
shouldUnregister: a
|
|
71
|
+
});
|
|
72
|
+
return n == null && (n = C(e)), /* @__PURE__ */ r.jsx(y, { ref: o.ref, label: n, helpText: (p = i.error) == null ? void 0 : p.message, ...m, children: c({ value: o.value, onChange: o.onChange }) });
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
f as H,
|
|
76
|
+
y as I,
|
|
77
|
+
g as L,
|
|
78
|
+
L as a
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=Item--h4UWJZo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item
|
|
1
|
+
{"version":3,"file":"Item--h4UWJZo.js","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":";;;;;;;AAiCO,MAAMA,IAAW,CAAC;AAAA,EACvB,WAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,GAAGC;AACL,MACEC,gBAAAA,EAAA;AAAA,EAACC;AAAAA,EAAA;AAAA,IACC,WAAWC;AAAA,MACTA,EAAI,EAAE,iBAAiB;AAAA,MACvBA,EAAI,GAAG,mBAAmBJ,CAAO;AAAA,MACjCD;AAAA,IACF;AAAA,IACA,OAAM;AAAA,IACL,GAAGE;AAAA,EAAA;AACN,GCnBWI,IAAQ,CAAC,EAAE,WAAAN,GAAW,GAAGE,QAC7BC,gBAAAA,EAAA,IAAC,SAAM,EAAA,WAAWE,EAAIA,EAAI,EAAE,aAAa,GAAGL,CAAS,GAAI,GAAGE,EAAO,CAAA,GCnB/DK,IAAe,CAACC,MAC3BA,EAAI,QAAQ,YAAY,KAAK,EAAE,QAAQ,MAAM,CAACA,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,QAAM,EAAE,OAAA2B,GAAO,YAAAC,EAAW,IAAIC,EAAwB;AAAA,IACpD,SAAAL;AAAA,IACA,OAAAD;AAAA,IACA,MAAAD;AAAA,IACA,kBAAAG;AAAA,EAAA,CACD;AACD,SAAIb,KAAS,SAAMA,IAAQP,EAAaiB,CAAI,IAE1CrB,gBAAAA,MAACU,KAAK,KAAKgB,EAAM,KAAK,OAAAf,GAAc,WAAUkB,IAAAF,EAAW,UAAX,gBAAAE,EAAkB,SAAU,GAAG9B,GAC1E,UAAAe,EAAS,EAAE,OAAOY,EAAM,OAAO,UAAUA,EAAM,SAAU,CAAA,EAC5D,CAAA;AAEJ;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const d=require("./jsx-runtime-evvPGacs.cjs"),C=require("react"),t=require("./css-s9KpanYu.cjs"),S=require("./Toggle-QnKinMl4.cjs"),v=require("./Link-16dbGK7G.cjs"),p={visible:!1,keys:[],xy:t.xy.ZERO},f=t.CSS.BM("context","selected"),M=t.CSS.BE("context","target"),I=t.CSS.BE("menu-context","container"),b=s=>{let e=s;for(;e!=null&&!e.classList.contains(M);){if(e.classList.contains(I))return s;e=e.parentElement}return e},_=s=>{var r;const e=b(s),c=((r=e.parentElement)==null?void 0:r.querySelectorAll(`.${f}`))??[];return[e,...Array.from(c)]},q=()=>{const s=C.useRef(null),[e,c]=C.useState(p),r=(n,o)=>{const l=t.xy.construct(n);"preventDefault"in n?(n.preventDefault(),n.stopPropagation(),o=o??t.unique(_(n.target).map(a=>a.id))):o=[],c({visible:!0,keys:o,xy:l})},u=n=>{s.current=n,n!=null&&c(o=>{if(o.visible){const[l,a]=t.box$1.positionSoVisible(n,window.document.documentElement);if(a)return{...o,xy:t.box$1.topLeft(l)}}return o})},i=()=>c(p);return S.useClickOutside(s,i),{...e,close:i,open:r,ref:u}},A=({children:s,menu:e,visible:c,open:r,close:u,xy:i,keys:n,className:o,...l},a)=>{const x=c?e==null?void 0:e({keys:n}):null;return d.jsxRuntimeExports.jsxs("div",{className:t.CSS(I,o,t.CSS.inheritDims()),onContextMenu:r,...l,children:[s,x!=null&&d.jsxRuntimeExports.jsx("div",{className:t.CSS(t.CSS.B("menu-context"),t.CSS.bordered()),ref:a,style:{left:i.x,top:i.y},onClick:u,children:x})]})},N=C.forwardRef(A);N.displayName="ContextMenu";const m=C.createContext({onClick:()=>{},selected:""}),R=()=>C.useContext(m),B=({children:s,onChange:e,level:c,iconSpacing:r,value:u=""})=>{const i=n=>e==null?void 0:e(n);return d.jsxRuntimeExports.jsx(m.Provider,{value:{onClick:i,selected:u,level:c,iconSpacing:r},children:s})},E=(s,e)=>c=>{const{itemKey:r,className:u,onClick:i,size:n,...o}={...e,...c},{onClick:l,selected:a,level:x,iconSpacing:y}=R(),L=j=>{l(r),i==null||i(j)},O=a===r;return d.jsxRuntimeExports.jsx(s,{level:x,...o,onClick:L,variant:"text",className:t.CSS(t.CSS.B("menu-item"),t.CSS.selected(O),u),size:n??y})},k=E(S.Button,{noWrap:!0}),h=E(S.Icon),D=E(v.Link,{noWrap:!0}),T=k;T.Icon=h;T.Link=D;exports.CONTEXT_SELECTED=f;exports.CONTEXT_TARGET=M;exports.ContextMenu=N;exports.CoreItem=k;exports.Item=T;exports.Menu=B;exports.MenuContext=m;exports.useContextMenu=q;exports.useMenuContext=R;
|
|
2
|
+
//# sourceMappingURL=Item-EBiM5yGJ.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item-HWzX7RK2.cjs","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":["xy","CSS","useRef","useState","unique","box","useClickOutside","jsxs","jsx","forwardRef","createContext","useContext","Button.Button","Button.Icon","Button.Link"],"mappings":";;;;;;AAsDA,MAAM,gBAAkC;AAAA,EACtC,SAAS;AAAA,EACT,MAAM,CAAC;AAAA,EACP,IAAIA,IAAG,GAAA;AACT;AAEO,MAAM,mBAAmBC,IAAA,IAAI,GAAG,WAAW,UAAU;AACrD,MAAM,iBAAiBA,IAAA,IAAI,GAAG,WAAW,QAAQ;AACxD,MAAM,yBAAyBA,IAAAA,IAAI,GAAG,gBAAgB,WAAW;AAEjE,MAAM,aAAa,CAAC,WAAqC;AACvD,MAAI,YAAY;AAChB,SAAO,aAAa,QAAQ,CAAC,UAAU,UAAU,SAAS,cAAc,GAAG;AACrE,QAAA,UAAU,UAAU,SAAS,sBAAsB;AAAU,aAAA;AACjE,gBAAY,UAAU;AAAA,EACxB;AACO,SAAA;AACT;AAEA,MAAM,eAAe,CAAC,YAAwC;;AACtD,QAAA,SAAS,WAAW,OAAO;AAC3B,QAAA,aAAY,YAAO,kBAAP,mBAAsB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6C,CAAC,MAAM;AACxD,iBAAW,OAAO;AAClB,yCAAU;AAAA,IAAC;AAEb,UAAM,YAAY,aAAa;AAC/B;AAAA;AAAA,MAEEA,2BAAA,kBAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACC,GAAG;AAAA,UACJ,SAAS;AAAA,UACT,SAAQ;AAAA,UACR,WAAWP,IAAAA,IAAIA,IAAA,IAAI,EAAE,WAAW,GAAGA,IAAAA,IAAI,SAAS,SAAS,GAAG,SAAS;AAAA,UACrE,MAAM,QAAQ;AAAA,QAAA;AAAA,MAChB;AAAA;AAAA,EAEJ;AAAA;AAKK,MAAM,WAAW,gBAAgBW,OAAAA,QAAe,EAAE,QAAQ,MAAM;AAKvE,MAAM,WAAW,gBAAgBC,OAAAA,IAAW;AAE5C,MAAM,WAAW,gBAAgBC,WAAa,EAAE,QAAQ,KAAM,CAAA;AAoBvD,MAAM,OAAO;AACpB,KAAK,OAAO;AACZ,KAAK,OAAO;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Item-EBiM5yGJ.cjs","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","e","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","_selected","CoreItem","Button.Button","ItemIcon","Button.Icon","ItemLink","Button.Link","Item"],"mappings":"kLAsDMA,EAAkC,CACtC,QAAS,GACT,KAAM,CAAC,EACP,GAAIC,EAAG,GAAA,IACT,EAEaC,EAAmBC,EAAA,IAAI,GAAG,UAAW,UAAU,EAC/CC,EAAiBD,EAAA,IAAI,GAAG,UAAW,QAAQ,EAClDE,EAAyBF,EAAAA,IAAI,GAAG,eAAgB,WAAW,EAE3DG,EAAcC,GAAqC,CACvD,IAAIC,EAAYD,EAChB,KAAOC,GAAa,MAAQ,CAACA,EAAU,UAAU,SAASJ,CAAc,GAAG,CACrE,GAAAI,EAAU,UAAU,SAASH,CAAsB,EAAU,OAAAE,EACjEC,EAAYA,EAAU,aACxB,CACO,OAAAA,CACT,EAEMC,EAAgBC,GAAwC,OACtD,MAAAH,EAASD,EAAWI,CAAO,EAC3BC,IAAYC,EAAAL,EAAO,gBA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ACJ,QAASR,EACT,QAAQ,OACR,UAAWpD,EAAAA,IAAIA,EAAA,IAAI,EAAE,WAAW,EAAGA,EAAAA,IAAI,SAAS8D,CAAS,EAAG3B,CAAS,EACrE,KAAMwB,GAAQT,CAAA,CAChB,CAEJ,EAKWa,EAAWT,EAAgBU,EAAAA,OAAe,CAAE,OAAQ,GAAM,EAKjEC,EAAWX,EAAgBY,EAAAA,IAAW,EAEtCC,EAAWb,EAAgBc,OAAa,CAAE,OAAQ,EAAM,CAAA,EAoBjDC,EAAON,EACpBM,EAAK,KAAOJ,EACZI,EAAK,KAAOF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const r=require("./jsx-runtime-evvPGacs.cjs"),n=require("./css-s9KpanYu.cjs"),C=require("react-hook-form"),j=require("./Center-ER_owvfX.cjs"),R=require("./Toggle-QnKinMl4.cjs");require("./component-dgLAEMbt.cjs");require("react");const a=({className:e,variant:t="error",...s})=>r.jsxRuntimeExports.jsx(R.Text,{className:n.CSS(n.CSS.B("input-help-text"),n.CSS.BM("input-help-text",t),e),level:"small",...s}),S=({className:e,...t})=>r.jsxRuntimeExports.jsx("label",{className:n.CSS(n.CSS.B("input-label"),e),...t}),E=e=>e.replace(/([A-Z])/g," $1").replace(/^./,t=>t.toUpperCase()),f=(e,t="x")=>e??(n.direction$1.construct(t)==="y"?"stretch":"center"),d=({label:e,showLabel:t=!0,helpText:s,direction:i="y",className:m,children:l,align:c,size:x="small",...o})=>{let u;return i==="x"?u=r.jsxRuntimeExports.jsxs(j.Space,{direction:"y",size:"small",children:[l,s!=null&&r.jsxRuntimeExports.jsx(a,{children:s})]}):u=r.jsxRuntimeExports.jsxs(r.jsxRuntimeExports.Fragment,{children:[l,s!=null&&r.jsxRuntimeExports.jsx(a,{children:s})]}),r.jsxRuntimeExports.jsxs(j.Space,{className:n.CSS(n.CSS.B("input-item"),m),direction:i,size:x,align:f(c,i),...o,children:[t&&r.jsxRuntimeExports.jsx(S,{children:e}),u]})},h=({name:e,rules:t,control:s,shouldUnregister:i,defaultValue:m,label:l,children:c,...x})=>{var p;const{field:o,fieldState:u}=C.useController({control:s,rules:t,name:e,shouldUnregister:i});return l==null&&(l=E(e)),r.jsxRuntimeExports.jsx(d,{ref:o.ref,label:l,helpText:(p=u.error)==null?void 0:p.message,...x,children:c({value:o.value,onChange:o.onChange})})};exports.HelpText=a;exports.Item=d;exports.ItemControlled=h;exports.Label=S;
|
|
2
|
+
//# sourceMappingURL=Item-_og4CdwZ.cjs.map
|