@synnaxlabs/pluto 0.21.7 → 0.21.9

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.
Files changed (147) hide show
  1. package/dist/{Center-hbwH7rg9.js → Center-BK9Rcaa0.js} +2 -2
  2. package/dist/{Center-hbwH7rg9.js.map → Center-BK9Rcaa0.js.map} +1 -1
  3. package/dist/{Center-5NJ61qfA.cjs → Center-Cc_rR5pQ.cjs} +2 -2
  4. package/dist/{Center-5NJ61qfA.cjs.map → Center-Cc_rR5pQ.cjs.map} +1 -1
  5. package/dist/{Keyboard-DaFraUsQ.cjs → Keyboard-Byx8rGZt.cjs} +3 -3
  6. package/dist/{Keyboard-DaFraUsQ.cjs.map → Keyboard-Byx8rGZt.cjs.map} +1 -1
  7. package/dist/{Keyboard-nDIAR7Rj.js → Keyboard-D31SwhYT.js} +3 -3
  8. package/dist/{Keyboard-nDIAR7Rj.js.map → Keyboard-D31SwhYT.js.map} +1 -1
  9. package/dist/{LinePlot-BZDm4uxJ.cjs → LinePlot-Bnb8Ufob.cjs} +96 -65
  10. package/dist/LinePlot-Bnb8Ufob.cjs.map +1 -0
  11. package/dist/{LinePlot-tOiSUMjC.js → LinePlot-KYwy1D7H.js} +281 -250
  12. package/dist/LinePlot-KYwy1D7H.js.map +1 -0
  13. package/dist/{Link-BdWFvK8v.cjs → Link-Bq38h1dw.cjs} +2 -2
  14. package/dist/{Link-BdWFvK8v.cjs.map → Link-Bq38h1dw.cjs.map} +1 -1
  15. package/dist/{Link-d3CXVSaO.js → Link-DQKdkwWL.js} +2 -2
  16. package/dist/{Link-d3CXVSaO.js.map → Link-DQKdkwWL.js.map} +1 -1
  17. package/dist/{List-DcsWFiLT.js → List-BmP_se57.js} +3 -3
  18. package/dist/{List-DcsWFiLT.js.map → List-BmP_se57.js.map} +1 -1
  19. package/dist/{List-PlMTfEHi.cjs → List-BnB-C5vQ.cjs} +3 -3
  20. package/dist/{List-PlMTfEHi.cjs.map → List-BnB-C5vQ.cjs.map} +1 -1
  21. package/dist/{Toggle-C6Z8WPT3.cjs → Toggle-D3iCEbO1.cjs} +46 -46
  22. package/dist/{Toggle-C6Z8WPT3.cjs.map → Toggle-D3iCEbO1.cjs.map} +1 -1
  23. package/dist/{Toggle-DGLgYCOX.js → Toggle-bT5RpwfA.js} +399 -399
  24. package/dist/{Toggle-DGLgYCOX.js.map → Toggle-bT5RpwfA.js.map} +1 -1
  25. package/dist/Video-B4sma9fk.cjs +14 -0
  26. package/dist/Video-B4sma9fk.cjs.map +1 -0
  27. package/dist/Video-Cp6XjjOK.js +15 -0
  28. package/dist/Video-Cp6XjjOK.js.map +1 -0
  29. package/dist/{aggregator-BgImZc4o.js → aggregator-B8fg7W2s.js} +106 -106
  30. package/dist/aggregator-B8fg7W2s.js.map +1 -0
  31. package/dist/{aggregator-BpfMBUD1.cjs → aggregator-Bh2Kyzkg.cjs} +100 -100
  32. package/dist/aggregator-Bh2Kyzkg.cjs.map +1 -0
  33. package/dist/align.cjs +1 -1
  34. package/dist/align.js +1 -1
  35. package/dist/button.cjs +1 -1
  36. package/dist/button.js +1 -1
  37. package/dist/{color-DV-YGUvp.js → color-CjdRh-aN.js} +2 -2
  38. package/dist/{color-DV-YGUvp.js.map → color-CjdRh-aN.js.map} +1 -1
  39. package/dist/{color-BVVyrgRF.cjs → color-DBNbbjJy.cjs} +2 -2
  40. package/dist/{color-BVVyrgRF.cjs.map → color-DBNbbjJy.cjs.map} +1 -1
  41. package/dist/color.cjs +1 -1
  42. package/dist/color.js +1 -1
  43. package/dist/{css-Pf9qxhQ4.cjs → css-Ci8WUD5E.cjs} +112 -108
  44. package/dist/css-Ci8WUD5E.cjs.map +1 -0
  45. package/dist/{css-DoalWJF6.js → css-DKKmdhSr.js} +114 -110
  46. package/dist/css-DKKmdhSr.js.map +1 -0
  47. package/dist/css.cjs +2 -2
  48. package/dist/css.js +2 -2
  49. package/dist/dropdown.cjs +1 -1
  50. package/dist/dropdown.js +1 -1
  51. package/dist/ether.cjs +3 -3
  52. package/dist/ether.js +5 -5
  53. package/dist/{external-Cu6T11fi.cjs → external-9_cqFQy3.cjs} +6 -6
  54. package/dist/{external-Cu6T11fi.cjs.map → external-9_cqFQy3.cjs.map} +1 -1
  55. package/dist/{external-Blx0rtt2.cjs → external-B-zN2e5z.cjs} +6 -6
  56. package/dist/{external-Blx0rtt2.cjs.map → external-B-zN2e5z.cjs.map} +1 -1
  57. package/dist/{external-DeheWVb-.js → external-BM82B8W2.js} +6 -6
  58. package/dist/{external-DeheWVb-.js.map → external-BM82B8W2.js.map} +1 -1
  59. package/dist/{external-96EinZfY.js → external-BYqTC99W.js} +3 -3
  60. package/dist/external-BYqTC99W.js.map +1 -0
  61. package/dist/{external-5przQjJD.js → external-BfZYUV3z.js} +11 -11
  62. package/dist/{external-5przQjJD.js.map → external-BfZYUV3z.js.map} +1 -1
  63. package/dist/{external-SxB9IH0p.js → external-BpqCp_M1.js} +2 -2
  64. package/dist/external-BpqCp_M1.js.map +1 -0
  65. package/dist/{external-C6GmnG49.js → external-BrW40HJx.js} +6 -6
  66. package/dist/{external-C6GmnG49.js.map → external-BrW40HJx.js.map} +1 -1
  67. package/dist/{external-1osPryUV.js → external-CAOQcoqL.js} +5 -5
  68. package/dist/{external-1osPryUV.js.map → external-CAOQcoqL.js.map} +1 -1
  69. package/dist/{external-D8dWmF4U.cjs → external-CIVsFXOp.cjs} +2 -2
  70. package/dist/external-CIVsFXOp.cjs.map +1 -0
  71. package/dist/{external-BAdU6u03.js → external-CnNdgPsB.js} +5 -5
  72. package/dist/{external-BAdU6u03.js.map → external-CnNdgPsB.js.map} +1 -1
  73. package/dist/{external-DiFhWWS-.js → external-CwjCCHPi.js} +7 -7
  74. package/dist/{external-DiFhWWS-.js.map → external-CwjCCHPi.js.map} +1 -1
  75. package/dist/{external-DarqsFzT.js → external-DNHMAfGi.js} +5 -5
  76. package/dist/{external-DarqsFzT.js.map → external-DNHMAfGi.js.map} +1 -1
  77. package/dist/{external-0PM7JrzG.cjs → external-DVQ2SRoH.cjs} +5 -5
  78. package/dist/{external-0PM7JrzG.cjs.map → external-DVQ2SRoH.cjs.map} +1 -1
  79. package/dist/{external-16K8slq8.cjs → external-D_yXh8rn.cjs} +11 -11
  80. package/dist/{external-16K8slq8.cjs.map → external-D_yXh8rn.cjs.map} +1 -1
  81. package/dist/{external-CPx8XA9-.cjs → external-Df0D1YYb.cjs} +7 -7
  82. package/dist/{external-CPx8XA9-.cjs.map → external-Df0D1YYb.cjs.map} +1 -1
  83. package/dist/{external-DvGqQHd8.cjs → external-DhPBdJpR.cjs} +3 -3
  84. package/dist/external-DhPBdJpR.cjs.map +1 -0
  85. package/dist/{external-D7XrxOVE.cjs → external-DhiN6pEk.cjs} +4 -4
  86. package/dist/{external-D7XrxOVE.cjs.map → external-DhiN6pEk.cjs.map} +1 -1
  87. package/dist/{external-CsO29OsF.cjs → external-DjYXzP7v.cjs} +7 -7
  88. package/dist/{external-CsO29OsF.cjs.map → external-DjYXzP7v.cjs.map} +1 -1
  89. package/dist/{external-B3ly2-jy.js → external-FWIwgLzc.js} +7 -7
  90. package/dist/{external-B3ly2-jy.js.map → external-FWIwgLzc.js.map} +1 -1
  91. package/dist/{external-B0z7uXZV.cjs → external-Iv2mRce8.cjs} +5 -5
  92. package/dist/{external-B0z7uXZV.cjs.map → external-Iv2mRce8.cjs.map} +1 -1
  93. package/dist/{external-CzJYG1hX.cjs → external-P6zP6dBA.cjs} +3 -3
  94. package/dist/external-P6zP6dBA.cjs.map +1 -0
  95. package/dist/{external-D4ur_D1S.cjs → external-d-vI8EHK.cjs} +5 -5
  96. package/dist/{external-D4ur_D1S.cjs.map → external-d-vI8EHK.cjs.map} +1 -1
  97. package/dist/{external-DQkw1ko0.js → external-giUMrk8w.js} +4 -4
  98. package/dist/{external-DQkw1ko0.js.map → external-giUMrk8w.js.map} +1 -1
  99. package/dist/{external-CgMwmBnF.js → external-zG96smqq.js} +3 -3
  100. package/dist/external-zG96smqq.js.map +1 -0
  101. package/dist/header.cjs +1 -1
  102. package/dist/header.js +1 -1
  103. package/dist/index.cjs +30 -30
  104. package/dist/index.js +55 -55
  105. package/dist/index.js.map +1 -1
  106. package/dist/input.cjs +1 -1
  107. package/dist/input.js +1 -1
  108. package/dist/list.cjs +1 -1
  109. package/dist/list.js +1 -1
  110. package/dist/menu.cjs +1 -1
  111. package/dist/menu.js +1 -1
  112. package/dist/src/telem/client/cache/cache.d.ts +3 -8
  113. package/dist/src/telem/client/cache/cache.d.ts.map +1 -1
  114. package/dist/src/telem/client/cache/dynamic.d.ts +13 -3
  115. package/dist/src/telem/client/cache/dynamic.d.ts.map +1 -1
  116. package/dist/src/telem/client/client.d.ts +1 -1
  117. package/dist/src/video/Video.d.ts +2 -2
  118. package/dist/src/video/Video.d.ts.map +1 -1
  119. package/dist/tabs.cjs +1 -1
  120. package/dist/tabs.js +1 -1
  121. package/dist/text.cjs +2 -2
  122. package/dist/text.js +2 -2
  123. package/dist/theming.cjs +2 -2
  124. package/dist/theming.js +2 -2
  125. package/dist/tree.cjs +1 -1
  126. package/dist/tree.js +1 -1
  127. package/dist/triggers.cjs +1 -1
  128. package/dist/triggers.js +1 -1
  129. package/dist/video.cjs +1 -1
  130. package/dist/video.js +1 -1
  131. package/package.json +1 -1
  132. package/dist/LinePlot-BZDm4uxJ.cjs.map +0 -1
  133. package/dist/LinePlot-tOiSUMjC.js.map +0 -1
  134. package/dist/Video-B1oW8NLd.js +0 -11
  135. package/dist/Video-B1oW8NLd.js.map +0 -1
  136. package/dist/Video-BGNx94bQ.cjs +0 -10
  137. package/dist/Video-BGNx94bQ.cjs.map +0 -1
  138. package/dist/aggregator-BgImZc4o.js.map +0 -1
  139. package/dist/aggregator-BpfMBUD1.cjs.map +0 -1
  140. package/dist/css-DoalWJF6.js.map +0 -1
  141. package/dist/css-Pf9qxhQ4.cjs.map +0 -1
  142. package/dist/external-96EinZfY.js.map +0 -1
  143. package/dist/external-CgMwmBnF.js.map +0 -1
  144. package/dist/external-CzJYG1hX.cjs.map +0 -1
  145. package/dist/external-D8dWmF4U.cjs.map +0 -1
  146. package/dist/external-DvGqQHd8.cjs.map +0 -1
  147. package/dist/external-SxB9IH0p.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"external-BAdU6u03.js","sources":["../src/header/Header.tsx","../src/header/Actions.tsx","../src/header/ButtonTitle.tsx","../src/header/Title.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","// 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 { Fragment, isValidElement, type ReactElement } from \"react\";\n\nimport { toArray } from \"@synnaxlabs/x\";\n\nimport { Align } from \"@/align\";\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { Divider } from \"@/divider\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport type ActionSpec = Button.IconProps | ReactElement;\n\nexport interface ActionsProps {\n children?: ActionSpec | ActionSpec[];\n}\n\n/**\n * Custom actions to render on the right side of the header.\n *\n * @param children - The actions to render. If the action is of type\n * {@link ButtonIconProps}, a correectly sized {@link ButtonIconOnly} is rendered\n * using the given props. If the action is a JSX element, it is renderered directly.\n * It's a good idea to prefer the latter in almost all cases for simplicity.\n */\nexport const Actions = ({ children = [] }: ActionsProps): ReactElement => {\n const { level, divided } = useContext();\n return (\n <Align.Space\n direction=\"x\"\n size=\"small\"\n align=\"center\"\n className={CSS.BE(\"header\", \"actions\")}\n >\n {toArray(children).map((action, i) => (\n <Action key={i} index={i} level={level} divided={divided}>\n {action}\n </Action>\n ))}\n </Align.Space>\n );\n};\n\ninterface ActionProps {\n index: number;\n level: Text.Level;\n children: ReactElement | Button.IconProps;\n divided: boolean;\n}\n\nconst Action = ({ index, level, children, divided }: ActionProps): ReactElement => {\n let content: ReactElement = children as ReactElement;\n if (!isValidElement(children)) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const props = children as Button.IconProps;\n content = (\n <Button.Icon\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.onClick?.(e);\n }}\n key={index}\n size={Text.LevelComponentSizes[level]}\n {...props}\n />\n );\n }\n return (\n <Fragment key={index}>\n {divided && <Divider.Divider />}\n {content}\n </Fragment>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport interface ButtonTitleProps\n extends Omit<Button.ButtonProps, \"variant\" | \"size\"> {}\n\n/**\n * Header.Title.Use renders a clickable header title.\n *\n * @param props - The comonent props. The props for this component are identical\n * to {@link Button}, except the variant is always 'outlined' and that the component size\n * is automatically inferred from the 'level' prop passsed to the parent {@link Header}\n * component.\n */\nexport const ButtonTitle = ({\n children = \"\",\n className,\n onClick,\n ...props\n}: ButtonTitleProps): ReactElement => {\n const { level } = useContext();\n return (\n <Button.Button\n variant=\"text\"\n size={Text.LevelComponentSizes[level]}\n onClick={onClick}\n className={CSS(CSS.B(\"header-button-title\"), className)}\n sharp\n {...props}\n >\n {children}\n </Button.Button>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { CSS } from \"@/css\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport interface TitleProps extends Omit<Text.WithIconProps, \"divided\" | \"level\"> {\n level?: Text.Level;\n}\n\n/**\n * Renders the title for the header component.\n *\n * @param props - The component props. The props for this component are identical\n * to the {@link Typography.TextWithIcon} component, except that the 'level', and\n * 'divider' props are inherited from the parent {@link Header} component.\n */\nexport const Title = ({\n className,\n level: propsLevel,\n ...props\n}: TitleProps): ReactElement => {\n const { level, divided } = useContext();\n return (\n <Text.WithIcon\n className={CSS(CSS.BE(\"header\", \"text\"), className)}\n level={propsLevel ?? level}\n divided={divided}\n size={1.5}\n {...props}\n />\n );\n};\n"],"names":["reactUseContext","jsx","Align.Space","toArray","Button.Icon","Text.LevelComponentSizes","Divider.Divider","Button.Button","Text.WithIcon"],"mappings":";;;;;;AAiCA,MAAM,UAAU,cAA4B;AAAA,EAC1C,SAAS;AAAA,EACT,OAAO;AACT,CAAC;AAEY,MAAA,aAAa,MAAoBA,aAAgB,OAAO;AAgB9D,MAAM,SAAS,CAAC;AAAA,EACrB;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,GAAG;AACL,MACEC,kCAAA,IAAC,QAAQ,UAAR,EAAiB,OAAO,EAAE,OAAO,WAChC,UAAAA,kCAAA;AAAA,EAACC;AAAAA,EAAA;AAAA,IACC,IAAG;AAAA,IACH,WAAU;AAAA,IACV,SAAQ;AAAA,IACR,WAAW;AAAA,MACT,IAAI,EAAE,QAAQ;AAAA,MACd,IAAI,SAAS,QAAQ;AAAA,MACrB,WAAW,IAAI,GAAG,UAAU,SAAS;AAAA,MACrC;AAAA,IACF;AAAA,IACC,GAAG;AAAA,IAEH;AAAA,EAAA;AACH,EACF,CAAA;AC1CK,MAAM,UAAU,CAAC,EAAE,WAAW,CAAA,QAAqC;AACxE,QAAM,EAAE,OAAO,QAAQ,IAAI,WAAW;AAEpC,SAAAD,kCAAA;AAAA,IAACC;AAAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,MAAK;AAAA,MACL,OAAM;AAAA,MACN,WAAW,IAAI,GAAG,UAAU,SAAS;AAAA,MAEpC,UAAQC,EAAA,QAAQ,EAAE,IAAI,CAAC,QAAQ,MAC7BF,sCAAA,QAAA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rB;AAAA,MACA,MAAM;AAAA,MACL,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;;;;;;;;;"}
1
+ {"version":3,"file":"external-CnNdgPsB.js","sources":["../src/header/Header.tsx","../src/header/Actions.tsx","../src/header/ButtonTitle.tsx","../src/header/Title.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","// 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 { Fragment, isValidElement, type ReactElement } from \"react\";\n\nimport { toArray } from \"@synnaxlabs/x\";\n\nimport { Align } from \"@/align\";\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { Divider } from \"@/divider\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport type ActionSpec = Button.IconProps | ReactElement;\n\nexport interface ActionsProps {\n children?: ActionSpec | ActionSpec[];\n}\n\n/**\n * Custom actions to render on the right side of the header.\n *\n * @param children - The actions to render. If the action is of type\n * {@link ButtonIconProps}, a correectly sized {@link ButtonIconOnly} is rendered\n * using the given props. If the action is a JSX element, it is renderered directly.\n * It's a good idea to prefer the latter in almost all cases for simplicity.\n */\nexport const Actions = ({ children = [] }: ActionsProps): ReactElement => {\n const { level, divided } = useContext();\n return (\n <Align.Space\n direction=\"x\"\n size=\"small\"\n align=\"center\"\n className={CSS.BE(\"header\", \"actions\")}\n >\n {toArray(children).map((action, i) => (\n <Action key={i} index={i} level={level} divided={divided}>\n {action}\n </Action>\n ))}\n </Align.Space>\n );\n};\n\ninterface ActionProps {\n index: number;\n level: Text.Level;\n children: ReactElement | Button.IconProps;\n divided: boolean;\n}\n\nconst Action = ({ index, level, children, divided }: ActionProps): ReactElement => {\n let content: ReactElement = children as ReactElement;\n if (!isValidElement(children)) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const props = children as Button.IconProps;\n content = (\n <Button.Icon\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.onClick?.(e);\n }}\n key={index}\n size={Text.LevelComponentSizes[level]}\n {...props}\n />\n );\n }\n return (\n <Fragment key={index}>\n {divided && <Divider.Divider />}\n {content}\n </Fragment>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport interface ButtonTitleProps\n extends Omit<Button.ButtonProps, \"variant\" | \"size\"> {}\n\n/**\n * Header.Title.Use renders a clickable header title.\n *\n * @param props - The comonent props. The props for this component are identical\n * to {@link Button}, except the variant is always 'outlined' and that the component size\n * is automatically inferred from the 'level' prop passsed to the parent {@link Header}\n * component.\n */\nexport const ButtonTitle = ({\n children = \"\",\n className,\n onClick,\n ...props\n}: ButtonTitleProps): ReactElement => {\n const { level } = useContext();\n return (\n <Button.Button\n variant=\"text\"\n size={Text.LevelComponentSizes[level]}\n onClick={onClick}\n className={CSS(CSS.B(\"header-button-title\"), className)}\n sharp\n {...props}\n >\n {children}\n </Button.Button>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { CSS } from \"@/css\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport interface TitleProps extends Omit<Text.WithIconProps, \"divided\" | \"level\"> {\n level?: Text.Level;\n}\n\n/**\n * Renders the title for the header component.\n *\n * @param props - The component props. The props for this component are identical\n * to the {@link Typography.TextWithIcon} component, except that the 'level', and\n * 'divider' props are inherited from the parent {@link Header} component.\n */\nexport const Title = ({\n className,\n level: propsLevel,\n ...props\n}: TitleProps): ReactElement => {\n const { level, divided } = useContext();\n return (\n <Text.WithIcon\n className={CSS(CSS.BE(\"header\", \"text\"), className)}\n level={propsLevel ?? level}\n divided={divided}\n size={1.5}\n {...props}\n />\n );\n};\n"],"names":["reactUseContext","jsx","Align.Space","toArray","Button.Icon","Text.LevelComponentSizes","Divider.Divider","Button.Button","Text.WithIcon"],"mappings":";;;;;;AAiCA,MAAM,UAAU,cAA4B;AAAA,EAC1C,SAAS;AAAA,EACT,OAAO;AACT,CAAC;AAEY,MAAA,aAAa,MAAoBA,aAAgB,OAAO;AAgB9D,MAAM,SAAS,CAAC;AAAA,EACrB;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,GAAG;AACL,MACEC,kCAAA,IAAC,QAAQ,UAAR,EAAiB,OAAO,EAAE,OAAO,WAChC,UAAAA,kCAAA;AAAA,EAACC;AAAAA,EAAA;AAAA,IACC,IAAG;AAAA,IACH,WAAU;AAAA,IACV,SAAQ;AAAA,IACR,WAAW;AAAA,MACT,IAAI,EAAE,QAAQ;AAAA,MACd,IAAI,SAAS,QAAQ;AAAA,MACrB,WAAW,IAAI,GAAG,UAAU,SAAS;AAAA,MACrC;AAAA,IACF;AAAA,IACC,GAAG;AAAA,IAEH;AAAA,EAAA;AACH,EACF,CAAA;AC1CK,MAAM,UAAU,CAAC,EAAE,WAAW,CAAA,QAAqC;AACxE,QAAM,EAAE,OAAO,QAAQ,IAAI,WAAW;AAEpC,SAAAD,kCAAA;AAAA,IAACC;AAAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,MAAK;AAAA,MACL,OAAM;AAAA,MACN,WAAW,IAAI,GAAG,UAAU,SAAS;AAAA,MAEpC,UAAQC,EAAA,QAAQ,EAAE,IAAI,CAAC,QAAQ,MAC7BF,sCAAA,QAAA,EAAe,OAAO,GAAG,OAAc,SACrC,UAAA,OAAA,GADU,CAEb,CACD;AAAA,IAAA;A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;;;;"}
@@ -1,11 +1,11 @@
1
1
  import { j as jsxRuntimeExports } from "./jsx-runtime-mMz73N64.js";
2
2
  import { memo, useState, useCallback, useMemo } from "react";
3
- import { p as m0, v as useSelectionUtils, w as useDataUtilContext, m as useDragAndDrop, q as CONTEXT_TARGET, C as CONTEXT_SELECTED, M as MaybeEditable, x as useCombinedStateAndRef, o as useSyncedRef, y as useHeldRef, B as Button, z as Core, A as Selector, F as edit, G as componentRenderProp } from "./Toggle-DGLgYCOX.js";
4
- import { L as Link } from "./Link-d3CXVSaO.js";
5
- import { C as CSS } from "./css-DoalWJF6.js";
6
- import { A, i as usePassthrough } from "./aggregator-BgImZc4o.js";
7
- import "./Center-hbwH7rg9.js";
8
- import { L as List } from "./List-DcsWFiLT.js";
3
+ import { p as m0, v as useSelectionUtils, w as useDataUtilContext, m as useDragAndDrop, q as CONTEXT_TARGET, C as CONTEXT_SELECTED, M as MaybeEditable, x as useCombinedStateAndRef, o as useSyncedRef, y as useHeldRef, B as Button, z as Core, A as Selector, F as edit, G as componentRenderProp } from "./Toggle-bT5RpwfA.js";
4
+ import { L as Link } from "./Link-DQKdkwWL.js";
5
+ import { C as CSS } from "./css-DKKmdhSr.js";
6
+ import { A, i as usePassthrough } from "./aggregator-B8fg7W2s.js";
7
+ import "./Center-BK9Rcaa0.js";
8
+ import { L as List } from "./List-BmP_se57.js";
9
9
  const shouldExpand = (node, expanded) => expanded.includes(node.key);
10
10
  const sortAndSplice = (nodes, sort) => {
11
11
  if (sort) {
@@ -369,4 +369,4 @@ const external = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProp
369
369
  export {
370
370
  external as e
371
371
  };
372
- //# sourceMappingURL=external-DiFhWWS-.js.map
372
+ //# sourceMappingURL=external-CwjCCHPi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"external-DiFhWWS-.js","sources":["../src/tree/core.ts","../src/tree/Tree.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 { toArray } from \"@synnaxlabs/x\";\n\nimport { type Haul } from \"@/haul\";\n\nexport interface Node {\n key: string;\n name: string;\n renaming?: boolean;\n forcePosition?: number;\n icon?: ReactElement;\n allowRename?: boolean;\n hasChildren?: boolean;\n children?: Node[];\n haulItems?: Haul.Item[];\n canDrop?: (items: Haul.Item[]) => boolean;\n href?: string;\n}\n\nexport interface NodeWithPosition extends Node {\n depth: number;\n position: number;\n}\n\nexport interface FlattenedNode extends Node {\n index: number;\n depth: number;\n expanded: boolean;\n}\n\nexport const shouldExpand = (node: Node, expanded: string[]): boolean =>\n expanded.includes(node.key);\n\nexport interface FlattenProps {\n nodes: Node[];\n expanded: string[];\n depth?: number;\n sort?: boolean;\n}\n\nexport const sortAndSplice = (nodes: Node[], sort: boolean): Node[] => {\n if (sort) {\n nodes.sort((a, b) => a.name.localeCompare(b.name));\n }\n let found = false;\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node.forcePosition != null && i !== node.forcePosition) {\n found = true;\n // remove the node from its current position\n nodes.splice(i, 1);\n // splice it into the forced position\n nodes.splice(node.forcePosition, 0, node);\n }\n }\n if (found) return sortAndSplice(nodes, false);\n return nodes;\n};\n\nexport const flatten = ({\n nodes,\n expanded,\n depth = 0,\n sort = true,\n}: FlattenProps): FlattenedNode[] => {\n // Sort the first level of the tree independently of the rest\n if (depth === 0 && sort) nodes = nodes.sort((a, b) => a.name.localeCompare(b.name));\n const flattened: FlattenedNode[] = [];\n nodes.forEach((node, index) => {\n const expand = shouldExpand(node, expanded);\n flattened.push({ ...node, depth, expanded: expand, index });\n if (expand && node.children != null) {\n node.children = sortAndSplice(node.children, sort);\n flattened.push(\n ...flatten({ nodes: node.children, expanded, depth: depth + 1, sort }),\n );\n }\n });\n return flattened;\n};\n\nexport interface MoveNodeProps {\n tree: Node[];\n destination: string;\n keys: string | string[];\n}\n\nexport const moveNode = ({ tree, destination, keys }: MoveNodeProps): Node[] => {\n keys = toArray(keys);\n keys.forEach((key) => {\n const node = findNode({ tree, key });\n if (node == null) return;\n removeNode({ tree, keys: key });\n setNode({ tree, destination, additions: node });\n });\n return tree;\n};\n\nexport interface RemoveNodeProps {\n tree: Node[];\n keys: string | string[];\n}\n\nexport const removeNode = ({ tree, keys }: RemoveNodeProps): Node[] => {\n keys = toArray(keys);\n const treeKeys = tree.map((node) => node.key);\n keys.forEach((key) => {\n const index = treeKeys.indexOf(key);\n if (index !== -1) tree.splice(index, 1);\n else {\n const parent = findNodeParent({ tree, key });\n if (parent != null)\n parent.children = parent.children?.filter((child) => child.key !== key);\n }\n });\n return tree;\n};\n\nexport interface SetNodeProps {\n tree: Node[];\n destination: string;\n additions: Node | Node[];\n}\n\nexport const setNode = ({ tree, destination, additions }: SetNodeProps): Node[] => {\n additions = toArray(additions);\n const node = findNode({ tree, key: destination });\n if (node == null) throw new Error(`Could not find node with key ${destination}`);\n if (node.children == null) node.children = [];\n const addedKeys = additions.map((node) => node.key);\n node.children = [\n ...additions,\n ...node.children.filter((child) => !addedKeys.includes(child.key)),\n ];\n return tree;\n};\n\nexport interface UpdateNodeProps {\n tree: Node[];\n key: string;\n updater: (node: Node) => Node;\n throwOnMissing?: boolean;\n}\n\nexport const updateNode = ({\n tree,\n key,\n updater,\n throwOnMissing = true,\n}: UpdateNodeProps): Node[] => {\n const node = findNode({ tree, key });\n if (node == null) {\n if (throwOnMissing) throw new Error(`Could not find node with key ${key}`);\n return tree;\n }\n const parent = findNodeParent({ tree, key });\n if (parent != null) {\n // splice the updated node into the parent's children\n const index = parent.children?.findIndex((child) => child.key === key);\n if (index != null && index !== -1) parent.children?.splice(index, 1, updater(node));\n } else {\n // we're in the root, so just update the node\n tree.splice(\n tree.findIndex((node) => node.key === key),\n 1,\n updater(node),\n );\n }\n return tree;\n};\n\nexport interface FindNodeProps {\n tree: Node[];\n key: string;\n depth?: number;\n}\n\nexport const findNode = ({\n tree,\n key,\n depth = 0,\n}: FindNodeProps): NodeWithPosition | null => {\n for (let i = 0; i < tree.length; i++) {\n const node = tree[i];\n if (node.key === key) {\n const n = node as NodeWithPosition;\n n.depth = depth;\n n.position = i;\n return n;\n }\n if (node.children != null) {\n const found = findNode({ tree: node.children, key, depth: depth + 1 });\n if (found != null) return found;\n }\n }\n return null;\n};\n\nexport interface FindNodesProps {\n tree: Node[];\n keys: string[];\n}\n\nexport const findNodes = ({ tree, keys }: FindNodesProps): NodeWithPosition[] => {\n const nodes: NodeWithPosition[] = [];\n for (const key of keys) {\n const node = findNode({ tree, key });\n if (node != null) nodes.push(node);\n }\n return nodes;\n};\n\nexport interface FindNodeParentProps {\n tree: Node[];\n key: string;\n}\n\nexport const findNodeParent = ({ tree, key }: FindNodeParentProps): Node | null => {\n for (const node of tree) {\n if (node.children != null) {\n if (node.children.some((child) => child.key === key)) return node;\n const found = findNodeParent({ tree: node.children, key });\n if (found != null) return found;\n }\n }\n return null;\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 {\n type ReactElement,\n useCallback,\n useMemo,\n useState,\n type FC,\n memo,\n} from \"react\";\n\nimport { Icon } from \"@synnaxlabs/media\";\n\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { Haul } from \"@/haul\";\nimport { useSyncedRef, useCombinedStateAndRef } from \"@/hooks\";\nimport { List } from \"@/list\";\nimport { type UseSelectOnChangeExtra, type UseSelectProps } from \"@/list/useSelect\";\nimport { CONTEXT_SELECTED, CONTEXT_TARGET } from \"@/menu/ContextMenu\";\nimport { state } from \"@/state\";\nimport { Text } from \"@/text\";\nimport { flatten, type Node, type FlattenedNode } from \"@/tree/core\";\nimport { Triggers } from \"@/triggers\";\nimport { type RenderProp, componentRenderProp } from \"@/util/renderProp\";\n\nimport \"@/tree/Tree.css\";\n\nexport const HAUL_TYPE = \"tree-item\";\n\nexport interface HandleExpandProps {\n current: string[];\n action: \"expand\" | \"contract\";\n clicked: string;\n}\n\nexport interface UseProps {\n onExpand?: (props: HandleExpandProps) => void;\n selected?: string[];\n onSelectedChange?: state.Set<string[]>;\n initialExpanded?: string[];\n nodes: Node[];\n sort?: boolean;\n}\n\nexport interface UseReturn {\n selected: string[];\n expanded: string[];\n onSelect: UseSelectProps<string, FlattenedNode>[\"onChange\"];\n nodes: FlattenedNode[];\n}\n\nconst SHIFT_TRIGGERS: Triggers.Trigger[] = [[\"Shift\"]];\n\nexport const use = (props: UseProps): UseReturn => {\n const {\n onExpand,\n nodes,\n initialExpanded = [],\n sort = true,\n selected: propsSelected,\n onSelectedChange,\n } = props ?? {};\n const [expanded, setExpanded, ref] =\n useCombinedStateAndRef<string[]>(initialExpanded);\n const [selected, setSelected] = state.usePassthrough<string[]>({\n initial: [],\n value: propsSelected,\n onChange: onSelectedChange,\n });\n const flat = useMemo(\n () => flatten({ nodes, expanded, sort }),\n [nodes, expanded, sort],\n );\n const flatRef = useSyncedRef(flat);\n\n const shiftRef = Triggers.useHeldRef({ triggers: SHIFT_TRIGGERS });\n\n const handleSelect: UseSelectProps<string, FlattenedNode>[\"onChange\"] = useCallback(\n (\n keys: string[],\n { clicked }: UseSelectOnChangeExtra<string, FlattenedNode>,\n ): void => {\n setSelected(keys);\n const n = flatRef.current.find((node) => node.key === clicked);\n if (n?.hasChildren === false) return;\n if (clicked == null || shiftRef.current.held) return;\n const currentlyExpanded = ref.current;\n const action = currentlyExpanded.some((key) => key === clicked)\n ? \"contract\"\n : \"expand\";\n let nextExpanded = currentlyExpanded;\n if (action === \"contract\")\n nextExpanded = currentlyExpanded.filter((key) => key !== clicked);\n else nextExpanded = [...currentlyExpanded, clicked];\n setExpanded(nextExpanded);\n onExpand?.({ current: nextExpanded, action, clicked });\n },\n [onExpand, flatRef, setExpanded, setSelected],\n );\n\n return {\n onSelect: handleSelect,\n selected,\n expanded,\n nodes: flat,\n };\n};\n\nexport interface ItemProps extends List.ItemProps<string, FlattenedNode> {\n onDrop?: (key: string, props: Haul.OnDropProps) => Haul.Item[];\n onSuccessfulDrop?: (key: string, props: Haul.OnSuccessfulDropProps) => void;\n onRename?: (key: string, name: string) => void;\n onDoubleClick?: (key: string, e: React.MouseEvent) => void;\n loading?: boolean;\n useMargin?: boolean;\n}\n\ntype TreePropsInheritedFromItem = Pick<\n ItemProps,\n \"onDrop\" | \"onRename\" | \"onSuccessfulDrop\" | \"onDoubleClick\" | \"useMargin\"\n>;\n\ntype TreePropsInheritedFromList = Omit<\n List.VirtualCoreProps<string, FlattenedNode>,\n \"onDrop\" | \"onSelect\" | \"children\" | \"onDoubleClick\" | \"itemHeight\"\n> & {\n itemHeight?: number;\n};\n\nexport interface TreeProps\n extends TreePropsInheritedFromItem,\n TreePropsInheritedFromList {\n nodes: FlattenedNode[];\n selected?: string[];\n onSelect: UseSelectProps<string, FlattenedNode>[\"onChange\"];\n children?: RenderProp<ItemProps>;\n virtual?: boolean;\n}\n\nconst expandedCaret = <Icon.Caret.Down className={CSS.B(\"caret\")} />;\nconst collapsedCaret = <Icon.Caret.Right className={CSS.B(\"caret\")} />;\n\nexport type Item = FC<ItemProps>;\n\nexport const DefaultItem = memo(\n ({\n entry,\n selected,\n onSelect,\n onDrop,\n onRename,\n onSuccessfulDrop,\n onDoubleClick,\n loading = false,\n useMargin = false,\n translate,\n }: ItemProps): ReactElement => {\n const {\n key,\n hasChildren = false,\n allowRename = false,\n children,\n icon,\n name,\n depth,\n expanded,\n href,\n haulItems = [],\n } = entry;\n\n const { getSelected } = List.useSelectionUtils<string>();\n const { getSourceData } = List.useDataUtilContext<string, FlattenedNode>();\n\n const actuallyHasChildren =\n hasChildren || (children != null && children.length > 0);\n\n // Expand, contract, and loading items.\n const startIcons: ReactElement[] = [];\n if (actuallyHasChildren) startIcons.push(expanded ? expandedCaret : collapsedCaret);\n if (icon != null) startIcons.push(icon);\n const endIcons: ReactElement[] = [];\n if (loading) endIcons.push(<Icon.Loading className={CSS.B(\"loading-indicator\")} />);\n\n const [draggingOver, setDraggingOver] = useState(false);\n\n // Drag and Drop\n const { startDrag, ...dropProps } = Haul.useDragAndDrop({\n type: \"Tree.Item\",\n key,\n canDrop: useCallback(({ items: entities, source }) => {\n const keys = entities.map((item) => item.key);\n setDraggingOver(false);\n return source.type === \"Tree.Item\" && !keys.includes(key);\n }, []),\n onDrop: useCallback((props) => onDrop?.(key, props) ?? [], [key, onDrop]),\n onDragOver: useCallback(() => setDraggingOver(true), []),\n });\n\n const handleDragStart = (): void => {\n const selectedItemKeys = getSelected();\n const selectedItems = getSourceData().filter((item) =>\n selectedItemKeys.includes(item.key),\n );\n if (selectedItemKeys.includes(key)) {\n const selectedHaulItems = selectedItems\n .map(({ key, haulItems }) => [{ type: HAUL_TYPE, key }, ...(haulItems ?? [])])\n .flat();\n return startDrag(selectedHaulItems, (props) => onSuccessfulDrop?.(key, props));\n }\n startDrag([{ type: HAUL_TYPE, key }, ...haulItems], (props) =>\n onSuccessfulDrop?.(key, props),\n );\n };\n\n const offsetKey = useMargin ? \"marginLeft\" : \"paddingLeft\";\n\n const baseProps: Button.LinkProps | Button.ButtonProps = {\n id: key,\n variant: \"text\",\n draggable: true,\n className: CSS(\n CSS.BE(\"list\", \"item\"),\n CONTEXT_TARGET,\n draggingOver && CSS.M(\"dragging-over\"),\n selected && CONTEXT_SELECTED,\n CSS.selected(selected),\n actuallyHasChildren && CSS.M(\"has-children\"),\n ),\n onDragLeave: () => setDraggingOver(false),\n onDragStart: handleDragStart,\n onClick: () => onSelect?.(key),\n style: {\n position: translate != null ? \"absolute\" : \"relative\",\n transform: `translateY(${translate}px)`,\n [offsetKey]: `${depth * 1.5 + 1}rem`,\n },\n startIcon: startIcons,\n iconSpacing: \"small\",\n noWrap: true,\n endIcon: endIcons,\n onDoubleClick: (e) => onDoubleClick?.(key, e),\n href,\n ...dropProps,\n };\n\n const Base = href != null ? Button.Link : Button.Button;\n\n return (\n <Base className={CSS.BE(\"list\", \"item\")} {...baseProps}>\n <Text.MaybeEditable\n id={`text-${key}`}\n level=\"p\"\n allowDoubleClick={false}\n value={name}\n disabled={!allowRename}\n onChange={(name) => onRename?.(key, name)}\n />\n </Base>\n );\n },\n);\nDefaultItem.displayName = \"Tree.Item\";\n\nconst defaultChild = componentRenderProp(DefaultItem);\n\nexport const Tree = ({\n nodes,\n selected = [],\n onSelect,\n onDrop,\n onRename,\n onSuccessfulDrop,\n onDoubleClick,\n className,\n children = defaultChild,\n itemHeight = 27,\n useMargin = false,\n virtual = true,\n ...props\n}: TreeProps): ReactElement => {\n const Core = virtual ? List.Core.Virtual : List.Core;\n\n return (\n <List.List<string, FlattenedNode> data={nodes}>\n <List.Selector value={selected} onChange={onSelect} allowMultiple replaceOnSingle>\n <Core<string, FlattenedNode>\n itemHeight={itemHeight}\n className={CSS(className, CSS.B(\"tree\"))}\n {...props}\n >\n {(props) =>\n children({\n ...props,\n useMargin,\n onDrop,\n onRename,\n onSuccessfulDrop,\n onDoubleClick,\n })\n }\n </Core>\n </List.Selector>\n </List.List>\n );\n};\n\nexport const startRenaming = (key: string): void => Text.edit(`text-${key}`);\n"],"names":["toArray","node","state.usePassthrough","Triggers.useHeldRef","jsx","Icon","List.useSelectionUtils","List.useDataUtilContext","Haul.useDragAndDrop","key","haulItems","Button.Link","Button.Button","Text.MaybeEditable","name","Core","List.Core","List.List","List.Selector","props","Text.edit"],"mappings":";;;;;;;;AAwCO,MAAM,eAAe,CAAC,MAAY,aACvC,SAAS,SAAS,KAAK,GAAG;AASf,MAAA,gBAAgB,CAAC,OAAe,SAA0B;AACrE,MAAI,MAAM;AACF,UAAA,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AAAA,EAC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A,QACA;AAAA,QACA;AAAA,MAAA,CACD;AAAA,IAAA;AAAA,EAAA,EAGP,CAAA,EACF,CAAA;AAEJ;AAEO,MAAM,gBAAgB,CAAC,QAAsBC,KAAU,QAAQ,GAAG,EAAE;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"external-CwjCCHPi.js","sources":["../src/tree/core.ts","../src/tree/Tree.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 { toArray } from \"@synnaxlabs/x\";\n\nimport { type Haul } from \"@/haul\";\n\nexport interface Node {\n key: string;\n name: string;\n renaming?: boolean;\n forcePosition?: number;\n icon?: ReactElement;\n allowRename?: boolean;\n hasChildren?: boolean;\n children?: Node[];\n haulItems?: Haul.Item[];\n canDrop?: (items: Haul.Item[]) => boolean;\n href?: string;\n}\n\nexport interface NodeWithPosition extends Node {\n depth: number;\n position: number;\n}\n\nexport interface FlattenedNode extends Node {\n index: number;\n depth: number;\n expanded: boolean;\n}\n\nexport const shouldExpand = (node: Node, expanded: string[]): boolean =>\n expanded.includes(node.key);\n\nexport interface FlattenProps {\n nodes: Node[];\n expanded: string[];\n depth?: number;\n sort?: boolean;\n}\n\nexport const sortAndSplice = (nodes: Node[], sort: boolean): Node[] => {\n if (sort) {\n nodes.sort((a, b) => a.name.localeCompare(b.name));\n }\n let found = false;\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node.forcePosition != null && i !== node.forcePosition) {\n found = true;\n // remove the node from its current position\n nodes.splice(i, 1);\n // splice it into the forced position\n nodes.splice(node.forcePosition, 0, node);\n }\n }\n if (found) return sortAndSplice(nodes, false);\n return nodes;\n};\n\nexport const flatten = ({\n nodes,\n expanded,\n depth = 0,\n sort = true,\n}: FlattenProps): FlattenedNode[] => {\n // Sort the first level of the tree independently of the rest\n if (depth === 0 && sort) nodes = nodes.sort((a, b) => a.name.localeCompare(b.name));\n const flattened: FlattenedNode[] = [];\n nodes.forEach((node, index) => {\n const expand = shouldExpand(node, expanded);\n flattened.push({ ...node, depth, expanded: expand, index });\n if (expand && node.children != null) {\n node.children = sortAndSplice(node.children, sort);\n flattened.push(\n ...flatten({ nodes: node.children, expanded, depth: depth + 1, sort }),\n );\n }\n });\n return flattened;\n};\n\nexport interface MoveNodeProps {\n tree: Node[];\n destination: string;\n keys: string | string[];\n}\n\nexport const moveNode = ({ tree, destination, keys }: MoveNodeProps): Node[] => {\n keys = toArray(keys);\n keys.forEach((key) => {\n const node = findNode({ tree, key });\n if (node == null) return;\n removeNode({ tree, keys: key });\n setNode({ tree, destination, additions: node });\n });\n return tree;\n};\n\nexport interface RemoveNodeProps {\n tree: Node[];\n keys: string | string[];\n}\n\nexport const removeNode = ({ tree, keys }: RemoveNodeProps): Node[] => {\n keys = toArray(keys);\n const treeKeys = tree.map((node) => node.key);\n keys.forEach((key) => {\n const index = treeKeys.indexOf(key);\n if (index !== -1) tree.splice(index, 1);\n else {\n const parent = findNodeParent({ tree, key });\n if (parent != null)\n parent.children = parent.children?.filter((child) => child.key !== key);\n }\n });\n return tree;\n};\n\nexport interface SetNodeProps {\n tree: Node[];\n destination: string;\n additions: Node | Node[];\n}\n\nexport const setNode = ({ tree, destination, additions }: SetNodeProps): Node[] => {\n additions = toArray(additions);\n const node = findNode({ tree, key: destination });\n if (node == null) throw new Error(`Could not find node with key ${destination}`);\n if (node.children == null) node.children = [];\n const addedKeys = additions.map((node) => node.key);\n node.children = [\n ...additions,\n ...node.children.filter((child) => !addedKeys.includes(child.key)),\n ];\n return tree;\n};\n\nexport interface UpdateNodeProps {\n tree: Node[];\n key: string;\n updater: (node: Node) => Node;\n throwOnMissing?: boolean;\n}\n\nexport const updateNode = ({\n tree,\n key,\n updater,\n throwOnMissing = true,\n}: UpdateNodeProps): Node[] => {\n const node = findNode({ tree, key });\n if (node == null) {\n if (throwOnMissing) throw new Error(`Could not find node with key ${key}`);\n return tree;\n }\n const parent = findNodeParent({ tree, key });\n if (parent != null) {\n // splice the updated node into the parent's children\n const index = parent.children?.findIndex((child) => child.key === key);\n if (index != null && index !== -1) parent.children?.splice(index, 1, updater(node));\n } else {\n // we're in the root, so just update the node\n tree.splice(\n tree.findIndex((node) => node.key === key),\n 1,\n updater(node),\n );\n }\n return tree;\n};\n\nexport interface FindNodeProps {\n tree: Node[];\n key: string;\n depth?: number;\n}\n\nexport const findNode = ({\n tree,\n key,\n depth = 0,\n}: FindNodeProps): NodeWithPosition | null => {\n for (let i = 0; i < tree.length; i++) {\n const node = tree[i];\n if (node.key === key) {\n const n = node as NodeWithPosition;\n n.depth = depth;\n n.position = i;\n return n;\n }\n if (node.children != null) {\n const found = findNode({ tree: node.children, key, depth: depth + 1 });\n if (found != null) return found;\n }\n }\n return null;\n};\n\nexport interface FindNodesProps {\n tree: Node[];\n keys: string[];\n}\n\nexport const findNodes = ({ tree, keys }: FindNodesProps): NodeWithPosition[] => {\n const nodes: NodeWithPosition[] = [];\n for (const key of keys) {\n const node = findNode({ tree, key });\n if (node != null) nodes.push(node);\n }\n return nodes;\n};\n\nexport interface FindNodeParentProps {\n tree: Node[];\n key: string;\n}\n\nexport const findNodeParent = ({ tree, key }: FindNodeParentProps): Node | null => {\n for (const node of tree) {\n if (node.children != null) {\n if (node.children.some((child) => child.key === key)) return node;\n const found = findNodeParent({ tree: node.children, key });\n if (found != null) return found;\n }\n }\n return null;\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 {\n type ReactElement,\n useCallback,\n useMemo,\n useState,\n type FC,\n memo,\n} from \"react\";\n\nimport { Icon } from \"@synnaxlabs/media\";\n\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { Haul } from \"@/haul\";\nimport { useSyncedRef, useCombinedStateAndRef } from \"@/hooks\";\nimport { List } from \"@/list\";\nimport { type UseSelectOnChangeExtra, type UseSelectProps } from \"@/list/useSelect\";\nimport { CONTEXT_SELECTED, CONTEXT_TARGET } from \"@/menu/ContextMenu\";\nimport { state } from \"@/state\";\nimport { Text } from \"@/text\";\nimport { flatten, type Node, type FlattenedNode } from \"@/tree/core\";\nimport { Triggers } from \"@/triggers\";\nimport { type RenderProp, componentRenderProp } from \"@/util/renderProp\";\n\nimport \"@/tree/Tree.css\";\n\nexport const HAUL_TYPE = \"tree-item\";\n\nexport interface HandleExpandProps {\n current: string[];\n action: \"expand\" | \"contract\";\n clicked: string;\n}\n\nexport interface UseProps {\n onExpand?: (props: HandleExpandProps) => void;\n selected?: string[];\n onSelectedChange?: state.Set<string[]>;\n initialExpanded?: string[];\n nodes: Node[];\n sort?: boolean;\n}\n\nexport interface UseReturn {\n selected: string[];\n expanded: string[];\n onSelect: UseSelectProps<string, FlattenedNode>[\"onChange\"];\n nodes: FlattenedNode[];\n}\n\nconst SHIFT_TRIGGERS: Triggers.Trigger[] = [[\"Shift\"]];\n\nexport const use = (props: UseProps): UseReturn => {\n const {\n onExpand,\n nodes,\n initialExpanded = [],\n sort = true,\n selected: propsSelected,\n onSelectedChange,\n } = props ?? {};\n const [expanded, setExpanded, ref] =\n useCombinedStateAndRef<string[]>(initialExpanded);\n const [selected, setSelected] = state.usePassthrough<string[]>({\n initial: [],\n value: propsSelected,\n onChange: onSelectedChange,\n });\n const flat = useMemo(\n () => flatten({ nodes, expanded, sort }),\n [nodes, expanded, sort],\n );\n const flatRef = useSyncedRef(flat);\n\n const shiftRef = Triggers.useHeldRef({ triggers: SHIFT_TRIGGERS });\n\n const handleSelect: UseSelectProps<string, FlattenedNode>[\"onChange\"] = useCallback(\n (\n keys: string[],\n { clicked }: UseSelectOnChangeExtra<string, FlattenedNode>,\n ): void => {\n setSelected(keys);\n const n = flatRef.current.find((node) => node.key === clicked);\n if (n?.hasChildren === false) return;\n if (clicked == null || shiftRef.current.held) return;\n const currentlyExpanded = ref.current;\n const action = currentlyExpanded.some((key) => key === clicked)\n ? \"contract\"\n : \"expand\";\n let nextExpanded = currentlyExpanded;\n if (action === \"contract\")\n nextExpanded = currentlyExpanded.filter((key) => key !== clicked);\n else nextExpanded = [...currentlyExpanded, clicked];\n setExpanded(nextExpanded);\n onExpand?.({ current: nextExpanded, action, clicked });\n },\n [onExpand, flatRef, setExpanded, setSelected],\n );\n\n return {\n onSelect: handleSelect,\n selected,\n expanded,\n nodes: flat,\n };\n};\n\nexport interface ItemProps extends List.ItemProps<string, FlattenedNode> {\n onDrop?: (key: string, props: Haul.OnDropProps) => Haul.Item[];\n onSuccessfulDrop?: (key: string, props: Haul.OnSuccessfulDropProps) => void;\n onRename?: (key: string, name: string) => void;\n onDoubleClick?: (key: string, e: React.MouseEvent) => void;\n loading?: boolean;\n useMargin?: boolean;\n}\n\ntype TreePropsInheritedFromItem = Pick<\n ItemProps,\n \"onDrop\" | \"onRename\" | \"onSuccessfulDrop\" | \"onDoubleClick\" | \"useMargin\"\n>;\n\ntype TreePropsInheritedFromList = Omit<\n List.VirtualCoreProps<string, FlattenedNode>,\n \"onDrop\" | \"onSelect\" | \"children\" | \"onDoubleClick\" | \"itemHeight\"\n> & {\n itemHeight?: number;\n};\n\nexport interface TreeProps\n extends TreePropsInheritedFromItem,\n TreePropsInheritedFromList {\n nodes: FlattenedNode[];\n selected?: string[];\n onSelect: UseSelectProps<string, FlattenedNode>[\"onChange\"];\n children?: RenderProp<ItemProps>;\n virtual?: boolean;\n}\n\nconst expandedCaret = <Icon.Caret.Down className={CSS.B(\"caret\")} />;\nconst collapsedCaret = <Icon.Caret.Right className={CSS.B(\"caret\")} />;\n\nexport type Item = FC<ItemProps>;\n\nexport const DefaultItem = memo(\n ({\n entry,\n selected,\n onSelect,\n onDrop,\n onRename,\n onSuccessfulDrop,\n onDoubleClick,\n loading = false,\n useMargin = false,\n translate,\n }: ItemProps): ReactElement => {\n const {\n key,\n hasChildren = false,\n allowRename = false,\n children,\n icon,\n name,\n depth,\n expanded,\n href,\n haulItems = [],\n } = entry;\n\n const { getSelected } = List.useSelectionUtils<string>();\n const { getSourceData } = List.useDataUtilContext<string, FlattenedNode>();\n\n const actuallyHasChildren =\n hasChildren || (children != null && children.length > 0);\n\n // Expand, contract, and loading items.\n const startIcons: ReactElement[] = [];\n if (actuallyHasChildren) startIcons.push(expanded ? expandedCaret : collapsedCaret);\n if (icon != null) startIcons.push(icon);\n const endIcons: ReactElement[] = [];\n if (loading) endIcons.push(<Icon.Loading className={CSS.B(\"loading-indicator\")} />);\n\n const [draggingOver, setDraggingOver] = useState(false);\n\n // Drag and Drop\n const { startDrag, ...dropProps } = Haul.useDragAndDrop({\n type: \"Tree.Item\",\n key,\n canDrop: useCallback(({ items: entities, source }) => {\n const keys = entities.map((item) => item.key);\n setDraggingOver(false);\n return source.type === \"Tree.Item\" && !keys.includes(key);\n }, []),\n onDrop: useCallback((props) => onDrop?.(key, props) ?? [], [key, onDrop]),\n onDragOver: useCallback(() => setDraggingOver(true), []),\n });\n\n const handleDragStart = (): void => {\n const selectedItemKeys = getSelected();\n const selectedItems = getSourceData().filter((item) =>\n selectedItemKeys.includes(item.key),\n );\n if (selectedItemKeys.includes(key)) {\n const selectedHaulItems = selectedItems\n .map(({ key, haulItems }) => [{ type: HAUL_TYPE, key }, ...(haulItems ?? [])])\n .flat();\n return startDrag(selectedHaulItems, (props) => onSuccessfulDrop?.(key, props));\n }\n startDrag([{ type: HAUL_TYPE, key }, ...haulItems], (props) =>\n onSuccessfulDrop?.(key, props),\n );\n };\n\n const offsetKey = useMargin ? \"marginLeft\" : \"paddingLeft\";\n\n const baseProps: Button.LinkProps | Button.ButtonProps = {\n id: key,\n variant: \"text\",\n draggable: true,\n className: CSS(\n CSS.BE(\"list\", \"item\"),\n CONTEXT_TARGET,\n draggingOver && CSS.M(\"dragging-over\"),\n selected && CONTEXT_SELECTED,\n CSS.selected(selected),\n actuallyHasChildren && CSS.M(\"has-children\"),\n ),\n onDragLeave: () => setDraggingOver(false),\n onDragStart: handleDragStart,\n onClick: () => onSelect?.(key),\n style: {\n position: translate != null ? \"absolute\" : \"relative\",\n transform: `translateY(${translate}px)`,\n [offsetKey]: `${depth * 1.5 + 1}rem`,\n },\n startIcon: startIcons,\n iconSpacing: \"small\",\n noWrap: true,\n endIcon: endIcons,\n onDoubleClick: (e) => onDoubleClick?.(key, e),\n href,\n ...dropProps,\n };\n\n const Base = href != null ? Button.Link : Button.Button;\n\n return (\n <Base className={CSS.BE(\"list\", \"item\")} {...baseProps}>\n <Text.MaybeEditable\n id={`text-${key}`}\n level=\"p\"\n allowDoubleClick={false}\n value={name}\n disabled={!allowRename}\n onChange={(name) => onRename?.(key, name)}\n />\n </Base>\n );\n },\n);\nDefaultItem.displayName = \"Tree.Item\";\n\nconst defaultChild = componentRenderProp(DefaultItem);\n\nexport const Tree = ({\n nodes,\n selected = [],\n onSelect,\n onDrop,\n onRename,\n onSuccessfulDrop,\n onDoubleClick,\n className,\n children = defaultChild,\n itemHeight = 27,\n useMargin = false,\n virtual = true,\n ...props\n}: TreeProps): ReactElement => {\n const Core = virtual ? List.Core.Virtual : List.Core;\n\n return (\n <List.List<string, FlattenedNode> data={nodes}>\n <List.Selector value={selected} onChange={onSelect} allowMultiple replaceOnSingle>\n <Core<string, FlattenedNode>\n itemHeight={itemHeight}\n className={CSS(className, CSS.B(\"tree\"))}\n {...props}\n >\n {(props) =>\n children({\n ...props,\n useMargin,\n onDrop,\n onRename,\n onSuccessfulDrop,\n onDoubleClick,\n })\n }\n </Core>\n </List.Selector>\n </List.List>\n );\n};\n\nexport const startRenaming = (key: string): void => Text.edit(`text-${key}`);\n"],"names":["toArray","node","state.usePassthrough","Triggers.useHeldRef","jsx","Icon","List.useSelectionUtils","List.useDataUtilContext","Haul.useDragAndDrop","key","haulItems","Button.Link","Button.Button","Text.MaybeEditable","name","Core","List.Core","List.List","List.Selector","props","Text.edit"],"mappings":";;;;;;;;AAwCO,MAAM,eAAe,CAAC,MAAY,aACvC,SAAS,SAAS,KAAK,GAAG;AASf,MAAA,gBAAgB,CAAC,OAAe,SAA0B;AACrE,MAAI,MAAM;AACF,UAAA,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AAAA,EACnD;AACA,MAAI,QAAQ;AACZ,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AAC/B,UAAA,OAAO,MAAM,CAAC;AACpB,QAAI,KAAK,iBAAiB,QAAQ,MAAM,KAAK,eAAe;AAClD,cAAA;AAEF,YAAA,OAAO,GAAG,CAAC;AAEjB,YAAM,OAAO,KAAK,eAAe,GAAG,IAAI;AAAA,IAC1C;AAAA,EACF;AACI,MAAA;AAAc,WAAA,cAAc,OAAO,KAAK;AACrC,SAAA;AACT;AAEO,MAAM,UAAU,CAAC;AAAA,EACtB;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,OAAO;AACT,MAAqC;AAEnC,MAAI,UAAU,KAAK;AAAc,YAAA,MAAM,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AAClF,QAAM,YAA6B,CAAA;AAC7B,QAAA,QAAQ,CAAC,MAAM,UAAU;AACvB,UAAA,SAAS,aAAa,MAAM,QAAQ;AAChC,cAAA,KAAK,EAAE,GAAG,MAAM,OAAO,UAAU,QAAQ,OAAO;AACtD,QAAA,UAAU,KAAK,YAAY,MAAM;AACnC,WAAK,WAAW,cAAc,KAAK,UAAU,IAAI;AACvC,gBAAA;AAAA,QACR,GAAG,QAAQ,EAAE,OAAO,KAAK,UAAU,UAAU,OAAO,QAAQ,GAAG,MAAM;AAAA,MAAA;AAAA,IAEzE;AAAA,EAAA,CACD;AACM,SAAA;AACT;AAQO,MAAM,WAAW,CAAC,EAAE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AACb,kCAAA,IAAAc,UAAA,EAAc,OAAO,UAAU,UAAU,UAAU,eAAa,MAAC,iBAAe,MAC/E,UAAAd,kCAAA;AAAA,IAACW;AAAAA,IAAA;AAAA,MACC;AAAA,MACA,WAAW,IAAI,WAAW,IAAI,EAAE,MAAM,CAAC;AAAA,MACtC,GAAG;AAAA,MAEH,UAAA,CAACI,WACA,SAAS;AAAA,QACP,GAAGA;AAAAA,QACH;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA,CACD;AAAA,IAAA;AAAA,EAAA,EAGP,CAAA,EACF,CAAA;AAEJ;AAEO,MAAM,gBAAgB,CAAC,QAAsBC,KAAU,QAAQ,GAAG,EAAE;;;;;;;;;;;;;;;;;;;"}
@@ -1,9 +1,9 @@
1
- import { C as CSS, a as Color, Z as ZERO, c as cssString, f as fromHSLA, t as toHex } from "./css-DoalWJF6.js";
1
+ import { C as CSS, a as Color, Z as ZERO, c as cssString, f as fromHSLA, t as toHex } from "./css-DKKmdhSr.js";
2
2
  import { j as jsxRuntimeExports } from "./jsx-runtime-mMz73N64.js";
3
- import { i as SketchPicker, j as use, u as use$1, k as useDraggingState, l as filterByType, m as useDragAndDrop, B as Button, e as Text, n as Dialog } from "./Toggle-DGLgYCOX.js";
3
+ import { i as SketchPicker, j as use, u as use$1, k as useDraggingState, l as filterByType, m as useDragAndDrop, B as Button, e as Text, n as Dialog } from "./Toggle-bT5RpwfA.js";
4
4
  import { useCallback } from "react";
5
- import "./aggregator-BgImZc4o.js";
6
- import "./Center-hbwH7rg9.js";
5
+ import "./aggregator-B8fg7W2s.js";
6
+ import "./Center-BK9Rcaa0.js";
7
7
  const Picker = ({ value, onChange, ...props }) => {
8
8
  const handleChange = (res) => {
9
9
  if (res.hex === "transparent")
@@ -105,4 +105,4 @@ export {
105
105
  Swatch as S,
106
106
  external as e
107
107
  };
108
- //# sourceMappingURL=external-DarqsFzT.js.map
108
+ //# sourceMappingURL=external-DNHMAfGi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"external-DarqsFzT.js","sources":["../src/color/Picker/Picker.tsx","../src/color/Swatch/Swatch.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 ComponentPropsWithoutRef, type ReactElement } from \"react\";\n\nimport { SketchPicker, type ColorResult } from \"react-color\";\n\nimport { color } from \"@/color/core\";\nimport { CSS } from \"@/css\";\nimport { type Input } from \"@/input\";\n\nimport \"@/color/Picker/Picker.css\";\n\nexport interface PickerProps\n extends Input.Control<color.Crude, color.Color>,\n Omit<ComponentPropsWithoutRef<\"div\">, \"onChange\"> {}\n\nexport const Picker = ({ value, onChange, ...props }: PickerProps): ReactElement => {\n const handleChange = (res: ColorResult): void => {\n if (res.hex === \"transparent\") onChange(color.ZERO);\n onChange(new color.Color(res.hex, res.rgb.a));\n };\n\n return (\n <SketchPicker\n className={CSS.B(\"color-picker\")}\n color={new color.Color(value).hex}\n onChange={handleChange}\n presetColors={[]}\n {...props}\n />\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement, useCallback } from \"react\";\n\nimport { Button } from \"@/button\";\nimport { color } from \"@/color/core\";\nimport { type Crude, type Color } from \"@/color/core/color\";\nimport { Picker } from \"@/color/Picker\";\nimport { CSS } from \"@/css\";\nimport { Dropdown } from \"@/dropdown\";\nimport { type UseProps } from \"@/dropdown/Dropdown\";\nimport { Haul } from \"@/haul\";\nimport { type Input } from \"@/input\";\nimport { Text } from \"@/text\";\nimport { Theming } from \"@/theming\";\n\nimport \"@/color/Swatch/Swatch.css\";\n\nexport interface SwatchProps\n extends Input.Control<Crude, Color>,\n Omit<Button.ButtonProps, \"onChange\" | \"value\">,\n UseProps {}\n\nconst HAUL_TYPE = \"color\";\n\nexport const Swatch = ({\n value,\n onChange,\n className,\n size = \"medium\",\n onVisibleChange,\n initialVisible,\n draggable = true,\n ...props\n}: SwatchProps): ReactElement => {\n const { visible, open, close } = Dropdown.use({ onVisibleChange, initialVisible });\n\n const bg = Theming.use().colors.gray.l0;\n\n const d = new color.Color(value);\n\n const dragging = Haul.useDraggingState();\n\n const canDrop: Haul.CanDrop = useCallback(\n ({ items }) => {\n const [k] = Haul.filterByType(HAUL_TYPE, items);\n return k != null && k.key !== d.hex;\n },\n [d.hex],\n );\n\n const { startDrag, ...haulProps } = Haul.useDragAndDrop({\n type: \"Color.Swatch\",\n onDrop: ({ items }) => {\n const dropped = Haul.filterByType(HAUL_TYPE, items);\n if (items.length > 0) onChange?.(new color.Color(dropped[0].key as string));\n return dropped;\n },\n canDrop,\n });\n\n const swatch = (\n <Button.Button\n className={CSS(\n CSS.B(\"color-swatch\"),\n CSS.size(size),\n d.contrast(bg) > 1.5 && d.a > 0.5 && CSS.M(\"no-border\"),\n CSS.dropRegion(canDrop(dragging)),\n className,\n )}\n draggable={draggable}\n onDragStart={() => startDrag([{ type: HAUL_TYPE, key: d.hex }])}\n style={{ backgroundColor: color.cssString(value) }}\n variant=\"text\"\n onClick={open}\n size={size}\n tooltip={\n onChange != null ? (\n <Text.Text level=\"small\">Click to change color</Text.Text>\n ) : undefined\n }\n {...haulProps}\n {...props}\n />\n );\n\n if (onChange == null) return swatch;\n\n return (\n <Dropdown.Dialog\n close={close}\n visible={visible}\n className={CSS.BE(\"color-swatch\", \"dropdown\")}\n keepMounted={false}\n variant=\"floating\"\n >\n {swatch}\n <Picker value={value} onChange={onChange} />\n </Dropdown.Dialog>\n );\n};\n"],"names":["color.ZERO","color.Color","jsx","Dropdown.use","Theming.use","Haul.useDraggingState","Haul.filterByType","Haul.use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CAAC,EAAE,GAAa;AAClE,aAAA;AAAA,IACT;AAAA,IACA;AAAA,EAAA,CACD;AAED,QAAM,SACJC,kCAAA;AAAA,IAACM;AAAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT,IAAI,EAAE,cAAc;AAAA,QACpB,IAAI,KAAK,IAAI;AAAA,QACb,EAAE,SAAS,EAAE,IAAI,OAAO,EAAE,IAAI,OAAO,IAAI,EAAE,WAAW;AAAA,QACtD,IAAI,WAAW,QAAQ,QAAQ,CAAC;AAAA,QAChC;AAAA,MACF;AAAA,MACA;AAAA,MACA,aAAa,MAAM,UAAU,CAAC,EAAE,MAAM,WAAW,KAAK,EAAE,IAAI,CAAC,CAAC;AAAA,MAC9D,OAAO,EAAE,iBAAiBC,UAAgB,KAAK,EAAE;AAAA,MACjD,SAAQ;AAAA,MACR,SAAS;AAAA,MACT;AAAA,MACA,SACE,YAAY,OACTP,kCAAAA,IAAAQ,MAAA,EAAU,OAAM,SAAQ,UAAA,wBAAqB,CAAA,IAC5C;AAAA,MAEL,GAAG;AAAA,MACH,GAAG;AAAA,IAAA;AAAA,EAAA;AAIR,MAAI,YAAY;AAAa,WAAA;AAG3B,SAAAC,kCAAA;AAAA,IAACC;AAAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,WAAW,IAAI,GAAG,gBAAgB,UAAU;AAAA,MAC5C,aAAa;AAAA,MACb,SAAQ;AAAA,MAEP,UAAA;AAAA,QAAA;AAAA,QACDV,kCAAAA,IAAC,QAAO,EAAA,OAAc,SAAoB,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGhD;;;;;;;;;;;"}
1
+ {"version":3,"file":"external-DNHMAfGi.js","sources":["../src/color/Picker/Picker.tsx","../src/color/Swatch/Swatch.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 ComponentPropsWithoutRef, type ReactElement } from \"react\";\n\nimport { SketchPicker, type ColorResult } from \"react-color\";\n\nimport { color } from \"@/color/core\";\nimport { CSS } from \"@/css\";\nimport { type Input } from \"@/input\";\n\nimport \"@/color/Picker/Picker.css\";\n\nexport interface PickerProps\n extends Input.Control<color.Crude, color.Color>,\n Omit<ComponentPropsWithoutRef<\"div\">, \"onChange\"> {}\n\nexport const Picker = ({ value, onChange, ...props }: PickerProps): ReactElement => {\n const handleChange = (res: ColorResult): void => {\n if (res.hex === \"transparent\") onChange(color.ZERO);\n onChange(new color.Color(res.hex, res.rgb.a));\n };\n\n return (\n <SketchPicker\n className={CSS.B(\"color-picker\")}\n color={new color.Color(value).hex}\n onChange={handleChange}\n presetColors={[]}\n {...props}\n />\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement, useCallback } from \"react\";\n\nimport { Button } from \"@/button\";\nimport { color } from \"@/color/core\";\nimport { type Crude, type Color } from \"@/color/core/color\";\nimport { Picker } from \"@/color/Picker\";\nimport { CSS } from \"@/css\";\nimport { Dropdown } from \"@/dropdown\";\nimport { type UseProps } from \"@/dropdown/Dropdown\";\nimport { Haul } from \"@/haul\";\nimport { type Input } from \"@/input\";\nimport { Text } from \"@/text\";\nimport { Theming } from \"@/theming\";\n\nimport \"@/color/Swatch/Swatch.css\";\n\nexport interface SwatchProps\n extends Input.Control<Crude, Color>,\n Omit<Button.ButtonProps, \"onChange\" | \"value\">,\n UseProps {}\n\nconst HAUL_TYPE = \"color\";\n\nexport const Swatch = ({\n value,\n onChange,\n className,\n size = \"medium\",\n onVisibleChange,\n initialVisible,\n draggable = true,\n ...props\n}: SwatchProps): ReactElement => {\n const { visible, open, close } = Dropdown.use({ onVisibleChange, initialVisible });\n\n const bg = Theming.use().colors.gray.l0;\n\n const d = new color.Color(value);\n\n const dragging = Haul.useDraggingState();\n\n const canDrop: Haul.CanDrop = useCallback(\n ({ items }) => {\n const [k] = Haul.filterByType(HAUL_TYPE, items);\n return k != null && k.key !== d.hex;\n },\n [d.hex],\n );\n\n const { startDrag, ...haulProps } = Haul.useDragAndDrop({\n type: \"Color.Swatch\",\n onDrop: ({ items }) => {\n const dropped = Haul.filterByType(HAUL_TYPE, items);\n if (items.length > 0) onChange?.(new color.Color(dropped[0].key as string));\n return dropped;\n },\n canDrop,\n });\n\n const swatch = (\n <Button.Button\n className={CSS(\n CSS.B(\"color-swatch\"),\n CSS.size(size),\n d.contrast(bg) > 1.5 && d.a > 0.5 && CSS.M(\"no-border\"),\n CSS.dropRegion(canDrop(dragging)),\n className,\n )}\n draggable={draggable}\n onDragStart={() => startDrag([{ type: HAUL_TYPE, key: d.hex }])}\n style={{ backgroundColor: color.cssString(value) }}\n variant=\"text\"\n onClick={open}\n size={size}\n tooltip={\n onChange != null ? (\n <Text.Text level=\"small\">Click to change color</Text.Text>\n ) : undefined\n }\n {...haulProps}\n {...props}\n />\n );\n\n if (onChange == null) return swatch;\n\n return (\n <Dropdown.Dialog\n close={close}\n visible={visible}\n className={CSS.BE(\"color-swatch\", \"dropdown\")}\n keepMounted={false}\n variant=\"floating\"\n >\n {swatch}\n <Picker value={value} onChange={onChange} />\n </Dropdown.Dialog>\n );\n};\n"],"names":["color.ZERO","color.Color","jsx","Dropdown.use","Theming.use","Haul.useDraggingState","Haul.filterByType","Haul.useDragAndDrop","Button.Button","color.cssString","Text.Text","jsxs","Dropdown.Dialog"],"mappings":";;;;;;AAuBO,MAAM,SAAS,CAAC,EAAE,OAAO,UAAU,GAAG,YAAuC;AAC5E,QAAA,eAAe,CAAC,QAA2B;AAC/C,QAAI,IAAI,QAAQ;AAAe,eAASA,IAAU;AACzC,aAAA,IAAIC,MAAY,IA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I,OAAO,EAAE,IAAI,OAAO,IAAI,EAAE,WAAW;AAAA,QACtD,IAAI,WAAW,QAAQ,QAAQ,CAAC;AAAA,QAChC;AAAA,MACF;AAAA,MACA;AAAA,MACA,aAAa,MAAM,UAAU,CAAC,EAAE,MAAM,WAAW,KAAK,EAAE,IAAI,CAAC,CAAC;AAAA,MAC9D,OAAO,EAAE,iBAAiBC,UAAgB,KAAK,EAAE;AAAA,MACjD,SAAQ;AAAA,MACR,SAAS;AAAA,MACT;AAAA,MACA,SACE,YAAY,OACTP,kCAAAA,IAAAQ,MAAA,EAAU,OAAM,SAAQ,UAAA,wBAAqB,CAAA,IAC5C;AAAA,MAEL,GAAG;AAAA,MACH,GAAG;AAAA,IAAA;AAAA,EAAA;AAIR,MAAI,YAAY;AAAa,WAAA;AAG3B,SAAAC,kCAAA;AAAA,IAACC;AAAAA,IAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,WAAW,IAAI,GAAG,gBAAgB,UAAU;AAAA,MAC5C,aAAa;AAAA,MACb,SAAQ;AAAA,MAEP,UAAA;AAAA,QAAA;AAAA,QACDV,kCAAAA,IAAC,QAAO,EAAA,OAAc,SAAoB,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGhD;;;;;;;;;;;"}
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  const jsxRuntime = require("./jsx-runtime-B3vWrP5x.cjs");
3
3
  const React = require("react");
4
- const aggregator = require("./aggregator-BpfMBUD1.cjs");
5
- const Center = require("./Center-5NJ61qfA.cjs");
6
- const Toggle = require("./Toggle-C6Z8WPT3.cjs");
7
- const css = require("./css-Pf9qxhQ4.cjs");
4
+ const aggregator = require("./aggregator-Bh2Kyzkg.cjs");
5
+ const Center = require("./Center-Cc_rR5pQ.cjs");
6
+ const Toggle = require("./Toggle-D3iCEbO1.cjs");
7
+ const css = require("./css-Ci8WUD5E.cjs");
8
8
  const Context = React.createContext({
9
9
  divided: false,
10
10
  level: "h1"
@@ -118,4 +118,4 @@ exports.Actions = Actions;
118
118
  exports.ButtonTitle = ButtonTitle;
119
119
  exports.Header = Header;
120
120
  exports.external = external;
121
- //# sourceMappingURL=external-0PM7JrzG.cjs.map
121
+ //# sourceMappingURL=external-DVQ2SRoH.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"external-0PM7JrzG.cjs","sources":["../src/header/Header.tsx","../src/header/Actions.tsx","../src/header/ButtonTitle.tsx","../src/header/Title.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","// 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 { Fragment, isValidElement, type ReactElement } from \"react\";\n\nimport { toArray } from \"@synnaxlabs/x\";\n\nimport { Align } from \"@/align\";\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { Divider } from \"@/divider\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport type ActionSpec = Button.IconProps | ReactElement;\n\nexport interface ActionsProps {\n children?: ActionSpec | ActionSpec[];\n}\n\n/**\n * Custom actions to render on the right side of the header.\n *\n * @param children - The actions to render. If the action is of type\n * {@link ButtonIconProps}, a correectly sized {@link ButtonIconOnly} is rendered\n * using the given props. If the action is a JSX element, it is renderered directly.\n * It's a good idea to prefer the latter in almost all cases for simplicity.\n */\nexport const Actions = ({ children = [] }: ActionsProps): ReactElement => {\n const { level, divided } = useContext();\n return (\n <Align.Space\n direction=\"x\"\n size=\"small\"\n align=\"center\"\n className={CSS.BE(\"header\", \"actions\")}\n >\n {toArray(children).map((action, i) => (\n <Action key={i} index={i} level={level} divided={divided}>\n {action}\n </Action>\n ))}\n </Align.Space>\n );\n};\n\ninterface ActionProps {\n index: number;\n level: Text.Level;\n children: ReactElement | Button.IconProps;\n divided: boolean;\n}\n\nconst Action = ({ index, level, children, divided }: ActionProps): ReactElement => {\n let content: ReactElement = children as ReactElement;\n if (!isValidElement(children)) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const props = children as Button.IconProps;\n content = (\n <Button.Icon\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.onClick?.(e);\n }}\n key={index}\n size={Text.LevelComponentSizes[level]}\n {...props}\n />\n );\n }\n return (\n <Fragment key={index}>\n {divided && <Divider.Divider />}\n {content}\n </Fragment>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport interface ButtonTitleProps\n extends Omit<Button.ButtonProps, \"variant\" | \"size\"> {}\n\n/**\n * Header.Title.Use renders a clickable header title.\n *\n * @param props - The comonent props. The props for this component are identical\n * to {@link Button}, except the variant is always 'outlined' and that the component size\n * is automatically inferred from the 'level' prop passsed to the parent {@link Header}\n * component.\n */\nexport const ButtonTitle = ({\n children = \"\",\n className,\n onClick,\n ...props\n}: ButtonTitleProps): ReactElement => {\n const { level } = useContext();\n return (\n <Button.Button\n variant=\"text\"\n size={Text.LevelComponentSizes[level]}\n onClick={onClick}\n className={CSS(CSS.B(\"header-button-title\"), className)}\n sharp\n {...props}\n >\n {children}\n </Button.Button>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { CSS } from \"@/css\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport interface TitleProps extends Omit<Text.WithIconProps, \"divided\" | \"level\"> {\n level?: Text.Level;\n}\n\n/**\n * Renders the title for the header component.\n *\n * @param props - The component props. The props for this component are identical\n * to the {@link Typography.TextWithIcon} component, except that the 'level', and\n * 'divider' props are inherited from the parent {@link Header} component.\n */\nexport const Title = ({\n className,\n level: propsLevel,\n ...props\n}: TitleProps): ReactElement => {\n const { level, divided } = useContext();\n return (\n <Text.WithIcon\n className={CSS(CSS.BE(\"header\", \"text\"), className)}\n level={propsLevel ?? level}\n divided={divided}\n size={1.5}\n {...props}\n />\n );\n};\n"],"names":["createContext","reactUseContext","jsx","Align.Space","CSS","toArray","isValidElement","Button.Icon","Text.LevelComponentSizes","Fragment","Divider.Divider","Button.Button","Text.WithIcon"],"mappings":";;;;;;;AAiCA,MAAM,UAAUA,MAAAA,cAA4B;AAAA,EAC1C,SAAS;AAAA,EACT,OAAO;AACT,CAAC;AAEY,MAAA,aAAa,MAAoBC,iBAAgB,OAAO;AAgB9D,MAAM,SAAS,CAAC;AAAA,EACrB;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,GAAG;AACL,MACEC,2BAAA,kBAAA,IAAC,QAAQ,UAAR,EAAiB,OAAO,EAAE,OAAO,WAChC,UAAAA,2BAAA,kBAAA;AAAA,EAACC,OAAM;AAAA,EAAN;AAAA,IACC,IAAG;AAAA,IACH,WAAU;AAAA,IACV,SAAQ;AAAA,IACR,WAAWC,IAAA;AAAA,MACTA,IAAA,IAAI,EAAE,QAAQ;AAAA,MACdA,IAAA,IAAI,SAAS,QAAQ;AAAA,MACrB,WAAWA,IAAA,IAAI,GAAG,UAAU,SAAS;AAAA,MACrC;AAAA,IACF;AAAA,IACC,GAAG;AAAA,IAEH;AAAA,EAAA;AACH,EACF,CAAA;AC1CK,MAAM,UAAU,CAAC,EAAE,WAAW,CAAA,QAAqC;AACxE,QAAM,EAAE,OAAO,QAAQ,IAAI,WAAW;AAEpC,SAAAF,2BAAA,kBAAA;AAAA,IAACC,OAAM;AAAA,IAAN;AAAA,MACC,WAAU;AAAA,MACV,MAAK;AAAA,MACL,OAAM;A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AA,EACP,GAAG;AACL,MAAgC;AAC9B,QAAM,EAAE,OAAO,QAAQ,IAAI,WAAW;AAEpC,SAAAF,2BAAA,kBAAA;AAAA,IAACU,OAAK;AAAA,IAAL;AAAA,MACC,WAAWR,IAAI,IAAAA,QAAI,GAAG,UAAU,MAAM,GAAG,SAAS;AAAA,MAClD,OAAO,cAAc;AAAA,MACrB;AAAA,MACA,MAAM;AAAA,MACL,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"external-DVQ2SRoH.cjs","sources":["../src/header/Header.tsx","../src/header/Actions.tsx","../src/header/ButtonTitle.tsx","../src/header/Title.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","// 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 { Fragment, isValidElement, type ReactElement } from \"react\";\n\nimport { toArray } from \"@synnaxlabs/x\";\n\nimport { Align } from \"@/align\";\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { Divider } from \"@/divider\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport type ActionSpec = Button.IconProps | ReactElement;\n\nexport interface ActionsProps {\n children?: ActionSpec | ActionSpec[];\n}\n\n/**\n * Custom actions to render on the right side of the header.\n *\n * @param children - The actions to render. If the action is of type\n * {@link ButtonIconProps}, a correectly sized {@link ButtonIconOnly} is rendered\n * using the given props. If the action is a JSX element, it is renderered directly.\n * It's a good idea to prefer the latter in almost all cases for simplicity.\n */\nexport const Actions = ({ children = [] }: ActionsProps): ReactElement => {\n const { level, divided } = useContext();\n return (\n <Align.Space\n direction=\"x\"\n size=\"small\"\n align=\"center\"\n className={CSS.BE(\"header\", \"actions\")}\n >\n {toArray(children).map((action, i) => (\n <Action key={i} index={i} level={level} divided={divided}>\n {action}\n </Action>\n ))}\n </Align.Space>\n );\n};\n\ninterface ActionProps {\n index: number;\n level: Text.Level;\n children: ReactElement | Button.IconProps;\n divided: boolean;\n}\n\nconst Action = ({ index, level, children, divided }: ActionProps): ReactElement => {\n let content: ReactElement = children as ReactElement;\n if (!isValidElement(children)) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n const props = children as Button.IconProps;\n content = (\n <Button.Icon\n onClick={(e) => {\n e.stopPropagation();\n e.preventDefault();\n props.onClick?.(e);\n }}\n key={index}\n size={Text.LevelComponentSizes[level]}\n {...props}\n />\n );\n }\n return (\n <Fragment key={index}>\n {divided && <Divider.Divider />}\n {content}\n </Fragment>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { Button } from \"@/button\";\nimport { CSS } from \"@/css\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport interface ButtonTitleProps\n extends Omit<Button.ButtonProps, \"variant\" | \"size\"> {}\n\n/**\n * Header.Title.Use renders a clickable header title.\n *\n * @param props - The comonent props. The props for this component are identical\n * to {@link Button}, except the variant is always 'outlined' and that the component size\n * is automatically inferred from the 'level' prop passsed to the parent {@link Header}\n * component.\n */\nexport const ButtonTitle = ({\n children = \"\",\n className,\n onClick,\n ...props\n}: ButtonTitleProps): ReactElement => {\n const { level } = useContext();\n return (\n <Button.Button\n variant=\"text\"\n size={Text.LevelComponentSizes[level]}\n onClick={onClick}\n className={CSS(CSS.B(\"header-button-title\"), className)}\n sharp\n {...props}\n >\n {children}\n </Button.Button>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { CSS } from \"@/css\";\nimport { useContext } from \"@/header/Header\";\nimport { Text } from \"@/text\";\n\nexport interface TitleProps extends Omit<Text.WithIconProps, \"divided\" | \"level\"> {\n level?: Text.Level;\n}\n\n/**\n * Renders the title for the header component.\n *\n * @param props - The component props. The props for this component are identical\n * to the {@link Typography.TextWithIcon} component, except that the 'level', and\n * 'divider' props are inherited from the parent {@link Header} component.\n */\nexport const Title = ({\n className,\n level: propsLevel,\n ...props\n}: TitleProps): ReactElement => {\n const { level, divided } = useContext();\n return (\n <Text.WithIcon\n className={CSS(CSS.BE(\"header\", \"text\"), className)}\n level={propsLevel ?? level}\n divided={divided}\n size={1.5}\n {...props}\n />\n );\n};\n"],"names":["createContext","reactUseContext","jsx","Align.Space","CSS","toArray","isValidElement","Button.Icon","Text.LevelComponentSizes","Fragment","Divider.Divider","Button.Button","Text.WithIcon"],"mappings":";;;;;;;AAiCA,MAAM,UAAUA,MAAAA,cAA4B;AAAA,EAC1C,SAAS;AAAA,EACT,OAAO;AACT,CAAC;AAEY,MAAA,aAAa,MAAoBC,iBAAgB,OAAO;AAgB9D,MAAM,SAAS,CAAC;AAAA,EACrB;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,GAAG;AACL,MACEC,2BAAA,kBAAA,IAAC,QAAQ,UAAR,EAAiB,OAAO,EAAE,OAAO,WAChC,UAAAA,2BAAA,kBAAA;AAAA,EAACC,OAAM;AAAA,EAAN;AAAA,IACC,IAAG;AAAA,IACH,WAAU;AAAA,IACV,SAAQ;AAAA,IACR,WAAWC,IAAA;AAAA,MACTA,IAAA,IAAI,EAAE,QAAQ;AAAA,MACdA,IAAA,IAAI,SAAS,QAAQ;AAAA,MACrB,WAAWA,IAAA,IAAI,GAAG,UAAU,SAAS;AAAA,MACrC;AAAA,IACF;AAAA,IACC,GAAG;AAAA,IAEH;AAAA,EAAA;AACH,EACF,CAAA;AC1CK,MAAM,UAAU,CAAC,EAAE,WAAW,CAAA,QAAqC;AACxE,QAAM,E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AAS;AAAA,MACtD,OAAK;AAAA,MACJ,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EAAA;AAGP;ACpBO,MAAM,QAAQ,CAAC;AAAA,EACpB;AAAA,EACA,OAAO;AAAA,EACP,GAAG;AACL,MAAgC;AAC9B,QAAM,EAAE,OAAO,QAAQ,IAAI,WAAW;AAEpC,SAAAF,2BAAA,kBAAA;AAAA,IAACU,OAAK;AAAA,IAAL;AAAA,MACC,WAAWR,IAAI,IAAAA,QAAI,GAAG,UAAU,MAAM,GAAG,SAAS;AAAA,MAClD,OAAO,cAAc;AAAA,MACrB;AAAA,MACA,MAAM;AAAA,MACL,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;;;;;;;;;;;;;"}
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
- const Toggle = require("./Toggle-C6Z8WPT3.cjs");
2
+ const Toggle = require("./Toggle-D3iCEbO1.cjs");
3
3
  const jsxRuntime = require("./jsx-runtime-B3vWrP5x.cjs");
4
- const css = require("./css-Pf9qxhQ4.cjs");
5
- const aggregator = require("./aggregator-BpfMBUD1.cjs");
4
+ const css = require("./css-Ci8WUD5E.cjs");
5
+ const aggregator = require("./aggregator-Bh2Kyzkg.cjs");
6
6
  const React = require("react");
7
- const Center = require("./Center-5NJ61qfA.cjs");
7
+ const Center = require("./Center-Cc_rR5pQ.cjs");
8
8
  const HelpText = ({
9
9
  className,
10
10
  variant = "error",
@@ -87,7 +87,7 @@ const DateTime = ({
87
87
  onBlur,
88
88
  ...props
89
89
  }) => {
90
- const ts = new aggregator.w(value, "UTC");
90
+ const ts = new aggregator.m(value, "UTC");
91
91
  const [internalValue, setInternalValue] = React.useState(
92
92
  ts.fString("ISO", "local").slice(0, -1)
93
93
  );
@@ -95,13 +95,13 @@ const DateTime = ({
95
95
  const handleChange = (next) => {
96
96
  let nextStr = next.toString();
97
97
  setInternalValue(nextStr);
98
- let ts2 = new aggregator.w(next, "UTC");
98
+ let ts2 = new aggregator.m(next, "UTC");
99
99
  if (nextStr.length < 23)
100
100
  nextStr += ".000";
101
101
  ts2 = ts2.add(
102
102
  BigInt(
103
- aggregator.w.now().date().getTimezoneOffset() - ts2.date().getTimezoneOffset()
104
- ) * aggregator.y.MINUTE.valueOf()
103
+ aggregator.m.now().date().getTimezoneOffset() - ts2.date().getTimezoneOffset()
104
+ ) * aggregator.w.MINUTE.valueOf()
105
105
  );
106
106
  let ok = false;
107
107
  try {
@@ -119,7 +119,7 @@ const DateTime = ({
119
119
  };
120
120
  const handleBlur = (e) => {
121
121
  setValueIsValid(true);
122
- setInternalValue(new aggregator.w(value, "UTC").fString("ISO", "local").slice(0, -1));
122
+ setInternalValue(new aggregator.m(value, "UTC").fString("ISO", "local").slice(0, -1));
123
123
  onBlur == null ? void 0 : onBlur(e);
124
124
  };
125
125
  return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
@@ -128,7 +128,7 @@ const DateTime = ({
128
128
  type: "datetime-local",
129
129
  onBlur: handleBlur,
130
130
  required: false,
131
- value: valueIsValid ? new aggregator.w(value, "UTC").fString("ISO", "local").slice(0, -1) : internalValue,
131
+ value: valueIsValid ? new aggregator.m(value, "UTC").fString("ISO", "local").slice(0, -1) : internalValue,
132
132
  onChange: handleChange,
133
133
  ...props
134
134
  }
@@ -153,4 +153,4 @@ const external = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProp
153
153
  }, Symbol.toStringTag, { value: "Module" }));
154
154
  exports.Item = Item;
155
155
  exports.external = external;
156
- //# sourceMappingURL=external-16K8slq8.cjs.map
156
+ //# sourceMappingURL=external-D_yXh8rn.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"external-16K8slq8.cjs","sources":["../src/input/HelpText.tsx","../src/input/Label.tsx","../src/input/Item.tsx","../src/input/DateTime.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 required?: boolean;\n}\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 * @param props.required - Indicate whether the label is associated with a required\n * input.\n */\nexport const Label = ({\n className,\n required = false,\n children,\n ...props\n}: LabelProps): ReactElement => {\n return (\n <label className={CSS(CSS.B(\"input-label\"), className)} {...props}>\n {children} {required && <span className={CSS.B(\"required-indicator\")}>*</span>}\n </label>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { direction } from \"@synnaxlabs/x\";\n\nimport { Align } from \"@/align\";\nimport { CSS } from \"@/css\";\nimport { HelpText } from \"@/input/HelpText\";\nimport { Label } from \"@/input/Label\";\n\nimport \"@/input/Item.css\";\nimport { status } from \"@/status/aether\";\n\nexport interface ItemProps extends Align.SpaceProps {\n label?: string;\n required?: boolean;\n showLabel?: boolean;\n helpText?: string;\n padHelpText?: boolean;\n helpTextVariant?: status.Variant;\n showHelpText?: boolean;\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 required,\n align,\n size = \"small\",\n padHelpText = false,\n helpTextVariant,\n showHelpText = true,\n ...props\n}: ItemProps): ReactElement => {\n let inputAndHelp: ReactElement;\n if (showHelpText === false && showLabel === false) return <>{children}</>;\n if (direction === \"x\")\n inputAndHelp = (\n <Align.Space direction=\"y\" size=\"small\">\n {children}\n {(padHelpText || (helpText != null && helpText.length > 0)) && (\n <HelpText variant={helpTextVariant}>{helpText}</HelpText>\n )}\n </Align.Space>\n );\n else\n inputAndHelp = (\n <Align.Space direction=\"y\" size={1 / 3}>\n {children}\n {(padHelpText || (helpText != null && helpText.length > 0)) && (\n <HelpText variant={helpTextVariant}>{helpText}</HelpText>\n )}\n </Align.Space>\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 required={required}>{label}</Label>}\n {inputAndHelp}\n </Align.Space>\n );\n};\n","// Copyright 2024 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, useState } from \"react\";\n\nimport { TimeSpan, TimeStamp } from \"@synnaxlabs/x\";\n\nimport { Text } from \"@/input/Text\";\nimport { type BaseProps } from \"@/input/types\";\n\nexport interface DateTimeProps extends BaseProps<number> {}\n\nexport const DateTime = ({\n value,\n onChange,\n onBlur,\n ...props\n}: DateTimeProps): ReactElement => {\n const ts = new TimeStamp(value, \"UTC\");\n const [internalValue, setInternalValue] = useState(\n ts.fString(\"ISO\", \"local\").slice(0, -1),\n );\n const [valueIsValid, setValueIsValid] = useState(true);\n\n const handleChange = (next: string | number): void => {\n let nextStr = next.toString();\n setInternalValue(nextStr);\n\n let ts = new TimeStamp(next, \"UTC\");\n if (nextStr.length < 23) nextStr += \".000\";\n\n ts = ts.add(\n BigInt(\n TimeStamp.now().date().getTimezoneOffset() - ts.date().getTimezoneOffset(),\n ) * TimeSpan.MINUTE.valueOf(),\n );\n let ok = false;\n try {\n const str = ts.fString(\"ISO\", \"local\");\n ok = str.slice(0, -1) === nextStr;\n } catch (_) {\n console.error(\"e\");\n }\n if (!ok) {\n setValueIsValid(false);\n return;\n }\n onChange(Number(ts.valueOf()));\n setValueIsValid(true);\n };\n\n const handleBlur: React.FocusEventHandler<HTMLInputElement> = (e) => {\n setValueIsValid(true);\n setInternalValue(new TimeStamp(value, \"UTC\").fString(\"ISO\", \"local\").slice(0, -1));\n onBlur?.(e);\n };\n\n return (\n <Text\n type=\"datetime-local\"\n onBlur={handleBlur}\n required={false}\n value={\n valueIsValid\n ? new TimeStamp(value, \"UTC\").fString(\"ISO\", \"local\").slice(0, -1)\n : internalValue\n }\n onChange={handleChange}\n {...props}\n />\n );\n};\n"],"names":["jsx","Text.Text","CSS","jsxs","direction","Align.Space","TimeStamp","useState","ts","TimeSpan","Text"],"mappings":";;;;;;;AAiCO,MAAM,WAAW,CAAC;AAAA,EACvB;AAAA,EACA,UAAU;AAAA,EACV,GAAG;AACL,MACEA,2BAAA,kBAAA;AAAA,EAACC,OAAK;AAAA,EAAL;AAAA,IACC,WAAWC,IAAA;AAAA,MACTA,IAAA,IAAI,EAAE,iBAAiB;AAAA,MACvBA,QAAI,GAAG,mBAAmB,OAAO;AAAA,MACjC;AAAA,IACF;AAAA,IACA,OAAM;AAAA,IACL,GAAG;AAAA,EAAA;AACN;ACfK,MAAM,QAAQ,CAAC;AAAA,EACpB;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA,GAAG;AACL,MAAgC;AAE5B,SAAAC,2BAAA,kBAAA,KAAC,SAAM,EAAA,WAAWD,IAAI,IAAAA,IAAA,IAAI,EAAE,aAAa,GAAG,SAAS,GAAI,GAAG,OACzD,UAAA;AAAA,IAAA;AAAA,IAAS;AAAA,IAAE,6DAAa,QAAK,EAAA,WAAWA,IAAAA,IAAI,EAAE,oBAAoB,GAAG,UAAC,KAAA;AAAA,EACzE,EAAA,CAAA;AAEJ;ACXA,MAAM,wBAAwB,CAC5B,OACA,MAAuB,QACH;AACpB,MAAI,SAAS;AAAa,WAAA;AAC1B,SAAOE,IAAAA,EAAU,UAAU,GAAG,MAAM,MAAM,YAAY;AACxD;AAEO,MAAM,OAAO,CAAC;AAAA,EACnB;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA,WAAAA,aAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,cAAc;AAAA,EACd;AAAA,EACA,eAAe;AAAA,EACf,GAAG;AACL,MAA+B;AACzB,MAAA;AACA,MAAA,iBAAiB,SAA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AAO;AAExB,QAAIC,MAAK,IAAIF,WAAAA,EAAU,MAAM,KAAK;AAClC,QAAI,QAAQ,SAAS;AAAe,iBAAA;AAEpCE,UAAKA,IAAG;AAAA,MACN;AAAA,QACEF,aAAU,IAAI,EAAE,KAAK,EAAE,sBAAsBE,IAAG,KAAK,EAAE,kBAAkB;AAAA,MAAA,IACvEC,WAAS,EAAA,OAAO,QAAQ;AAAA,IAAA;AAE9B,QAAI,KAAK;AACL,QAAA;AACF,YAAM,MAAMD,IAAG,QAAQ,OAAO,OAAO;AACrC,WAAK,IAAI,MAAM,GAAG,EAAE,MAAM;AAAA,aACnB,GAAG;AACV,cAAQ,MAAM,GAAG;AAAA,IACnB;AACA,QAAI,CAAC,IAAI;AACP,sBAAgB,KAAK;AACrB;AAAA,IACF;AACA,aAAS,OAAOA,IAAG,QAAQ,CAAC,CAAC;AAC7B,oBAAgB,IAAI;AAAA,EAAA;AAGhB,QAAA,aAAwD,CAAC,MAAM;AACnE,oBAAgB,IAAI;AACpB,qBAAiB,IAAIF,WAAA,EAAU,OAAO,KAAK,EAAE,QAAQ,OAAO,OAAO,EAAE,MAAM,GAAG,EAAE,CAAC;AACjF,qCAAS;AAAA,EAAC;AAIV,SAAAN,2BAAA,kBAAA;AAAA,IAACU,OAAA;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,OACE,eACI,IAAIJ,WAAA,EAAU,OAAO,KAAK,EAAE,QAAQ,OAAO,OAAO,EAAE,MAAM,GAAG,EAAE,IAC/D;AAAA,MAEN,UAAU;AAAA,MACT,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"external-D_yXh8rn.cjs","sources":["../src/input/HelpText.tsx","../src/input/Label.tsx","../src/input/Item.tsx","../src/input/DateTime.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 required?: boolean;\n}\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 * @param props.required - Indicate whether the label is associated with a required\n * input.\n */\nexport const Label = ({\n className,\n required = false,\n children,\n ...props\n}: LabelProps): ReactElement => {\n return (\n <label className={CSS(CSS.B(\"input-label\"), className)} {...props}>\n {children} {required && <span className={CSS.B(\"required-indicator\")}>*</span>}\n </label>\n );\n};\n","// Copyright 2023 Synnax Labs, Inc.\n//\n// Use of this software is governed by the Business Source License included in the file\n// licenses/BSL.txt.\n//\n// As of the Change Date specified in that file, in accordance with the Business Source\n// License, use of this software will be governed by the Apache License, Version 2.0,\n// included in the file licenses/APL.txt.\n\nimport { type ReactElement } from \"react\";\n\nimport { direction } from \"@synnaxlabs/x\";\n\nimport { Align } from \"@/align\";\nimport { CSS } from \"@/css\";\nimport { HelpText } from \"@/input/HelpText\";\nimport { Label } from \"@/input/Label\";\n\nimport \"@/input/Item.css\";\nimport { status } from \"@/status/aether\";\n\nexport interface ItemProps extends Align.SpaceProps {\n label?: string;\n required?: boolean;\n showLabel?: boolean;\n helpText?: string;\n padHelpText?: boolean;\n helpTextVariant?: status.Variant;\n showHelpText?: boolean;\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 required,\n align,\n size = \"small\",\n padHelpText = false,\n helpTextVariant,\n showHelpText = true,\n ...props\n}: ItemProps): ReactElement => {\n let inputAndHelp: ReactElement;\n if (showHelpText === false && showLabel === false) return <>{children}</>;\n if (direction === \"x\")\n inputAndHelp = (\n <Align.Space direction=\"y\" size=\"small\">\n {children}\n {(padHelpText || (helpText != null && helpText.length > 0)) && (\n <HelpText variant={helpTextVariant}>{helpText}</HelpText>\n )}\n </Align.Space>\n );\n else\n inputAndHelp = (\n <Align.Space direction=\"y\" size={1 / 3}>\n {children}\n {(padHelpText || (helpText != null && helpText.length > 0)) && (\n <HelpText variant={helpTextVariant}>{helpText}</HelpText>\n )}\n </Align.Space>\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 required={required}>{label}</Label>}\n {inputAndHelp}\n </Align.Space>\n );\n};\n","// Copyright 2024 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, useState } from \"react\";\n\nimport { TimeSpan, TimeStamp } from \"@synnaxlabs/x\";\n\nimport { Text } from \"@/input/Text\";\nimport { type BaseProps } from \"@/input/types\";\n\nexport interface DateTimeProps extends BaseProps<number> {}\n\nexport const DateTime = ({\n value,\n onChange,\n onBlur,\n ...props\n}: DateTimeProps): ReactElement => {\n const ts = new TimeStamp(value, \"UTC\");\n const [internalValue, setInternalValue] = useState(\n ts.fString(\"ISO\", \"local\").slice(0, -1),\n );\n const [valueIsValid, setValueIsValid] = useState(true);\n\n const handleChange = (next: string | number): void => {\n let nextStr = next.toString();\n setInternalValue(nextStr);\n\n let ts = new TimeStamp(next, \"UTC\");\n if (nextStr.length < 23) nextStr += \".000\";\n\n ts = ts.add(\n BigInt(\n TimeStamp.now().date().getTimezoneOffset() - ts.date().getTimezoneOffset(),\n ) * TimeSpan.MINUTE.valueOf(),\n );\n let ok = false;\n try {\n const str = ts.fString(\"ISO\", \"local\");\n ok = str.slice(0, -1) === nextStr;\n } catch (_) {\n console.error(\"e\");\n }\n if (!ok) {\n setValueIsValid(false);\n return;\n }\n onChange(Number(ts.valueOf()));\n setValueIsValid(true);\n };\n\n const handleBlur: React.FocusEventHandler<HTMLInputElement> = (e) => {\n setValueIsValid(true);\n setInternalValue(new TimeStamp(value, \"UTC\").fString(\"ISO\", \"local\").slice(0, -1));\n onBlur?.(e);\n };\n\n return (\n <Text\n type=\"datetime-local\"\n onBlur={handleBlur}\n required={false}\n value={\n valueIsValid\n ? new TimeStamp(value, \"UTC\").fString(\"ISO\", \"local\").slice(0, -1)\n : internalValue\n }\n onChange={handleChange}\n {...props}\n />\n );\n};\n"],"names":["jsx","Text.Text","CSS","jsxs","direction","Align.Space","TimeStamp","useState","ts","TimeSpan","Text"],"mappings":";;;;;;;AAiCO,MAAM,WAAW,CAAC;AAAA,EACvB;AAAA,EACA,UAAU;AAAA,EACV,GAAG;AACL,MACEA,2BAAA,kBAAA;AAAA,EAACC,OAAK;AAAA,EAAL;AAAA,IACC,WAAWC,IAAA;AAAA,MACTA,IAAA,IAAI,EAAE,iBAAiB;AAAA,MACvBA,QAAI,GAAG,mBAAmB,OAAO;AAAA,MACjC;AAAA,IACF;AAAA,IACA,OAAM;AAAA,IACL,GAAG;AAAA,EAAA;AACN;ACfK,MAAM,QAAQ,CAAC;AAAA,EACpB;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA,GAAG;AACL,MAAgC;AAE5B,SAAAC,2BAAA,kBAAA,KAAC,SAAM,EAAA,WAAWD,IAAI,IAAAA,IAAA,IAAI,EAAE,aAAa,GAAG,SAAS,GAAI,GAAG,OACzD,UAAA;AAAA,IAAA;AAAA,IAAS;AAAA,IAAE,6DAAa,QAAK,EAAA,WAAWA,IAAAA,IAAI,EAAE,oBAAoB,GAAG,UAAC,KAAA;AAAA,EACzE,EAAA,CAAA;AAEJ;ACXA,MAAM,wBAAwB,CAC5B,OACA,MAAuB,QACH;AACpB,MAAI,SAAS;AAAa,WAAA;AAC1B,SAAOE,IAAAA,EAAU,UAAU,GAAG,MAAM,MAAM,YAAY;AACxD;AAEO,MAAM,OAAO,CAAC;AAAA,EACnB;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA,WAAAA,aAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,cAAc;AAAA,EACd;AAAA,EACA,eAAe;AAAA,EACf,GAA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3.cjs");
5
- const Link = require("./Link-BdWFvK8v.cjs");
6
- const css = require("./css-Pf9qxhQ4.cjs");
7
- const aggregator = require("./aggregator-BpfMBUD1.cjs");
8
- require("./Center-5NJ61qfA.cjs");
9
- const List = require("./List-PlMTfEHi.cjs");
4
+ const Toggle = require("./Toggle-D3iCEbO1.cjs");
5
+ const Link = require("./Link-Bq38h1dw.cjs");
6
+ const css = require("./css-Ci8WUD5E.cjs");
7
+ const aggregator = require("./aggregator-Bh2Kyzkg.cjs");
8
+ require("./Center-Cc_rR5pQ.cjs");
9
+ const List = require("./List-BnB-C5vQ.cjs");
10
10
  const shouldExpand = (node, expanded) => expanded.includes(node.key);
11
11
  const sortAndSplice = (nodes, sort) => {
12
12
  if (sort) {
@@ -368,4 +368,4 @@ const external = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProp
368
368
  use
369
369
  }, Symbol.toStringTag, { value: "Module" }));
370
370
  exports.external = external;
371
- //# sourceMappingURL=external-CPx8XA9-.cjs.map
371
+ //# sourceMappingURL=external-Df0D1YYb.cjs.map