softable-pixels-web 1.1.23 → 1.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{BasePopover-CES18mzR.js → BasePopover-2xiaqZ18.js} +3 -3
- package/dist/{BasePopover-CES18mzR.js.map → BasePopover-2xiaqZ18.js.map} +1 -1
- package/dist/{Button-Cbt1knrt.js → Button-O1qTryxl.js} +3 -3
- package/dist/{Button-Cbt1knrt.js.map → Button-O1qTryxl.js.map} +1 -1
- package/dist/{CheckItem-CJqWCE1W.js → CheckItem-De_SUcso.js} +4 -4
- package/dist/{CheckItem-CJqWCE1W.js.map → CheckItem-De_SUcso.js.map} +1 -1
- package/dist/{Checkbox-j9ZnSxT7.js → Checkbox-CIuviq1A.js} +4 -4
- package/dist/{Checkbox-j9ZnSxT7.js.map → Checkbox-CIuviq1A.js.map} +1 -1
- package/dist/Chip-DsY37srY.js +71 -0
- package/dist/Chip-DsY37srY.js.map +1 -0
- package/dist/ChipList-CqSzk5g9.js +113 -0
- package/dist/ChipList-CqSzk5g9.js.map +1 -0
- package/dist/{ContextMenu-D7lPQcw1.js → ContextMenu-WC9Anmmu.js} +5 -5
- package/dist/{ContextMenu-D7lPQcw1.js.map → ContextMenu-WC9Anmmu.js.map} +1 -1
- package/dist/ErrorMessage-CXCrWEmT.js +49 -0
- package/dist/ErrorMessage-CXCrWEmT.js.map +1 -0
- package/dist/{Icon-KzwFJI_k.js → Icon-gUBGQxTT.js} +2 -2
- package/dist/{Icon-KzwFJI_k.js.map → Icon-gUBGQxTT.js.map} +1 -1
- package/dist/{IconButton-B_yAoSQR.js → IconButton-B4fwoP1l.js} +2 -2
- package/dist/{IconButton-B_yAoSQR.js.map → IconButton-B4fwoP1l.js.map} +1 -1
- package/dist/{InfoSummary-Cf2ein9V.js → InfoSummary-ascvleeB.js} +3 -3
- package/dist/{InfoSummary-Cf2ein9V.js.map → InfoSummary-ascvleeB.js.map} +1 -1
- package/dist/{Input-7z9sFjK3.js → Input-DCWrv5D5.js} +6 -17
- package/dist/Input-DCWrv5D5.js.map +1 -0
- package/dist/{MaskModule-DBNrJACG.js → MaskModule-vY-mW0qU.js} +1 -1
- package/dist/{MaskModule-DBNrJACG.js.map → MaskModule-vY-mW0qU.js.map} +1 -1
- package/dist/{Popover-CNon8bZo.js → Popover-DFBRJr1m.js} +4 -4
- package/dist/{Popover-CNon8bZo.js.map → Popover-DFBRJr1m.js.map} +1 -1
- package/dist/{Select-CGWL6BOg.js → Select-FQSkNBPP.js} +6 -17
- package/dist/{Select-CGWL6BOg.js.map → Select-FQSkNBPP.js.map} +1 -1
- package/dist/{Switch-DJNZbvzy.js → Switch-DDuUYo3m.js} +2 -2
- package/dist/{Switch-DJNZbvzy.js.map → Switch-DDuUYo3m.js.map} +1 -1
- package/dist/{TabSwitch-DlXdgLPc.js → TabSwitch-BLHRKyvG.js} +3 -3
- package/dist/{TabSwitch-DlXdgLPc.js.map → TabSwitch-BLHRKyvG.js.map} +1 -1
- package/dist/{TextArea-DHUTFFOU.js → TextArea-Bxmzvxva.js} +6 -17
- package/dist/TextArea-Bxmzvxva.js.map +1 -0
- package/dist/{ThemeContext-DhXvmWKO.js → ThemeContext-DenX6j5W.js} +1 -1
- package/dist/{ThemeContext-DhXvmWKO.js.map → ThemeContext-DenX6j5W.js.map} +1 -1
- package/dist/{Typography-BkFV7BhK.js → Typography-nqFP5MkW.js} +2 -2
- package/dist/{Typography-BkFV7BhK.js.map → Typography-nqFP5MkW.js.map} +1 -1
- package/dist/base-popover.d.ts +3 -3
- package/dist/base-popover.js +5 -5
- package/dist/button.d.ts +2 -2
- package/dist/button.js +3 -3
- package/dist/check-item.d.ts +1 -1
- package/dist/check-item.js +4 -4
- package/dist/checkbox.d.ts +2 -2
- package/dist/checkbox.js +4 -4
- package/dist/chip-list.d.ts +2 -0
- package/dist/chip-list.js +7 -0
- package/dist/chip.d.ts +8 -0
- package/dist/chip.js +5 -0
- package/dist/context-menu.d.ts +1 -1
- package/dist/context-menu.js +8 -8
- package/dist/icon-button.d.ts +1 -1
- package/dist/icon-button.js +2 -2
- package/dist/{index-BjwQCXWj.d.ts → index-6m6Fg-qd.d.ts} +1 -1
- package/dist/{index-CYnINkUh.d.ts → index-7BdW8AIv.d.ts} +2 -2
- package/dist/{index-CEk3W9fj.d.ts → index-BAX61Ma3.d.ts} +1 -1
- package/dist/{index-BeZYjWoj.d.ts → index-BDE35oLr.d.ts} +1 -1
- package/dist/{index-Cl2z9ftU.d.ts → index-BUx7qGRJ.d.ts} +2 -10
- package/dist/{index-BhxcqGNw.d.ts → index-BimyGo_D.d.ts} +2 -2
- package/dist/{index-CK68mp8m.d.ts → index-BpaG3kK1.d.ts} +2 -2
- package/dist/{index-B6t8KE4A.d.ts → index-CZZPzAHE.d.ts} +2 -2
- package/dist/{index-CPoGZ0_L.d.ts → index-Cc4A-sGZ.d.ts} +5 -13
- package/dist/{index-BNPyjNve.d.ts → index-DaiZNOFe.d.ts} +1 -1
- package/dist/{index-Dp4TTO2D.d.ts → index-DzpZursa.d.ts} +4 -12
- package/dist/{index-DUP_xS5q.d.ts → index-F_qxigTi.d.ts} +4 -4
- package/dist/{index-Chi8TU12.d.ts → index-HRno-aue.d.ts} +1 -1
- package/dist/index-cjiRvXzl.d.ts +27 -0
- package/dist/{index-BY84CAyh.d.ts → index-zzy7gR26.d.ts} +2 -2
- package/dist/index.d.ts +19 -16
- package/dist/index.js +24 -22
- package/dist/info-summary.js +3 -3
- package/dist/input.d.ts +1 -1
- package/dist/input.js +6 -6
- package/dist/mask-modules.d.ts +1 -1
- package/dist/mask-modules.js +1 -1
- package/dist/popover.d.ts +2 -2
- package/dist/popover.js +4 -4
- package/dist/select.d.ts +2 -2
- package/dist/select.js +9 -9
- package/dist/{styleProps-CWZn-ouw.d.ts → styleProps-XIo7Z2e1.d.ts} +1 -1
- package/dist/switch.d.ts +1 -1
- package/dist/switch.js +2 -2
- package/dist/tab-switch.d.ts +1 -1
- package/dist/tab-switch.js +3 -3
- package/dist/text-area.d.ts +1 -1
- package/dist/text-area.js +5 -5
- package/dist/theme-context.d.ts +1 -1
- package/dist/theme-context.js +1 -1
- package/dist/{types-Bayf6NdC.d.ts → types-BD5gMrsh.d.ts} +3 -3
- package/dist/types-C5BOgrpY.d.ts +19 -0
- package/dist/{types-BIJRqScJ.d.ts → types-DnV82Kzx.d.ts} +1 -1
- package/dist/{types-BM6zJmu5.d.ts → types-pbsJG9um.d.ts} +3 -3
- package/dist/typography.d.ts +1 -1
- package/dist/typography.js +2 -2
- package/dist/use-dismiss.js +1 -1
- package/dist/use-floating.d.ts +1 -1
- package/dist/use-floating.js +1 -1
- package/dist/{useDismiss-DwQfMU11.js → useDismiss-1hdSJRjS.js} +1 -1
- package/dist/{useDismiss-DwQfMU11.js.map → useDismiss-1hdSJRjS.js.map} +1 -1
- package/dist/{useFloating-DCxblHIR.js → useFloating-CPegpcJ0.js} +1 -1
- package/dist/{useFloating-DCxblHIR.js.map → useFloating-CPegpcJ0.js.map} +1 -1
- package/dist/{useThemedStyles-BUR6rDGs.d.ts → useThemedStyles-Bc7Fn_iZ.d.ts} +1 -1
- package/dist/{useThemedStyles-CrarDyWc.js → useThemedStyles-wIbjybs1.js} +1 -1
- package/dist/{useThemedStyles-CrarDyWc.js.map → useThemedStyles-wIbjybs1.js.map} +1 -1
- package/package.json +9 -1
- package/dist/Input-7z9sFjK3.js.map +0 -1
- package/dist/Label-BHq2knad.js +0 -25
- package/dist/Label-BHq2knad.js.map +0 -1
- package/dist/TextArea-DHUTFFOU.js.map +0 -1
- /package/dist/{chunk-SwsWFa5-.js → chunk-D2fR7Rao.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as styled, t as useThemedStyles } from "./useThemedStyles-
|
|
2
|
-
import { t as Popover } from "./Popover-
|
|
1
|
+
import { n as styled, t as useThemedStyles } from "./useThemedStyles-wIbjybs1.js";
|
|
2
|
+
import { t as Popover } from "./Popover-DFBRJr1m.js";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/components/commons/structure/BasePopover/styles.ts
|
|
@@ -49,4 +49,4 @@ const BasePopover = (props) => {
|
|
|
49
49
|
|
|
50
50
|
//#endregion
|
|
51
51
|
export { BasePopover as t };
|
|
52
|
-
//# sourceMappingURL=BasePopover-
|
|
52
|
+
//# sourceMappingURL=BasePopover-2xiaqZ18.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasePopover-
|
|
1
|
+
{"version":3,"file":"BasePopover-2xiaqZ18.js","names":["BasePopover: React.FC<BasePopoverProps>"],"sources":["../src/components/commons/structure/BasePopover/styles.ts","../src/components/commons/structure/BasePopover/index.tsx"],"sourcesContent":["// Types\nimport type { BasePopoverProps } from './types'\nimport { styled } from '@hooks/useThemedStyles/types'\n\nexport function createBasePopoverStyles({\n maxWidth = 'unset',\n minWidth = 'fit-content',\n minHeight = 'fit-content',\n maxHeight = '15rem',\n panel\n}: BasePopoverProps) {\n return styled({\n content: {\n minWidth,\n maxWidth,\n minHeight,\n maxHeight,\n\n display: 'flex',\n flexDirection: 'column',\n\n zIndex: 10,\n\n overflowY: 'auto',\n overflowX: 'hidden',\n overscrollBehavior: 'contain',\n\n borderWidth: 1,\n rowGap: '0.25rem',\n padding: panel?.padding ? panel.padding : '0.5rem',\n borderRadius: '0.75rem',\n\n backgroundColor: 'var(--px-bg)',\n boxShadow: 'var(--px-shadow-default)',\n borderColor: 'var(--px-border-primary)'\n }\n })\n}\n","// External Libraries\nimport type React from 'react'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Components\nimport { Popover } from '@components/commons/toolkit/Popover'\n\n// Types\nimport type { BasePopoverProps } from './types'\n\n// Styles\nimport { createBasePopoverStyles } from './styles'\n\nexport const BasePopover: React.FC<BasePopoverProps> = props => {\n const { children, ...rest } = props\n\n const { styles } = useThemedStyles(props, createBasePopoverStyles, {\n applyCommonProps: false,\n pick: p => [p.open, p.trigger]\n })\n\n return (\n <Popover\n p={0}\n hideShadow\n {...rest}\n content={({ widthTrigger }) => (\n <div style={{ ...styles.content, width: widthTrigger }}>{children}</div>\n )}\n />\n )\n}\n"],"mappings":";;;;;AAIA,SAAgB,wBAAwB,EACtC,WAAW,SACX,WAAW,eACX,YAAY,eACZ,YAAY,SACZ,SACmB;AACnB,QAAO,OAAO,EACZ,SAAS;EACP;EACA;EACA;EACA;EAEA,SAAS;EACT,eAAe;EAEf,QAAQ;EAER,WAAW;EACX,WAAW;EACX,oBAAoB;EAEpB,aAAa;EACb,QAAQ;EACR,SAAS,OAAO,UAAU,MAAM,UAAU;EAC1C,cAAc;EAEd,iBAAiB;EACjB,WAAW;EACX,aAAa;EACd,EACF,CAAC;;;;;ACrBJ,MAAaA,eAA0C,UAAS;CAC9D,MAAM,EAAE,UAAU,GAAG,SAAS;CAE9B,MAAM,EAAE,WAAW,gBAAgB,OAAO,yBAAyB;EACjE,kBAAkB;EAClB,OAAM,MAAK,CAAC,EAAE,MAAM,EAAE,QAAQ;EAC/B,CAAC;AAEF,QACE,oBAAC;EACC,GAAG;EACH;EACA,GAAI;EACJ,UAAU,EAAE,mBACV,oBAAC;GAAI,OAAO;IAAE,GAAG,OAAO;IAAS,OAAO;IAAc;GAAG;IAAe;GAE1E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as styled, t as useThemedStyles } from "./useThemedStyles-
|
|
2
|
-
import { t as Typography } from "./Typography-
|
|
1
|
+
import { n as styled, t as useThemedStyles } from "./useThemedStyles-wIbjybs1.js";
|
|
2
|
+
import { t as Typography } from "./Typography-nqFP5MkW.js";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { AnimatePresence, motion } from "framer-motion";
|
|
5
5
|
|
|
@@ -202,4 +202,4 @@ const Button = ({ type = "button", variant = "filled", ...rest }) => {
|
|
|
202
202
|
|
|
203
203
|
//#endregion
|
|
204
204
|
export { Button as t };
|
|
205
|
-
//# sourceMappingURL=Button-
|
|
205
|
+
//# sourceMappingURL=Button-O1qTryxl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button-Cbt1knrt.js","names":["getBorder","createButtonLoaderStyles","getBorder","Loader: React.FC<LoaderProps>","createButtonLoaderStyles","ButtonLoader: React.FC<Props>","Button: React.FC<ButtonProps>"],"sources":["../src/utils/animations/spiner.ts","../src/components/commons/toolkit/Loader/constants.ts","../src/components/commons/toolkit/Loader/utils.ts","../src/components/commons/toolkit/Loader/styles.ts","../src/components/commons/toolkit/Loader/index.tsx","../src/components/commons/buttons/Button/components/ButtonLoader/styles.ts","../src/components/commons/buttons/Button/components/ButtonLoader/index.tsx","../src/components/commons/buttons/Button/styles.ts","../src/components/commons/buttons/Button/index.tsx"],"sourcesContent":["export const SPINNER_ANIMATION = {\n animate: { rotate: 360 },\n transition: {\n repeat: Infinity,\n duration: 1,\n ease: 'linear'\n }\n}\n","const DEFAULT_SIZE = '20px'\nconst DEFAULT_THICKNESS = '2px'\n\nconst DEFAULT_COLOR = 'white'\nconst DEFAULT_EMPTY_COLOR = 'transparent'\n\nexport { DEFAULT_SIZE, DEFAULT_THICKNESS, DEFAULT_COLOR, DEFAULT_EMPTY_COLOR }\n","// Utils\nimport { DEFAULT_THICKNESS, DEFAULT_EMPTY_COLOR } from './constants'\n\n// Types\nimport type { LoaderProps } from './types'\n\nexport function getBorder(props: LoaderProps) {\n const thickness = props.thickness || DEFAULT_THICKNESS\n const emptyColor = props.emptyColor || DEFAULT_EMPTY_COLOR\n\n return `${thickness} solid ${emptyColor}`\n}\n","// Types\nimport { styled, type StyleMap } from '@hooks/useThemedStyles/types'\nimport type { LoaderProps } from './types'\nimport { getBorder } from './utils'\nimport { DEFAULT_COLOR, DEFAULT_SIZE } from './constants'\n\nexport function createButtonLoaderStyles(props: LoaderProps): StyleMap {\n return styled({\n container: {\n display: ' inline-block',\n\n width: props.size || DEFAULT_SIZE,\n height: props.size || DEFAULT_SIZE,\n\n borderRadius: '50%',\n border: getBorder(props),\n borderLeftColor: props.color || DEFAULT_COLOR\n }\n })\n}\n","// External Libraries\nimport type React from 'react'\nimport { motion } from 'framer-motion'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Utils\nimport { SPINNER_ANIMATION } from '@utils/animations'\n\n// Types\nimport type { LoaderProps } from './types'\n\n// Styles\nimport { createButtonLoaderStyles } from './styles'\n\nexport const Loader: React.FC<LoaderProps> = props => {\n // Hooks\n const { styles } = useThemedStyles(props, createButtonLoaderStyles, {})\n\n return (\n <motion.div\n role=\"status\"\n aria-label=\"Loading\"\n style={styles.container}\n {...SPINNER_ANIMATION}\n />\n )\n}\n","// Types\nimport { styled, type StyleMap } from '@hooks/useThemedStyles/types'\n\nexport function createButtonLoaderStyles(): StyleMap {\n return styled({\n container: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n\n borderRadius: 'var(--px-border-radius-button)'\n }\n })\n}\n","// External Libraries\nimport type React from 'react'\nimport { motion } from 'framer-motion'\n\n// Components\nimport { Loader } from '@components/commons/toolkit/Loader'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Styles\nimport { createButtonLoaderStyles } from './styles'\n\ntype Props = {\n color: string\n}\n\nexport const ButtonLoader: React.FC<Props> = ({ color }) => {\n // Hooks\n const { styles } = useThemedStyles({}, createButtonLoaderStyles, {})\n\n return (\n <motion.div\n style={styles.container}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n >\n <Loader color={color} />\n </motion.div>\n )\n}\n","// Types\nimport { styled } from '@hooks/useThemedStyles/types'\nimport type { ButtonProps, ButtonSize, ButtonVariant } from './types'\n\nexport function createButtonStyles({\n size,\n color,\n variant,\n fullWidth,\n textAlign,\n outlineColor\n}: ButtonProps) {\n const finalVariant = variant ?? 'filled'\n\n return styled({\n container: {\n minHeight: getSize(size ?? 'md'),\n width: fullWidth ? '100%' : 'fit-content',\n\n position: 'relative',\n display: 'flex',\n justifyContent: textAlign || 'center',\n\n padding: '10px var(--px-space-xl)',\n gap: 'var(--px-space-sm)',\n\n borderRadius: 'var(--px-radius-lg)',\n\n cursor: 'pointer',\n\n transition: 'background-color 0.5s',\n\n border: getBorder(finalVariant, outlineColor || color),\n backgroundColor: getBackgroundColor(finalVariant, color),\n boxShadow: variant === 'outlined' ? 'var(--px-shadow-xs)' : 'none',\n\n __rules: {\n '&:hover': {\n opacity: '0.85 !important'\n },\n '&:disabled': {\n opacity: '0.5 !important',\n cursor: 'not-allowed !important'\n }\n }\n },\n\n content: {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n\n padding: '0',\n borderRadius: 'inherit',\n\n whiteSpace: 'nowrap',\n columnGap: 'var(--px-space-sm)'\n }\n })\n}\n\nfunction getSize(size: ButtonSize | string): string {\n switch (size) {\n case 'lg':\n return '3.25rem'\n case 'md':\n return '2.75rem'\n case 'sm':\n return '2.25rem'\n case 'xs':\n return '1.75rem'\n default:\n return size\n }\n}\n\nfunction getBackgroundColor(variant: ButtonVariant, color?: string): string {\n if (color) return color\n\n if (variant === 'filled') return 'var(--px-btn-filled-bg)'\n\n if (variant === 'outlined') return 'transparent'\n\n if (variant === 'ghost') return 'transparent'\n\n return 'var(--px-btn-filled-bg)'\n}\n\nfunction getBorder(variant: ButtonVariant, color?: string): string {\n if (color) return `1px solid ${color}`\n\n if (variant === 'filled') return '1px solid var(--px-btn-filled-bg)'\n\n if (variant === 'outlined') return '1px solid var(--px-border-primary)'\n\n if (variant === 'ghost') return 'none'\n\n return '1px solid var(--px-color-primary)'\n}\n\nexport function getTextColor({ variant, labelColor }: ButtonProps): string {\n if (labelColor) return labelColor\n\n if (variant === 'filled') return 'var(--px-btn-filled-label)'\n\n if (variant === 'outlined') return 'var(--px-btn-outlined-label)'\n\n if (variant === 'ghost') return '--px-btn-ghost-label'\n\n return 'var(--px-btn-filled-label)'\n}\n","// External Libraries\nimport type React from 'react'\nimport type { MouseEvent } from 'react'\nimport { AnimatePresence } from 'framer-motion'\n\n// Components\nimport { ButtonLoader } from './components/ButtonLoader'\nimport { Typography } from '@components/commons/toolkit/Typography'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Types\nimport type { ButtonProps } from './types'\n\n// Styles\nimport { createButtonStyles, getTextColor } from './styles'\n\nexport const Button: React.FC<ButtonProps> = ({\n type = 'button',\n variant = 'filled',\n ...rest\n}) => {\n // Constants\n const disabled = rest.disabled || rest.loading\n const resolvedProps = { type, variant, disabled, ...rest }\n const textColor = getTextColor(resolvedProps)\n const { label, endIcon, startIcon, loading } = resolvedProps\n\n // Hooks\n const { styles, classes } = useThemedStyles(\n resolvedProps,\n createButtonStyles,\n {\n override: rest.styles,\n applyCommonProps: true,\n commonSlot: 'container',\n pick: p => [p.disabled, p.loading, p.label, p.color]\n }\n )\n\n // Functions\n function handleButtonClick(event: MouseEvent<HTMLButtonElement>) {\n if (disabled) return\n\n if (rest.onClick) rest.onClick(event)\n }\n\n return (\n <button\n type={type}\n disabled={disabled}\n aria-busy={rest.loading}\n style={styles.container}\n className={classes.container}\n onClick={handleButtonClick}\n >\n <div style={styles.content}>\n {startIcon ?? null}\n\n <Typography\n color={textColor}\n fontSize={resolvedProps.fontSize}\n variant={rest.labelVariant || 'b1'}\n >\n {label}\n </Typography>\n\n {endIcon ?? null}\n\n {loading ? (\n <AnimatePresence>\n <ButtonLoader color={textColor} />\n </AnimatePresence>\n ) : null}\n </div>\n </button>\n )\n}\n"],"mappings":";;;;;;AAAA,MAAa,oBAAoB;CAC/B,SAAS,EAAE,QAAQ,KAAK;CACxB,YAAY;EACV,QAAQ;EACR,UAAU;EACV,MAAM;EACP;CACF;;;;ACPD,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAE1B,MAAM,gBAAgB;AACtB,MAAM,sBAAsB;;;;ACE5B,SAAgBA,YA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,YAAY;EACZ,OAAM,MAAK;GAAC,EAAE;GAAU,EAAE;GAAS,EAAE;GAAO,EAAE;GAAM;EACrD,CACF;CAGD,SAAS,kBAAkB,OAAsC;AAC/D,MAAI,SAAU;AAEd,MAAI,KAAK,QAAS,MAAK,QAAQ,MAAM;;AAGvC,QACE,oBAAC;EACO;EACI;EACV,aAAW,KAAK;EAChB,OAAO,OAAO;EACd,WAAW,QAAQ;EACnB,SAAS;YAET,qBAAC;GAAI,OAAO,OAAO;;IAChB,aAAa;IAEd,oBAAC;KACC,OAAO;KACP,UAAU,cAAc;KACxB,SAAS,KAAK,gBAAgB;eAE7B;MACU;IAEZ,WAAW;IAEX,UACC,oBAAC,6BACC,oBAAC,gBAAa,OAAO,YAAa,GAClB,GAChB;;IACA;GACC"}
|
|
1
|
+
{"version":3,"file":"Button-O1qTryxl.js","names":["getBorder","createButtonLoaderStyles","getBorder","Loader: React.FC<LoaderProps>","createButtonLoaderStyles","ButtonLoader: React.FC<Props>","Button: React.FC<ButtonProps>"],"sources":["../src/utils/animations/spiner.ts","../src/components/commons/toolkit/Loader/constants.ts","../src/components/commons/toolkit/Loader/utils.ts","../src/components/commons/toolkit/Loader/styles.ts","../src/components/commons/toolkit/Loader/index.tsx","../src/components/commons/buttons/Button/components/ButtonLoader/styles.ts","../src/components/commons/buttons/Button/components/ButtonLoader/index.tsx","../src/components/commons/buttons/Button/styles.ts","../src/components/commons/buttons/Button/index.tsx"],"sourcesContent":["export const SPINNER_ANIMATION = {\n animate: { rotate: 360 },\n transition: {\n repeat: Infinity,\n duration: 1,\n ease: 'linear'\n }\n}\n","const DEFAULT_SIZE = '20px'\nconst DEFAULT_THICKNESS = '2px'\n\nconst DEFAULT_COLOR = 'white'\nconst DEFAULT_EMPTY_COLOR = 'transparent'\n\nexport { DEFAULT_SIZE, DEFAULT_THICKNESS, DEFAULT_COLOR, DEFAULT_EMPTY_COLOR }\n","// Utils\nimport { DEFAULT_THICKNESS, DEFAULT_EMPTY_COLOR } from './constants'\n\n// Types\nimport type { LoaderProps } from './types'\n\nexport function getBorder(props: LoaderProps) {\n const thickness = props.thickness || DEFAULT_THICKNESS\n const emptyColor = props.emptyColor || DEFAULT_EMPTY_COLOR\n\n return `${thickness} solid ${emptyColor}`\n}\n","// Types\nimport { styled, type StyleMap } from '@hooks/useThemedStyles/types'\nimport type { LoaderProps } from './types'\nimport { getBorder } from './utils'\nimport { DEFAULT_COLOR, DEFAULT_SIZE } from './constants'\n\nexport function createButtonLoaderStyles(props: LoaderProps): StyleMap {\n return styled({\n container: {\n display: ' inline-block',\n\n width: props.size || DEFAULT_SIZE,\n height: props.size || DEFAULT_SIZE,\n\n borderRadius: '50%',\n border: getBorder(props),\n borderLeftColor: props.color || DEFAULT_COLOR\n }\n })\n}\n","// External Libraries\nimport type React from 'react'\nimport { motion } from 'framer-motion'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Utils\nimport { SPINNER_ANIMATION } from '@utils/animations'\n\n// Types\nimport type { LoaderProps } from './types'\n\n// Styles\nimport { createButtonLoaderStyles } from './styles'\n\nexport const Loader: React.FC<LoaderProps> = props => {\n // Hooks\n const { styles } = useThemedStyles(props, createButtonLoaderStyles, {})\n\n return (\n <motion.div\n role=\"status\"\n aria-label=\"Loading\"\n style={styles.container}\n {...SPINNER_ANIMATION}\n />\n )\n}\n","// Types\nimport { styled, type StyleMap } from '@hooks/useThemedStyles/types'\n\nexport function createButtonLoaderStyles(): StyleMap {\n return styled({\n container: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n\n borderRadius: 'var(--px-border-radius-button)'\n }\n })\n}\n","// External Libraries\nimport type React from 'react'\nimport { motion } from 'framer-motion'\n\n// Components\nimport { Loader } from '@components/commons/toolkit/Loader'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Styles\nimport { createButtonLoaderStyles } from './styles'\n\ntype Props = {\n color: string\n}\n\nexport const ButtonLoader: React.FC<Props> = ({ color }) => {\n // Hooks\n const { styles } = useThemedStyles({}, createButtonLoaderStyles, {})\n\n return (\n <motion.div\n style={styles.container}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n >\n <Loader color={color} />\n </motion.div>\n )\n}\n","// Types\nimport { styled } from '@hooks/useThemedStyles/types'\nimport type { ButtonProps, ButtonSize, ButtonVariant } from './types'\n\nexport function createButtonStyles({\n size,\n color,\n variant,\n fullWidth,\n textAlign,\n outlineColor\n}: ButtonProps) {\n const finalVariant = variant ?? 'filled'\n\n return styled({\n container: {\n minHeight: getSize(size ?? 'md'),\n width: fullWidth ? '100%' : 'fit-content',\n\n position: 'relative',\n display: 'flex',\n justifyContent: textAlign || 'center',\n\n padding: '10px var(--px-space-xl)',\n gap: 'var(--px-space-sm)',\n\n borderRadius: 'var(--px-radius-lg)',\n\n cursor: 'pointer',\n\n transition: 'background-color 0.5s',\n\n border: getBorder(finalVariant, outlineColor || color),\n backgroundColor: getBackgroundColor(finalVariant, color),\n boxShadow: variant === 'outlined' ? 'var(--px-shadow-xs)' : 'none',\n\n __rules: {\n '&:hover': {\n opacity: '0.85 !important'\n },\n '&:disabled': {\n opacity: '0.5 !important',\n cursor: 'not-allowed !important'\n }\n }\n },\n\n content: {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n\n padding: '0',\n borderRadius: 'inherit',\n\n whiteSpace: 'nowrap',\n columnGap: 'var(--px-space-sm)'\n }\n })\n}\n\nfunction getSize(size: ButtonSize | string): string {\n switch (size) {\n case 'lg':\n return '3.25rem'\n case 'md':\n return '2.75rem'\n case 'sm':\n return '2.25rem'\n case 'xs':\n return '1.75rem'\n default:\n return size\n }\n}\n\nfunction getBackgroundColor(variant: ButtonVariant, color?: string): string {\n if (color) return color\n\n if (variant === 'filled') return 'var(--px-btn-filled-bg)'\n\n if (variant === 'outlined') return 'transparent'\n\n if (variant === 'ghost') return 'transparent'\n\n return 'var(--px-btn-filled-bg)'\n}\n\nfunction getBorder(variant: ButtonVariant, color?: string): string {\n if (color) return `1px solid ${color}`\n\n if (variant === 'filled') return '1px solid var(--px-btn-filled-bg)'\n\n if (variant === 'outlined') return '1px solid var(--px-border-primary)'\n\n if (variant === 'ghost') return 'none'\n\n return '1px solid var(--px-color-primary)'\n}\n\nexport function getTextColor({ variant, labelColor }: ButtonProps): string {\n if (labelColor) return labelColor\n\n if (variant === 'filled') return 'var(--px-btn-filled-label)'\n\n if (variant === 'outlined') return 'var(--px-btn-outlined-label)'\n\n if (variant === 'ghost') return '--px-btn-ghost-label'\n\n return 'var(--px-btn-filled-label)'\n}\n","// External Libraries\nimport type React from 'react'\nimport type { MouseEvent } from 'react'\nimport { AnimatePresence } from 'framer-motion'\n\n// Components\nimport { ButtonLoader } from './components/ButtonLoader'\nimport { Typography } from '@components/commons/toolkit/Typography'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Types\nimport type { ButtonProps } from './types'\n\n// Styles\nimport { createButtonStyles, getTextColor } from './styles'\n\nexport const Button: React.FC<ButtonProps> = ({\n type = 'button',\n variant = 'filled',\n ...rest\n}) => {\n // Constants\n const disabled = rest.disabled || rest.loading\n const resolvedProps = { type, variant, disabled, ...rest }\n const textColor = getTextColor(resolvedProps)\n const { label, endIcon, startIcon, loading } = resolvedProps\n\n // Hooks\n const { styles, classes } = useThemedStyles(\n resolvedProps,\n createButtonStyles,\n {\n override: rest.styles,\n applyCommonProps: true,\n commonSlot: 'container',\n pick: p => [p.disabled, p.loading, p.label, p.color]\n }\n )\n\n // Functions\n function handleButtonClick(event: MouseEvent<HTMLButtonElement>) {\n if (disabled) return\n\n if (rest.onClick) rest.onClick(event)\n }\n\n return (\n <button\n type={type}\n disabled={disabled}\n aria-busy={rest.loading}\n style={styles.container}\n className={classes.container}\n onClick={handleButtonClick}\n >\n <div style={styles.content}>\n {startIcon ?? null}\n\n <Typography\n color={textColor}\n fontSize={resolvedProps.fontSize}\n variant={rest.labelVariant || 'b1'}\n >\n {label}\n </Typography>\n\n {endIcon ?? null}\n\n {loading ? (\n <AnimatePresence>\n <ButtonLoader color={textColor} />\n </AnimatePresence>\n ) : null}\n </div>\n </button>\n )\n}\n"],"mappings":";;;;;;AAAA,MAAa,oBAAoB;CAC/B,SAAS,EAAE,QAAQ,KAAK;CACxB,YAAY;EACV,QAAQ;EACR,UAAU;EACV,MAAM;EACP;CACF;;;;ACPD,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAE1B,MAAM,gBAAgB;AACtB,MAAM,sBAAsB;;;;ACE5B,SAAgBA,YAAU,OAAoB;AAI5C,QAAO,GAHW,MAAM,aAAa,kBAGjB,SAFD,MAAM,cAAc;;;;;ACFzC,SAAgBC,2BAAyB,OAA8B;AACrE,QAAO,OAAO,EACZ,WAAW;EACT,SAAS;EAET,OAAO,MAAM,QAAQ;EACrB,QAAQ,MAAM,QAAQ;EAEtB,cAAc;EACd,QAAQC,YAAU,MAAM;EACxB,iBAAiB,MAAM,SAAS;EACjC,EACF,CAAC;;;;;ACFJ,MAAaC,UAAgC,UAAS;CAEpD,MAAM,EAAE,WAAW,gBAAgB,OAAOC,4BAA0B,EAAE,CAAC;AAEvE,QACE,oBAAC,OAAO;EACN,MAAK;EACL,cAAW;EACX,OAAO,OAAO;EACd,GAAI;GACJ;;;;;ACvBN,SAAgB,2BAAqC;AACnD,QAAO,OAAO,EACZ,WAAW;EACT,UAAU;EACV,KAAK;EACL,MAAM;EACN,OAAO;EACP,QAAQ;EAER,SAAS;EACT,YAAY;EACZ,gBAAgB;EAEhB,cAAc;EACf,EACF,CAAC;;;;;ACDJ,MAAaC,gBAAiC,EAAE,YAAY;CAE1D,MAAM,EAAE,WAAW,gBAAgB,EAAE,EAAE,0BAA0B,EAAE,CAAC;AAEpE,QACE,oBAAC,OAAO;EACN,OAAO,OAAO;EACd,SAAS,EAAE,SAAS,GAAG;EACvB,SAAS,EAAE,SAAS,GAAG;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AEjC,KAAI,YAAY,WAAY,QAAO;AAEnC,KAAI,YAAY,QAAS,QAAO;AAEhC,QAAO;;;;;AC3FT,MAAaC,UAAiC,EAC5C,OAAO,UACP,UAAU,UACV,GAAG,WACC;CAEJ,MAAM,WAAW,KAAK,YAAY,KAAK;CACvC,MAAM,gBAAgB;EAAE;EAAM;EAAS;EAAU,GAAG;EAAM;CAC1D,MAAM,YAAY,aAAa,cAAc;CAC7C,MAAM,EAAE,OAAO,SAAS,WAAW,YAAY;CAG/C,MAAM,EAAE,QAAQ,YAAY,gBAC1B,eACA,oBACA;EACE,UAAU,KAAK;EACf,kBAAkB;EAClB,YAAY;EACZ,OAAM,MAAK;GAAC,EAAE;GAAU,EAAE;GAAS,EAAE;GAAO,EAAE;GAAM;EACrD,CACF;CAGD,SAAS,kBAAkB,OAAsC;AAC/D,MAAI,SAAU;AAEd,MAAI,KAAK,QAAS,MAAK,QAAQ,MAAM;;AAGvC,QACE,oBAAC;EACO;EACI;EACV,aAAW,KAAK;EAChB,OAAO,OAAO;EACd,WAAW,QAAQ;EACnB,SAAS;YAET,qBAAC;GAAI,OAAO,OAAO;;IAChB,aAAa;IAEd,oBAAC;KACC,OAAO;KACP,UAAU,cAAc;KACxB,SAAS,KAAK,gBAAgB;eAE7B;MACU;IAEZ,WAAW;IAEX,UACC,oBAAC,6BACC,oBAAC,gBAAa,OAAO,YAAa,GAClB,GAChB;;IACA;GACC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as styled, t as useThemedStyles } from "./useThemedStyles-
|
|
2
|
-
import { t as Icon } from "./Icon-
|
|
3
|
-
import { t as Typography } from "./Typography-
|
|
1
|
+
import { n as styled, t as useThemedStyles } from "./useThemedStyles-wIbjybs1.js";
|
|
2
|
+
import { t as Icon } from "./Icon-gUBGQxTT.js";
|
|
3
|
+
import { t as Typography } from "./Typography-nqFP5MkW.js";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
|
|
6
6
|
//#region src/components/commons/toolkit/CheckItem/styles.ts
|
|
@@ -45,4 +45,4 @@ const CheckItem = (props) => {
|
|
|
45
45
|
|
|
46
46
|
//#endregion
|
|
47
47
|
export { CheckItem as t };
|
|
48
|
-
//# sourceMappingURL=CheckItem-
|
|
48
|
+
//# sourceMappingURL=CheckItem-De_SUcso.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckItem-
|
|
1
|
+
{"version":3,"file":"CheckItem-De_SUcso.js","names":["CheckItem: React.FC<CheckItemProps>"],"sources":["../src/components/commons/toolkit/CheckItem/styles.ts","../src/components/commons/toolkit/CheckItem/index.tsx"],"sourcesContent":["// Types\nimport type { CheckItemProps } from './types'\nimport { styled, type StyleMap } from '@hooks/useThemedStyles/types'\n\nexport function createCheckItemStyles({ checked }: CheckItemProps): StyleMap {\n return styled({\n container: {\n display: 'flex',\n flexDirection: 'row',\n columnGap: 'var(--px-space-sm)'\n },\n\n iconContainer: {\n width: '20px',\n height: '20px',\n\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n\n backgroundColor: checked\n ? 'var(--px-color-success)'\n : 'var(--px-color-disabled)',\n\n borderRadius: '50%'\n }\n })\n}\n","// External Libraries\nimport type React from 'react'\n\n// Components\nimport { Icon } from '../Icon'\nimport { Typography } from '../Typography'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Types\nimport type { CheckItemProps } from './types'\n\n// Styles\nimport { createCheckItemStyles } from './styles'\n\nexport const CheckItem: React.FC<CheckItemProps> = props => {\n // Hooks\n const { styles } = useThemedStyles(props, createCheckItemStyles)\n\n return (\n <div style={styles.container}>\n <div style={styles.iconContainer}>\n <Icon name=\"general-check\" color=\"white\" size=\"sm\" />\n </div>\n\n <Typography variant=\"b2\">{props.label}</Typography>\n </div>\n )\n}\n"],"mappings":";;;;;;AAIA,SAAgB,sBAAsB,EAAE,WAAqC;AAC3E,QAAO,OAAO;EACZ,WAAW;GACT,SAAS;GACT,eAAe;GACf,WAAW;GACZ;EAED,eAAe;GACb,OAAO;GACP,QAAQ;GAER,SAAS;GACT,YAAY;GACZ,gBAAgB;GAEhB,iBAAiB,UACb,4BACA;GAEJ,cAAc;GACf;EACF,CAAC;;;;;ACVJ,MAAaA,aAAsC,UAAS;CAE1D,MAAM,EAAE,WAAW,gBAAgB,OAAO,sBAAsB;AAEhE,QACE,qBAAC;EAAI,OAAO,OAAO;aACjB,oBAAC;GAAI,OAAO,OAAO;aACjB,oBAAC;IAAK,MAAK;IAAgB,OAAM;IAAQ,MAAK;KAAO;IACjD,EAEN,oBAAC;GAAW,SAAQ;aAAM,MAAM;IAAmB;GAC/C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as styled, t as useThemedStyles } from "./useThemedStyles-
|
|
2
|
-
import { t as Icon } from "./Icon-
|
|
3
|
-
import { t as Typography } from "./Typography-
|
|
1
|
+
import { n as styled, t as useThemedStyles } from "./useThemedStyles-wIbjybs1.js";
|
|
2
|
+
import { t as Icon } from "./Icon-gUBGQxTT.js";
|
|
3
|
+
import { t as Typography } from "./Typography-nqFP5MkW.js";
|
|
4
4
|
import { useId } from "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { Checkbox, Label } from "radix-ui";
|
|
@@ -165,4 +165,4 @@ const Checkbox$1 = (props) => {
|
|
|
165
165
|
|
|
166
166
|
//#endregion
|
|
167
167
|
export { Checkbox$1 as t };
|
|
168
|
-
//# sourceMappingURL=Checkbox-
|
|
168
|
+
//# sourceMappingURL=Checkbox-CIuviq1A.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox-
|
|
1
|
+
{"version":3,"file":"Checkbox-CIuviq1A.js","names":["Label: React.FC<LabelProps>","LabelRadix","CHECKBOX_STYLES: Record<string, StyleMap>","Checkbox: React.FC<CheckboxProps>","CheckboxRadix","checked","Label"],"sources":["../src/components/commons/toolkit/Checkbox/components/Label/styles.ts","../src/components/commons/toolkit/Checkbox/components/Label/index.tsx","../src/components/commons/toolkit/Checkbox/hooks/useCheckbox.ts","../src/components/commons/toolkit/Checkbox/styles.ts","../src/utils/functions/getContrastingTextColor.ts","../src/components/commons/toolkit/Checkbox/index.tsx"],"sourcesContent":["// Types\nimport type { LabelProps } from './types'\nimport { styled, type StyleMap } from '@hooks/useThemedStyles/types'\n\nexport function createLabelStyles(props: LabelProps): StyleMap {\n const { disabled } = props\n\n return styled({\n container: {\n userSelect: 'none',\n opacity: disabled ? 0.6 : 1,\n cursor: disabled ? 'not-allowed' : 'pointer',\n\n transition: 'all 200ms',\n\n __rules: {\n ':hover': { color: 'var(--px-color-secondary)' }\n }\n }\n })\n}\n","// External libraries\nimport { Label as LabelRadix } from 'radix-ui'\n\n// Components\nimport { Typography } from '@components/commons/toolkit/Typography'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Types\nimport type { LabelProps } from './types'\n\n// Styles\nimport { createLabelStyles } from './styles'\n\nexport const Label: React.FC<LabelProps> = props => {\n const { idFor, label, labelVariant } = props\n\n // Hooks\n const { styles } = useThemedStyles(props, createLabelStyles, {\n pick: p => [p.disabled, p.labelVariant, p.label],\n applyCommonProps: true\n })\n\n return (\n <LabelRadix.Root htmlFor={idFor} style={styles.container}>\n <Typography variant={labelVariant ?? 'b1'} fontWeight=\"regular\">\n {label}\n </Typography>\n </LabelRadix.Root>\n )\n}\n","// External libraries\nimport { useId } from 'react'\n\nexport function useCheckbox() {\n return {\n id: useId()\n }\n}\n","// Types\nimport type { CheckboxProps } from './types'\nimport { styled, type StyleMap } from '@hooks/useThemedStyles/types'\n\nexport const CHECKBOX_STYLES: Record<string, StyleMap> = {\n size: {\n sm: { width: '1rem', height: '1rem' },\n md: { width: '1.25rem', height: '1.25rem' },\n lg: { width: '1.5rem', height: '1.5rem' }\n },\n radius: {\n none: { borderRadius: 0 },\n sm: { borderRadius: '0.25rem' },\n md: { borderRadius: '0.375rem' },\n lg: { borderRadius: '0.5rem' },\n full: { borderRadius: '100%' }\n }\n}\n\nexport function createCheckBoxStyles(props: CheckboxProps) {\n const {\n color,\n checked,\n size = 'md',\n radius = 'md',\n disabled = false,\n labelPlacement = 'right'\n } = props\n\n const focusIndicatorOffsetColor = '#fff'\n\n return styled({\n container: {\n display: 'flex',\n columnGap: '0.5rem',\n alignItems: 'center',\n '--px-ring-color': color ?? undefined,\n flexDirection: labelPlacement === 'right' ? 'row' : 'row-reverse'\n },\n\n root: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n\n backgroundColor: checked ? color : 'white',\n borderWidth: '1px',\n borderStyle: 'solid',\n borderColor: checked ? color : 'var(--px-border-primary, #e5e7eb)',\n\n transition: 'color 200ms',\n opacity: disabled ? 0.5 : 1,\n cursor: disabled ? 'not-allowed' : 'pointer',\n\n ...(CHECKBOX_STYLES.size[size] as any),\n ...(CHECKBOX_STYLES.radius[radius] as any),\n\n __rules: {\n '&:hover': { borderColor: 'var(--px-border-secondary, #e5e7eb)' },\n '&:focus-visible': {\n outline: 'none',\n boxShadow: `0 0 0 2px ${focusIndicatorOffsetColor}, 0 0 0 4px var(--px-ring-color, #2b2b2bff)`\n }\n }\n },\n\n indicator: {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n color: 'var(--px-text-primary, #4b5563)'\n }\n })\n}\n","/**\n * Returns the contrasting text color for a given background color.\n * @param backgroundColor hexadecimal color (i.e.: \"#ffffff\", \"#000\", \"#ffcc00\")\n */\nexport function getContrastingTextColor(\n backgroundColor: string\n): 'black' | 'white' {\n let hex = backgroundColor.replace('#', '')\n\n if (hex.length === 3) {\n hex = hex\n .split('')\n .map(c => c + c)\n .join('')\n }\n\n if (hex.length === 8) {\n hex = hex.substring(0, 6)\n }\n\n if (hex.length !== 6) return 'black'\n\n const r = parseInt(hex.substring(0, 2), 16)\n const g = parseInt(hex.substring(2, 4), 16)\n const b = parseInt(hex.substring(4, 6), 16)\n\n const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255\n\n return luminance > 0.6 ? 'black' : 'white'\n}\n","// External Libraries\nimport type React from 'react'\nimport { Checkbox as CheckboxRadix } from 'radix-ui'\n\n// Components\nimport { Icon } from '../Icon'\nimport { Label } from './components/Label'\n\n// Hooks\nimport { useCheckbox } from './hooks/useCheckbox'\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Types\nimport type { CheckboxProps } from './types'\n\n// Styles\nimport { createCheckBoxStyles } from './styles'\nimport { getContrastingTextColor } from '@utils/functions'\n\nexport const Checkbox: React.FC<CheckboxProps> = props => {\n const {\n icon,\n label,\n color,\n labelVariant,\n checked = false,\n disabled = false,\n onChange\n } = props\n\n const iconColor = color ? getContrastingTextColor(color) : undefined\n\n // Hooks\n const { id } = useCheckbox()\n\n const { styles, classes } = useThemedStyles(props, createCheckBoxStyles)\n\n return (\n <div style={styles.container}>\n <CheckboxRadix.Root\n style={styles.root}\n className={classes.root}\n id={id}\n tabIndex={0}\n checked={checked}\n disabled={disabled}\n onCheckedChange={checked => onChange(checked === true)}\n >\n <CheckboxRadix.Indicator style={styles.indicator}>\n {icon ?? <Icon name=\"general-check\" size=\"sm\" color={iconColor} />}\n </CheckboxRadix.Indicator>\n </CheckboxRadix.Root>\n\n {label ? (\n <Label\n idFor={id}\n label={label}\n disabled={disabled}\n labelVariant={labelVariant}\n />\n ) : null}\n </div>\n )\n}\n"],"mappings":";;;;;;;;AAIA,SAAgB,kBAAkB,OAA6B;CAC7D,MAAM,EAAE,aAAa;AAErB,QAAO,OAAO,EACZ,WAAW;EACT,YAAY;EACZ,SAAS,WAAW,KAAM;EAC1B,QAAQ,WAAW,gBAAgB;EAEnC,YAAY;EAEZ,SAAS,EACP,UAAU,EAAE,OAAO,6BAA6B,EACjD;EACF,EACF,CAAC;;;;;ACJJ,MAAaA,WAA8B,UAAS;CAClD,MAAM,EAAE,OAAO,OAAO,iBAAiB;CAGvC,MAAM,EAAE,WAAW,gBAAgB,OAAO,mBAAmB;EAC3D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wIbjybs1.js";
|
|
2
|
+
import { t as Typography } from "./Typography-nqFP5MkW.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/components/commons/toolkit/Chip/styles.ts
|
|
6
|
+
function createChipStyles(props) {
|
|
7
|
+
return styled({ container: {
|
|
8
|
+
display: "flex",
|
|
9
|
+
alignItems: "center",
|
|
10
|
+
borderWidth: 1,
|
|
11
|
+
columnGap: "0.25rem",
|
|
12
|
+
borderRadius: "0.5rem",
|
|
13
|
+
paddingBlock: "0.25rem",
|
|
14
|
+
paddingRight: "0.625rem",
|
|
15
|
+
paddingLeft: props.data.icon ? "0.5rem" : "0.625rem",
|
|
16
|
+
cursor: !props.viewOnly ? "pointer" : "default",
|
|
17
|
+
boxShadow: "var(--px-shadow-default)",
|
|
18
|
+
borderColor: "var(--px-border-primary)",
|
|
19
|
+
color: props.isSelected ? "white" : "var(--px-text-primary)",
|
|
20
|
+
backgroundColor: props.isSelected ? "var(--px-color-primary)" : "var(--px-bg)",
|
|
21
|
+
userSelect: props.viewOnly ? "auto" : "none",
|
|
22
|
+
MozUserSelect: props.viewOnly ? "auto" : "none",
|
|
23
|
+
msUserSelect: props.viewOnly ? "inherit" : "none",
|
|
24
|
+
WebkitUserSelect: props.viewOnly ? "auto" : "none",
|
|
25
|
+
transition: "background-color 0.25s ease-out",
|
|
26
|
+
opacity: checkDisabled(props) ? .5 : 1,
|
|
27
|
+
__rules: {
|
|
28
|
+
"&:hover": { opacity: props.viewOnly ? 1 : .85 },
|
|
29
|
+
"&:disabled": {
|
|
30
|
+
opacity: "0.5 !important",
|
|
31
|
+
cursor: "not-allowed !important"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
} });
|
|
35
|
+
}
|
|
36
|
+
function checkDisabled(props) {
|
|
37
|
+
if (!props.viewOnly) return false;
|
|
38
|
+
return props.listDisabled || props.data.disabled;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/components/commons/toolkit/Chip/types.ts
|
|
43
|
+
var types_exports = {};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/components/commons/toolkit/Chip/index.tsx
|
|
47
|
+
const Chip = (props) => {
|
|
48
|
+
const { styles, classes } = useThemedStyles(props, createChipStyles);
|
|
49
|
+
const Component = props.viewOnly ? "span" : "button";
|
|
50
|
+
const isDisabled = props.listDisabled || props.data.disabled;
|
|
51
|
+
function handleClick() {
|
|
52
|
+
if (isDisabled || props.viewOnly) return;
|
|
53
|
+
props.onClick?.(props.data);
|
|
54
|
+
}
|
|
55
|
+
return /* @__PURE__ */ jsxs(Component, {
|
|
56
|
+
disabled: isDisabled,
|
|
57
|
+
style: styles.container,
|
|
58
|
+
className: classes.container,
|
|
59
|
+
onClick: handleClick,
|
|
60
|
+
children: [props.data.icon, /* @__PURE__ */ jsx(Typography, {
|
|
61
|
+
variant: "b2",
|
|
62
|
+
lineHeight: "1.25rem",
|
|
63
|
+
color: "inherit",
|
|
64
|
+
children: props.data.label
|
|
65
|
+
})]
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
export { types_exports as n, Chip as t };
|
|
71
|
+
//# sourceMappingURL=Chip-DsY37srY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Chip-DsY37srY.js","names":["Chip: React.FC<ChipProps>"],"sources":["../src/components/commons/toolkit/Chip/styles.ts","../src/components/commons/toolkit/Chip/types.ts","../src/components/commons/toolkit/Chip/index.tsx"],"sourcesContent":["// Types\nimport type { ChipProps } from './types'\nimport { styled } from '@hooks/useThemedStyles/types'\n\nexport function createChipStyles(props: ChipProps) {\n return styled({\n container: {\n display: 'flex',\n alignItems: 'center',\n\n borderWidth: 1,\n columnGap: '0.25rem',\n borderRadius: '0.5rem',\n paddingBlock: '0.25rem',\n paddingRight: '0.625rem',\n paddingLeft: props.data.icon ? '0.5rem' : '0.625rem',\n\n cursor: !props.viewOnly ? 'pointer' : 'default',\n\n boxShadow: 'var(--px-shadow-default)',\n borderColor: 'var(--px-border-primary)',\n color: props.isSelected ? 'white' : 'var(--px-text-primary)',\n backgroundColor: props.isSelected\n ? 'var(--px-color-primary)'\n : 'var(--px-bg)',\n\n userSelect: props.viewOnly ? 'auto' : 'none',\n MozUserSelect: props.viewOnly ? 'auto' : 'none',\n msUserSelect: props.viewOnly ? 'inherit' : 'none',\n WebkitUserSelect: props.viewOnly ? 'auto' : 'none',\n\n transition: 'background-color 0.25s ease-out',\n opacity: checkDisabled(props) ? 0.5 : 1,\n\n __rules: {\n '&:hover': {\n opacity: props.viewOnly ? 1 : 0.85\n },\n\n '&:disabled': {\n opacity: '0.5 !important',\n cursor: 'not-allowed !important'\n }\n }\n }\n })\n}\n\nfunction checkDisabled(props: ChipProps) {\n if (!props.viewOnly) return false\n return props.listDisabled || props.data.disabled\n}\n","export interface ChipProps {\n data: ChipOption\n viewOnly?: boolean\n isSelected?: boolean\n listDisabled?: boolean\n\n onClick?(value: ChipOption): void\n}\n\nexport interface ChipOption {\n value: string\n label: string\n\n disabled?: boolean\n icon?: React.ReactNode\n}\n","// External Libraries\nimport type React from 'react'\n\n// Components\nimport { Typography } from '../Typography'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Types\nimport type { ChipProps } from './types'\n\n// Styles\nimport { createChipStyles } from './styles'\n\nexport * as ChipTypes from './types'\n\nexport const Chip: React.FC<ChipProps> = props => {\n // Hooks\n const { styles, classes } = useThemedStyles(props, createChipStyles)\n\n // Constants\n const Component = props.viewOnly ? 'span' : 'button'\n const isDisabled = props.listDisabled || props.data.disabled\n\n // Functions\n function handleClick() {\n if (isDisabled || props.viewOnly) return\n props.onClick?.(props.data)\n }\n\n return (\n <Component\n disabled={isDisabled}\n style={styles.container}\n className={classes.container}\n onClick={handleClick}\n >\n {props.data.icon}\n\n <Typography variant=\"b2\" lineHeight=\"1.25rem\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as styled, t as useThemedStyles } from "./useThemedStyles-wIbjybs1.js";
|
|
2
|
+
import { t as Chip } from "./Chip-DsY37srY.js";
|
|
3
|
+
import { n as Label, t as ErrorMessage } from "./ErrorMessage-CXCrWEmT.js";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/components/commons/toolkit/ChipList/components/ChipsLoader/styles.ts
|
|
8
|
+
function createChipsLoaderStyles() {
|
|
9
|
+
return styled({ container: {
|
|
10
|
+
width: "5rem",
|
|
11
|
+
height: "1.75rem",
|
|
12
|
+
display: "flex",
|
|
13
|
+
borderRadius: "0.5rem",
|
|
14
|
+
backgroundColor: "var(--px-surface)"
|
|
15
|
+
} });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/components/commons/toolkit/ChipList/components/ChipsLoader/index.tsx
|
|
20
|
+
const ChipsLoader = () => {
|
|
21
|
+
const [pulseOn, setPulseOn] = useState(true);
|
|
22
|
+
const { styles } = useThemedStyles({}, createChipsLoaderStyles);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const id = setInterval(() => setPulseOn((v) => !v), 600);
|
|
25
|
+
return () => clearInterval(id);
|
|
26
|
+
}, []);
|
|
27
|
+
function renderContent() {
|
|
28
|
+
return Array.from({ length: 5 }).map((_, idx) => {
|
|
29
|
+
const delayMs = idx * 120;
|
|
30
|
+
return /* @__PURE__ */ jsx("div", { style: {
|
|
31
|
+
...styles.container,
|
|
32
|
+
opacity: pulseOn ? 1 : .6,
|
|
33
|
+
transition: `opacity 600ms ease-in-out ${delayMs}ms`
|
|
34
|
+
} }, idx.toString());
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return /* @__PURE__ */ jsx(Fragment, { children: renderContent() });
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/components/commons/toolkit/ChipList/hooks/useChipList/index.ts
|
|
42
|
+
function useChipList({ value, canClear, multiple, onChange }) {
|
|
43
|
+
function handleChange(option) {
|
|
44
|
+
const isAlreadySelected = value.includes(option.value);
|
|
45
|
+
if (!multiple) {
|
|
46
|
+
if (isAlreadySelected) {
|
|
47
|
+
if (canClear) onChange?.([]);
|
|
48
|
+
} else onChange?.([option.value]);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (isAlreadySelected) if (value.length === 1) {
|
|
52
|
+
if (canClear) onChange?.([]);
|
|
53
|
+
} else onChange?.(value.filter((v) => v !== option.value));
|
|
54
|
+
else onChange?.([...value, option.value]);
|
|
55
|
+
}
|
|
56
|
+
return { handleChange };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/components/commons/toolkit/ChipList/styles.ts
|
|
61
|
+
function createChipListStyles() {
|
|
62
|
+
return styled({
|
|
63
|
+
container: {
|
|
64
|
+
width: "100%",
|
|
65
|
+
display: "flex",
|
|
66
|
+
flexDirection: "column",
|
|
67
|
+
rowGap: "0.375rem"
|
|
68
|
+
},
|
|
69
|
+
listContainer: {
|
|
70
|
+
width: "100%",
|
|
71
|
+
display: "flex",
|
|
72
|
+
flexWrap: "wrap",
|
|
73
|
+
gap: "0.5rem"
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/components/commons/toolkit/ChipList/index.tsx
|
|
80
|
+
const ChipList = (props) => {
|
|
81
|
+
const { handleChange } = useChipList(props);
|
|
82
|
+
const { styles } = useThemedStyles(props, createChipListStyles);
|
|
83
|
+
function renderContent() {
|
|
84
|
+
if (props.isLoading) return /* @__PURE__ */ jsx(ChipsLoader, {});
|
|
85
|
+
return props.options.map((item) => /* @__PURE__ */ jsx(Chip, {
|
|
86
|
+
data: item,
|
|
87
|
+
viewOnly: props.viewOnly,
|
|
88
|
+
listDisabled: props.disabled,
|
|
89
|
+
isSelected: props.value.includes(item.value),
|
|
90
|
+
onClick: handleChange
|
|
91
|
+
}, item.value));
|
|
92
|
+
}
|
|
93
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
94
|
+
style: styles.container,
|
|
95
|
+
children: [
|
|
96
|
+
props.hideLabel ? null : /* @__PURE__ */ jsx(Label, {
|
|
97
|
+
label: props.label,
|
|
98
|
+
required: props.required,
|
|
99
|
+
requiredColor: props.requiredColor,
|
|
100
|
+
...props.labelConfig
|
|
101
|
+
}),
|
|
102
|
+
/* @__PURE__ */ jsx("div", {
|
|
103
|
+
style: styles.listContainer,
|
|
104
|
+
children: renderContent()
|
|
105
|
+
}),
|
|
106
|
+
props.errorMessage ? /* @__PURE__ */ jsx(ErrorMessage, { message: props.errorMessage }) : null
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
export { ChipList as t };
|
|
113
|
+
//# sourceMappingURL=ChipList-CqSzk5g9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChipList-CqSzk5g9.js","names":["ChipsLoader: React.FC","ChipList: React.FC<ChipListProps>"],"sources":["../src/components/commons/toolkit/ChipList/components/ChipsLoader/styles.ts","../src/components/commons/toolkit/ChipList/components/ChipsLoader/index.tsx","../src/components/commons/toolkit/ChipList/hooks/useChipList/index.ts","../src/components/commons/toolkit/ChipList/styles.ts","../src/components/commons/toolkit/ChipList/index.tsx"],"sourcesContent":["// Types\nimport { styled } from '@hooks/useThemedStyles/types'\n\nexport function createChipsLoaderStyles() {\n return styled({\n container: {\n width: '5rem',\n height: '1.75rem',\n\n display: 'flex',\n\n borderRadius: '0.5rem',\n\n backgroundColor: 'var(--px-surface)'\n }\n })\n}\n","// External Libraries\nimport type React from 'react'\nimport { useEffect, useState } from 'react'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Styles\nimport { createChipsLoaderStyles } from './styles'\n\nexport const ChipsLoader: React.FC = () => {\n // States\n const [pulseOn, setPulseOn] = useState(true)\n\n // Hooks\n const { styles } = useThemedStyles({}, createChipsLoaderStyles)\n\n useEffect(() => {\n const id = setInterval(() => setPulseOn(v => !v), 600)\n return () => clearInterval(id)\n }, [])\n\n // Functions\n function renderContent() {\n return Array.from({ length: 5 }).map((_, idx) => {\n const delayMs = idx * 120\n\n return (\n <div\n key={idx.toString()}\n style={{\n ...styles.container,\n opacity: pulseOn ? 1 : 0.6,\n transition: `opacity 600ms ease-in-out ${delayMs}ms`\n }}\n />\n )\n })\n }\n\n return <>{renderContent()}</>\n}\n","// Types\nimport type { ChipListProps } from '../../types'\nimport type { ChipOption } from '@components/commons/toolkit/Chip/types'\n\nexport function useChipList({\n value,\n canClear,\n multiple,\n onChange\n}: ChipListProps) {\n // Functions\n function handleChange(option: ChipOption) {\n const isAlreadySelected = value.includes(option.value)\n\n if (!multiple) {\n if (isAlreadySelected) {\n if (canClear) onChange?.([])\n } else onChange?.([option.value])\n\n return\n }\n\n if (isAlreadySelected) {\n if (value.length === 1) {\n if (canClear) onChange?.([])\n } else onChange?.(value.filter(v => v !== option.value))\n } else onChange?.([...value, option.value])\n }\n\n return { handleChange }\n}\n","// Types\nimport { styled } from '@hooks/useThemedStyles/types'\n\nexport function createChipListStyles() {\n return styled({\n container: {\n width: '100%',\n\n display: 'flex',\n flexDirection: 'column',\n\n rowGap: '0.375rem'\n },\n\n listContainer: {\n width: '100%',\n\n display: 'flex',\n flexWrap: 'wrap',\n\n gap: '0.5rem'\n }\n })\n}\n","// External Libraries\nimport type React from 'react'\n\n// Components\nimport { Chip } from '../Chip'\nimport { Label } from '../Label'\nimport { ErrorMessage } from '../ErrorMessage'\nimport { ChipsLoader } from './components/ChipsLoader'\n\n// Hooks\nimport { useChipList } from './hooks/useChipList'\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Types\nimport type { ChipListProps } from './types'\n\n// Styles\nimport { createChipListStyles } from './styles'\n\nexport const ChipList: React.FC<ChipListProps> = props => {\n // Hooks\n const { handleChange } = useChipList(props)\n const { styles } = useThemedStyles(props, createChipListStyles)\n\n // Functions\n function renderContent() {\n if (props.isLoading) return <ChipsLoader />\n\n return props.options.map(item => (\n <Chip\n key={item.value}\n data={item}\n viewOnly={props.viewOnly}\n listDisabled={props.disabled}\n isSelected={props.value.includes(item.value)}\n onClick={handleChange}\n />\n ))\n }\n\n return (\n <div style={styles.container}>\n {props.hideLabel ? null : (\n <Label\n label={props.label}\n required={props.required}\n requiredColor={props.requiredColor}\n {...props.labelConfig}\n />\n )}\n\n <div style={styles.listContainer}>{renderContent()}</div>\n\n {props.errorMessage ? (\n <ErrorMessage message={props.errorMessage} />\n ) : null}\n </div>\n )\n}\n"],"mappings":";;;;;;;AAGA,SAAgB,0BAA0B;AACxC,QAAO,OAAO,EACZ,WAAW;EACT,OAAO;EACP,QAAQ;EAER,SAAS;EAET,cAAc;EAEd,iBAAiB;EAClB,EACF,CAAC;;;;;ACLJ,MAAaA,oBAA8B;CAEzC,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAG5C,MAAM,EAAE,WAAW,gBAAgB,EAAE,EAAE,wBAAwB;AAE/D,iBAAgB;EACd,MAAM,KAAK,kBAAkB,YAAW,MAAK,CAAC,EAAE,EAAE,IAAI;AACtD,eAAa,cAAc,GAAG;IAC7B,EAAE,CAAC;CAGN,SAAS,gBAAgB;AACvB,SAAO,MAAM,KAAK,EAAE,QAAQ,GAAG,CAAC,CAAC,KAAK,GAAG,QAAQ;GAC/C,MAAM,UAAU,MAAM;AAEtB,UACE,oBAAC,SAEC,OAAO;IACL,GAAG,OAAO;IACV,SAAS,UAAU,IAAI;IACvB,YAAY,6BAA6B,QAAQ;IAClD,IALI,IAAI,UAAU,CAMnB;IAEJ;;AAGJ,QAAO,0CAAG,eAAe,GAAI;;;;;ACpC/B,SAAgB,YAAY,EAC1B,OACA,UACA,UACA,YACgB;CAEhB,SAAS,aAAa,QAAoB;EACxC,MAAM,oB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
-
import { t as Switch } from "./Switch-
|
|
3
|
-
import { t as Typography } from "./Typography-
|
|
4
|
-
import { t as BasePopover } from "./BasePopover-
|
|
1
|
+
import { n as styled, t as useThemedStyles } from "./useThemedStyles-wIbjybs1.js";
|
|
2
|
+
import { t as Switch } from "./Switch-DDuUYo3m.js";
|
|
3
|
+
import { t as Typography } from "./Typography-nqFP5MkW.js";
|
|
4
|
+
import { t as BasePopover } from "./BasePopover-2xiaqZ18.js";
|
|
5
5
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
|
|
@@ -314,4 +314,4 @@ const ContextMenu = (props) => {
|
|
|
314
314
|
|
|
315
315
|
//#endregion
|
|
316
316
|
export { types_exports as n, ContextMenu as t };
|
|
317
|
-
//# sourceMappingURL=ContextMenu-
|
|
317
|
+
//# sourceMappingURL=ContextMenu-WC9Anmmu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu-D7lPQcw1.js","names":["floatingOptions: FloatingOptions","DividerRow: React.FC"],"sources":["../src/components/commons/toolkit/ContextMenu/components/Menu/components/ItemRow/styles.ts","../src/components/commons/toolkit/ContextMenu/components/Menu/components/ItemRow/index.tsx","../src/components/commons/toolkit/ContextMenu/components/Menu/components/CustomRow/styles.ts","../src/components/commons/toolkit/ContextMenu/components/Menu/components/CustomRow/index.tsx","../src/components/commons/toolkit/ContextMenu/components/Menu/components/DividerRow/styles.ts","../src/components/commons/toolkit/ContextMenu/components/Menu/components/DividerRow/index.tsx","../src/components/commons/toolkit/ContextMenu/components/Menu/styles.ts","../src/components/commons/toolkit/ContextMenu/components/Menu/index.tsx","../src/components/commons/toolkit/ContextMenu/utils/normalizeMenuOptions.ts","../src/components/commons/toolkit/ContextMenu/types.ts","../src/components/commons/toolkit/ContextMenu/styles.ts","../src/components/commons/toolkit/ContextMenu/index.tsx"],"sourcesContent":["// Types\nimport type { ItemRowProps } from './types'\nimport { styled } from '@hooks/useThemedStyles/types'\n\nexport function createItemRowStyles<T>({ item, active }: ItemRowProps<T>) {\n return styled({\n button: {\n width: '100%',\n textAlign: 'left',\n\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: '0.5rem',\n\n borderRadius: '0.5rem',\n\n paddingInline: '0.5rem',\n paddingBlock: '0.25rem',\n\n userSelect: 'none',\n\n backgroundColor:\n item.disabled || active\n ? 'var(--px-background-card-hover)'\n : 'transparent',\n\n __rules: {\n '&:hover': {\n transition: 'all 200ms',\n backgroundColor: 'var(--px-background-card-hover) !important'\n }\n }\n },\n containerIcon: {\n width: '1rem',\n flexShrink: 0,\n display: 'flex',\n alignItems: 'center'\n }\n })\n}\n","// External Libraries\nimport { useEffect, useRef, useState } from 'react'\n\n// Components\nimport { Menu } from '../..'\nimport { Switch } from '@components/commons/toolkit/Switch'\nimport { Typography } from '@components/commons/toolkit/Typography'\nimport { BasePopover } from '@components/commons/structure/BasePopover'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Types\nimport type { ItemRowProps } from './types'\nimport type { FloatingOptions } from '@hooks/useFloating/types'\n\n// Styles\nimport { createItemRowStyles } from './styles'\n\nexport const ItemRow = <T extends string>(props: ItemRowProps<T>) => {\n const { item, depth, width, onHover, onSelect } = props\n const isGroup = item.type === 'group'\n\n const [subOpen, setSubOpen] = useState(false)\n const closeTimer = useRef<number | null>(null)\n const anchorRef = useRef<HTMLButtonElement | null>(null)\n const floatingOptions: FloatingOptions = {\n offsetX: 10,\n offsetY: -4,\n strategy: 'fixed',\n keepInViewport: true,\n placement: 'right-start'\n }\n\n // Hooks\n const { styles, classes } = useThemedStyles(props, createItemRowStyles, {\n applyCommonProps: true,\n override: props.styles,\n pick: p => [p.active]\n })\n\n // Functions\n function handleMouseEnter() {\n onHover(item.id, isGroup)\n\n if (!isGroup) return\n clearTimer()\n setSubOpen(true)\n }\n\n function handleMouseLeave() {\n if (!isGroup) return\n scheduleClose()\n }\n\n function handleClick() {\n if (isGroup) return\n onSelect(item)\n }\n\n function clearTimer() {\n if (closeTimer.current) window.clearTimeout(closeTimer.current)\n closeTimer.current = null\n }\n\n function scheduleClose() {\n clearTimer()\n closeTimer.current = window.setTimeout(() => setSubOpen(false), 150)\n }\n\n function renderMenuType() {\n if (item.type === 'switch') return <Switch checked={item.checked} />\n else {\n return (\n <>\n {item.shortcut ? <span>{item.shortcut}</span> : null}\n\n {isGroup ? <span>›</span> : null}\n </>\n )\n }\n }\n\n // UseEffects\n // biome-ignore lint/correctness/useExhaustiveDependencies: <Not needed>\n useEffect(() => {\n return () => clearTimer()\n }, [])\n\n return (\n <>\n <button\n ref={anchorRef}\n type=\"button\"\n role=\"menuitem\"\n style={styles.button}\n className={classes.button}\n disabled={!!item.disabled}\n aria-disabled={item.disabled || undefined}\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n {item.icon ? (\n <span style={styles.containerIcon}>{item.icon ?? null}</span>\n ) : null}\n\n <Typography variant=\"b2\">{item.label}</Typography>\n\n {renderMenuType()}\n </button>\n\n {isGroup ? (\n <BasePopover\n // biome-ignore lint/suspicious/noExplicitAny: <Not needed>\n anchorRef={anchorRef as any}\n open={subOpen}\n closeOnEscape={false}\n closeOnOutsideClick={false}\n floatingOptions={floatingOptions}\n dismissScope={props.dismissScope}\n onMouseEnter={() => {\n clearTimer()\n setSubOpen(true)\n }}\n onMouseLeave={() => {\n scheduleClose()\n }}\n onOpenChange={setSubOpen}\n >\n <Menu\n width={width}\n depth={depth + 1}\n activeId={undefined}\n items={item.children}\n onHover={onHover}\n onSelect={onSelect}\n />\n </BasePopover>\n ) : null}\n </>\n )\n}\n","// Types\nimport { styled } from '@hooks/useThemedStyles/types'\n\nexport function createCustomRowStyles() {\n return styled({\n container: {\n padding: '0.25rem'\n }\n })\n}\n","// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Types\nimport type { CustomRowProps } from './types'\n\n// Styles\nimport { createCustomRowStyles } from './styles'\n\nexport const CustomRow = <T extends string>(props: CustomRowProps<T>) => {\n const { item, close } = props\n\n // Hooks\n const { styles } = useThemedStyles(props, createCustomRowStyles)\n\n return <div style={styles.container}>{item.render({ close })}</div>\n}\n","// Types\nimport { styled } from '@hooks/useThemedStyles/types'\n\nexport function createDividerRowStyles() {\n return styled({\n container: {\n border: 0,\n display: 'flex',\n marginBlock: '0.1rem',\n borderTop: '1px solid var(--px-border-primary)'\n }\n })\n}\n","// External Libraries\nimport type React from 'react'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Styles\nimport { createDividerRowStyles } from './styles'\n\nexport const DividerRow: React.FC = props => {\n // Hooks\n const { styles } = useThemedStyles(props, createDividerRowStyles)\n\n return <hr style={styles.container} />\n}\n","// Types\nimport type { MenuProps } from './types'\nimport { styled } from '@hooks/useThemedStyles/types'\n\nexport function createMenuStyles<T>({ width }: MenuProps<T>) {\n return styled({\n container: {\n width,\n flexShrink: 0\n }\n })\n}\n","// Components\nimport { ItemRow } from './components/ItemRow'\nimport { CustomRow } from './components/CustomRow'\nimport { DividerRow } from './components/DividerRow'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Types\nimport type { MenuProps } from './types'\n\n// Styles\nimport { createMenuStyles } from './styles'\n\nexport const Menu = <T extends string>(props: MenuProps<T>) => {\n const { items, depth, activeId, width = 240, onHover, onSelect } = props\n\n const { styles } = useThemedStyles(props, createMenuStyles, {\n applyCommonProps: true,\n override: props.styles,\n pick: p => [p.items, p.width, p.activeId, p.onSelect, p.onHover]\n })\n\n // Functions\n function renderItems() {\n return items.map(item => {\n if (item.type === 'divider') return <DividerRow key={item.id} />\n if (item.type === 'custom')\n return <CustomRow key={item.id} item={item} close={close} />\n\n return (\n <ItemRow\n key={item.id}\n item={item}\n depth={depth}\n width={width}\n active={activeId === item.id}\n dismissScope={props.dismissScope}\n onHover={onHover}\n onSelect={onSelect}\n />\n )\n })\n }\n\n return (\n <div style={styles.container} role={depth === 0 ? 'menu' : undefined}>\n {renderItems()}\n </div>\n )\n}\n","// Types\nimport type { MenuOption, MenuOptionInput } from '../types'\n\nexport function normalizeMenuOptions<T>(\n options: MenuOptionInput<T>[]\n): MenuOption<T>[] {\n return options.map(opt => {\n if ('children' in opt) {\n return {\n id: opt.id,\n label: opt.label,\n icon: opt.icon,\n shortcut: opt.shortcut,\n disabled: opt.disabled,\n className: opt.className,\n type: 'group' as const,\n children: normalizeMenuOptions(opt.children)\n }\n }\n return opt as MenuOption<T>\n })\n}\n","// External Libraries\nimport type { ReactNode } from 'react'\n\n// Hooks\nimport type { Placement } from '@hooks/useFloating/types'\n\n// Styles\nimport type { createContextMenuStyles } from './styles'\n\ninterface BaseOption<T> {\n id: T\n icon?: ReactNode\n label?: ReactNode\n disabled?: boolean\n className?: string\n shortcut?: ReactNode\n closeOnSelect?: boolean\n}\n\nexport type MenuActionOption<T> = BaseOption<T> & {\n type: 'action'\n closeOnSelect?: boolean\n}\n\nexport type MenuSwitchOption<T> = BaseOption<T> & {\n type: 'switch'\n checked: boolean\n closeOnSelect?: boolean\n onCheckedChange: (next: boolean) => void\n}\n\nexport interface MenuDividerOption<T> {\n id: T\n type: 'divider'\n}\n\nexport interface MenuCustomOption<T> extends BaseOption<T> {\n type: 'custom'\n render: (ctx: { close: () => void }) => ReactNode\n}\n\nexport interface MenuGroupInput<T> extends BaseOption<T> {\n type?: 'group'\n children: MenuOptionInput<T>[]\n}\n\nexport type MenuOptionInput<T> =\n | MenuGroupInput<T>\n | MenuActionOption<T>\n | MenuSwitchOption<T>\n | MenuCustomOption<T>\n | MenuDividerOption<T>\n\nexport interface MenuGroup<T> extends BaseOption<T> {\n type: 'group'\n children: MenuOption<T>[]\n}\n\nexport type MenuOption<T> =\n | MenuGroup<T>\n | MenuActionOption<T>\n | MenuSwitchOption<T>\n | MenuCustomOption<T>\n | MenuDividerOption<T>\n\nexport interface ContextMenuProps<T> {\n trigger: ReactNode\n options: MenuOptionInput<T>[]\n\n offsetX?: number\n offsetY?: number\n columnWidth?: number\n placement?: Placement\n\n onSelect: (actionId: T) => void\n\n styles?: Partial<ReturnType<typeof createContextMenuStyles>>\n}\n","// Types\nimport type { ContextMenuProps } from './types'\nimport { styled } from '@hooks/useThemedStyles/types'\n\nexport function createContextMenuStyles<T>(_props: ContextMenuProps<T>) {\n return styled({\n trigger: {\n width: 'fit-content',\n height: 'fit-content',\n\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n cursor: 'pointer'\n }\n })\n}\n","// External Libraries\nimport { useMemo, useRef } from 'react'\n\n// Components\nimport { Menu } from './components/Menu'\nimport { BasePopover } from '@components/commons/structure/BasePopover'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Utils\nimport { normalizeMenuOptions } from './utils'\n\n// Types\nimport type { ContextMenuProps, MenuOption } from './types'\nimport type { PopoverTriggerRenderProps } from '../Popover/types'\n\nexport * as ContextMenuTypes from './types'\n\n// Styles\nimport { createContextMenuStyles } from './styles'\n\nexport const ContextMenu = <T extends string>(props: ContextMenuProps<T>) => {\n const {\n trigger,\n options,\n offsetX = 0,\n offsetY = 8,\n columnWidth = 240,\n placement = 'bottom-start',\n onSelect\n } = props\n\n // Refs\n const scopeRef = useRef<string>(makeScopeId())\n\n const items = useMemo(() => normalizeMenuOptions(options), [options])\n const floatingOptions = useMemo(\n () => ({\n offsetX,\n offsetY,\n placement\n }),\n [offsetX, offsetY, placement]\n )\n\n // Hooks\n const { styles } = useThemedStyles(props, createContextMenuStyles, {\n applyCommonProps: true,\n override: props.styles,\n pick: p => [p.options, p.columnWidth, p.placement]\n })\n\n // Functions\n function makeScopeId() {\n if (typeof crypto !== 'undefined' && crypto.randomUUID)\n return crypto.randomUUID()\n return `scope_${Math.random().toString(16).slice(2)}`\n }\n\n function handleSelect(item: MenuOption<T>, close: () => void) {\n if (item.type === 'action') {\n onSelect(item.id)\n if (item.closeOnSelect ?? true) close()\n }\n\n if (item.type === 'switch') {\n item.onCheckedChange(!item.checked)\n if (item.closeOnSelect ?? false) close()\n }\n }\n\n function renderTrigger({\n ref,\n ariaExpanded,\n onClick\n }: PopoverTriggerRenderProps) {\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: <Not needed>\n // biome-ignore lint/a11y/useKeyWithClickEvents: <Not needed>\n <span\n ref={ref as any}\n style={styles.trigger}\n aria-expanded={ariaExpanded}\n onClick={onClick}\n >\n {trigger}\n </span>\n )\n }\n\n return (\n <BasePopover\n floatingOptions={floatingOptions}\n dismissScope={scopeRef.current}\n trigger={renderTrigger}\n >\n <Menu\n depth={0}\n items={items}\n onHover={() => {}}\n width={columnWidth}\n dismissScope={scopeRef.current}\n onSelect={item => handleSelect(item as MenuOption<T>, close)}\n />\n </BasePopover>\n )\n}\n"],"mappings":";;;;;;;;AAIA,SAAgB,oBAAuB,EAAE,MAAM,UAA2B;AACxE,QAAO,OAAO;EACZ,QAAQ;GACN,OAAO;GACP,WAAW;GAEX,SAAS;GACT,YAAY;GACZ,gBAAgB;GAChB,KAAK;GAEL,cAAc;GAEd,eAAe;GACf,cAAc;GAEd,YAAY;GAEZ,iBACE,KAAK,YAAY,SACb,oCACA;GAEN,SAAS,EACP,WAAW;IACT,YAAY;IACZ,iBAAiB;IAClB,EACF;GACF;EACD,eAAe;GACb,OAAO;GACP,YAAY;GACZ,SAAS;GACT,YAAY;GACb;EACF,CAAC;;;;;ACrBJ,MAAa,WAA6B,UAA2B;CACnE,MAAM,EAAE,MAAM,OAAO,OAAO,SAAS,aAAa;CAClD,MAAM,UAAU,KAAK,SAAS;CAE9B,MAAM,CAAC,SAAS,cAAc,SAAS,MAAM;CAC7C,MAAM,aAAa,OAAsB,KAAK;CAC9C,MAAM,YAAY,OAAiC,KAAK;CACxD,MAAMA,kBAAmC;EACvC,SAAS;EACT,SAAS;EACT,UAAU;EACV,gBAAgB;EAChB,WAAW;EACZ;CAGD,MAAM,EAAE,QAAQ,YAAY,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,MAAI,KAAK,SAAS,UAAU;AAC1B,YAAS,KAAK,GAAG;AACjB,OAAI,KAAK,iBAAiB,KAAM,UAAO;;AAGzC,MAAI,KAAK,SAAS,UAAU;AAC1B,QAAK,gBAAgB,CAAC,KAAK,QAAQ;AACnC,OAAI,KAAK,iBAAiB,MAAO,UAAO;;;CAI5C,SAAS,cAAc,EACrB,KACA,cACA,WAC4B;AAC5B,SAGE,oBAAC;GACM;GACL,OAAO,OAAO;GACd,iBAAe;GACN;aAER;IACI;;AAIX,QACE,oBAAC;EACkB;EACjB,cAAc,SAAS;EACvB,SAAS;YAET,oBAAC;GACC,OAAO;GACA;GACP,eAAe;GACf,OAAO;GACP,cAAc,SAAS;GACvB,WAAU,SAAQ,aAAa,MAAuB,MAAM;IAC5D;GACU"}
|
|
1
|
+
{"version":3,"file":"ContextMenu-WC9Anmmu.js","names":["floatingOptions: FloatingOptions","DividerRow: React.FC"],"sources":["../src/components/commons/toolkit/ContextMenu/components/Menu/components/ItemRow/styles.ts","../src/components/commons/toolkit/ContextMenu/components/Menu/components/ItemRow/index.tsx","../src/components/commons/toolkit/ContextMenu/components/Menu/components/CustomRow/styles.ts","../src/components/commons/toolkit/ContextMenu/components/Menu/components/CustomRow/index.tsx","../src/components/commons/toolkit/ContextMenu/components/Menu/components/DividerRow/styles.ts","../src/components/commons/toolkit/ContextMenu/components/Menu/components/DividerRow/index.tsx","../src/components/commons/toolkit/ContextMenu/components/Menu/styles.ts","../src/components/commons/toolkit/ContextMenu/components/Menu/index.tsx","../src/components/commons/toolkit/ContextMenu/utils/normalizeMenuOptions.ts","../src/components/commons/toolkit/ContextMenu/types.ts","../src/components/commons/toolkit/ContextMenu/styles.ts","../src/components/commons/toolkit/ContextMenu/index.tsx"],"sourcesContent":["// Types\nimport type { ItemRowProps } from './types'\nimport { styled } from '@hooks/useThemedStyles/types'\n\nexport function createItemRowStyles<T>({ item, active }: ItemRowProps<T>) {\n return styled({\n button: {\n width: '100%',\n textAlign: 'left',\n\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: '0.5rem',\n\n borderRadius: '0.5rem',\n\n paddingInline: '0.5rem',\n paddingBlock: '0.25rem',\n\n userSelect: 'none',\n\n backgroundColor:\n item.disabled || active\n ? 'var(--px-background-card-hover)'\n : 'transparent',\n\n __rules: {\n '&:hover': {\n transition: 'all 200ms',\n backgroundColor: 'var(--px-background-card-hover) !important'\n }\n }\n },\n containerIcon: {\n width: '1rem',\n flexShrink: 0,\n display: 'flex',\n alignItems: 'center'\n }\n })\n}\n","// External Libraries\nimport { useEffect, useRef, useState } from 'react'\n\n// Components\nimport { Menu } from '../..'\nimport { Switch } from '@components/commons/toolkit/Switch'\nimport { Typography } from '@components/commons/toolkit/Typography'\nimport { BasePopover } from '@components/commons/structure/BasePopover'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Types\nimport type { ItemRowProps } from './types'\nimport type { FloatingOptions } from '@hooks/useFloating/types'\n\n// Styles\nimport { createItemRowStyles } from './styles'\n\nexport const ItemRow = <T extends string>(props: ItemRowProps<T>) => {\n const { item, depth, width, onHover, onSelect } = props\n const isGroup = item.type === 'group'\n\n const [subOpen, setSubOpen] = useState(false)\n const closeTimer = useRef<number | null>(null)\n const anchorRef = useRef<HTMLButtonElement | null>(null)\n const floatingOptions: FloatingOptions = {\n offsetX: 10,\n offsetY: -4,\n strategy: 'fixed',\n keepInViewport: true,\n placement: 'right-start'\n }\n\n // Hooks\n const { styles, classes } = useThemedStyles(props, createItemRowStyles, {\n applyCommonProps: true,\n override: props.styles,\n pick: p => [p.active]\n })\n\n // Functions\n function handleMouseEnter() {\n onHover(item.id, isGroup)\n\n if (!isGroup) return\n clearTimer()\n setSubOpen(true)\n }\n\n function handleMouseLeave() {\n if (!isGroup) return\n scheduleClose()\n }\n\n function handleClick() {\n if (isGroup) return\n onSelect(item)\n }\n\n function clearTimer() {\n if (closeTimer.current) window.clearTimeout(closeTimer.current)\n closeTimer.current = null\n }\n\n function scheduleClose() {\n clearTimer()\n closeTimer.current = window.setTimeout(() => setSubOpen(false), 150)\n }\n\n function renderMenuType() {\n if (item.type === 'switch') return <Switch checked={item.checked} />\n else {\n return (\n <>\n {item.shortcut ? <span>{item.shortcut}</span> : null}\n\n {isGroup ? <span>›</span> : null}\n </>\n )\n }\n }\n\n // UseEffects\n // biome-ignore lint/correctness/useExhaustiveDependencies: <Not needed>\n useEffect(() => {\n return () => clearTimer()\n }, [])\n\n return (\n <>\n <button\n ref={anchorRef}\n type=\"button\"\n role=\"menuitem\"\n style={styles.button}\n className={classes.button}\n disabled={!!item.disabled}\n aria-disabled={item.disabled || undefined}\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n {item.icon ? (\n <span style={styles.containerIcon}>{item.icon ?? null}</span>\n ) : null}\n\n <Typography variant=\"b2\">{item.label}</Typography>\n\n {renderMenuType()}\n </button>\n\n {isGroup ? (\n <BasePopover\n // biome-ignore lint/suspicious/noExplicitAny: <Not needed>\n anchorRef={anchorRef as any}\n open={subOpen}\n closeOnEscape={false}\n closeOnOutsideClick={false}\n floatingOptions={floatingOptions}\n dismissScope={props.dismissScope}\n onMouseEnter={() => {\n clearTimer()\n setSubOpen(true)\n }}\n onMouseLeave={() => {\n scheduleClose()\n }}\n onOpenChange={setSubOpen}\n >\n <Menu\n width={width}\n depth={depth + 1}\n activeId={undefined}\n items={item.children}\n onHover={onHover}\n onSelect={onSelect}\n />\n </BasePopover>\n ) : null}\n </>\n )\n}\n","// Types\nimport { styled } from '@hooks/useThemedStyles/types'\n\nexport function createCustomRowStyles() {\n return styled({\n container: {\n padding: '0.25rem'\n }\n })\n}\n","// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Types\nimport type { CustomRowProps } from './types'\n\n// Styles\nimport { createCustomRowStyles } from './styles'\n\nexport const CustomRow = <T extends string>(props: CustomRowProps<T>) => {\n const { item, close } = props\n\n // Hooks\n const { styles } = useThemedStyles(props, createCustomRowStyles)\n\n return <div style={styles.container}>{item.render({ close })}</div>\n}\n","// Types\nimport { styled } from '@hooks/useThemedStyles/types'\n\nexport function createDividerRowStyles() {\n return styled({\n container: {\n border: 0,\n display: 'flex',\n marginBlock: '0.1rem',\n borderTop: '1px solid var(--px-border-primary)'\n }\n })\n}\n","// External Libraries\nimport type React from 'react'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Styles\nimport { createDividerRowStyles } from './styles'\n\nexport const DividerRow: React.FC = props => {\n // Hooks\n const { styles } = useThemedStyles(props, createDividerRowStyles)\n\n return <hr style={styles.container} />\n}\n","// Types\nimport type { MenuProps } from './types'\nimport { styled } from '@hooks/useThemedStyles/types'\n\nexport function createMenuStyles<T>({ width }: MenuProps<T>) {\n return styled({\n container: {\n width,\n flexShrink: 0\n }\n })\n}\n","// Components\nimport { ItemRow } from './components/ItemRow'\nimport { CustomRow } from './components/CustomRow'\nimport { DividerRow } from './components/DividerRow'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Types\nimport type { MenuProps } from './types'\n\n// Styles\nimport { createMenuStyles } from './styles'\n\nexport const Menu = <T extends string>(props: MenuProps<T>) => {\n const { items, depth, activeId, width = 240, onHover, onSelect } = props\n\n const { styles } = useThemedStyles(props, createMenuStyles, {\n applyCommonProps: true,\n override: props.styles,\n pick: p => [p.items, p.width, p.activeId, p.onSelect, p.onHover]\n })\n\n // Functions\n function renderItems() {\n return items.map(item => {\n if (item.type === 'divider') return <DividerRow key={item.id} />\n if (item.type === 'custom')\n return <CustomRow key={item.id} item={item} close={close} />\n\n return (\n <ItemRow\n key={item.id}\n item={item}\n depth={depth}\n width={width}\n active={activeId === item.id}\n dismissScope={props.dismissScope}\n onHover={onHover}\n onSelect={onSelect}\n />\n )\n })\n }\n\n return (\n <div style={styles.container} role={depth === 0 ? 'menu' : undefined}>\n {renderItems()}\n </div>\n )\n}\n","// Types\nimport type { MenuOption, MenuOptionInput } from '../types'\n\nexport function normalizeMenuOptions<T>(\n options: MenuOptionInput<T>[]\n): MenuOption<T>[] {\n return options.map(opt => {\n if ('children' in opt) {\n return {\n id: opt.id,\n label: opt.label,\n icon: opt.icon,\n shortcut: opt.shortcut,\n disabled: opt.disabled,\n className: opt.className,\n type: 'group' as const,\n children: normalizeMenuOptions(opt.children)\n }\n }\n return opt as MenuOption<T>\n })\n}\n","// External Libraries\nimport type { ReactNode } from 'react'\n\n// Hooks\nimport type { Placement } from '@hooks/useFloating/types'\n\n// Styles\nimport type { createContextMenuStyles } from './styles'\n\ninterface BaseOption<T> {\n id: T\n icon?: ReactNode\n label?: ReactNode\n disabled?: boolean\n className?: string\n shortcut?: ReactNode\n closeOnSelect?: boolean\n}\n\nexport type MenuActionOption<T> = BaseOption<T> & {\n type: 'action'\n closeOnSelect?: boolean\n}\n\nexport type MenuSwitchOption<T> = BaseOption<T> & {\n type: 'switch'\n checked: boolean\n closeOnSelect?: boolean\n onCheckedChange: (next: boolean) => void\n}\n\nexport interface MenuDividerOption<T> {\n id: T\n type: 'divider'\n}\n\nexport interface MenuCustomOption<T> extends BaseOption<T> {\n type: 'custom'\n render: (ctx: { close: () => void }) => ReactNode\n}\n\nexport interface MenuGroupInput<T> extends BaseOption<T> {\n type?: 'group'\n children: MenuOptionInput<T>[]\n}\n\nexport type MenuOptionInput<T> =\n | MenuGroupInput<T>\n | MenuActionOption<T>\n | MenuSwitchOption<T>\n | MenuCustomOption<T>\n | MenuDividerOption<T>\n\nexport interface MenuGroup<T> extends BaseOption<T> {\n type: 'group'\n children: MenuOption<T>[]\n}\n\nexport type MenuOption<T> =\n | MenuGroup<T>\n | MenuActionOption<T>\n | MenuSwitchOption<T>\n | MenuCustomOption<T>\n | MenuDividerOption<T>\n\nexport interface ContextMenuProps<T> {\n trigger: ReactNode\n options: MenuOptionInput<T>[]\n\n offsetX?: number\n offsetY?: number\n columnWidth?: number\n placement?: Placement\n\n onSelect: (actionId: T) => void\n\n styles?: Partial<ReturnType<typeof createContextMenuStyles>>\n}\n","// Types\nimport type { ContextMenuProps } from './types'\nimport { styled } from '@hooks/useThemedStyles/types'\n\nexport function createContextMenuStyles<T>(_props: ContextMenuProps<T>) {\n return styled({\n trigger: {\n width: 'fit-content',\n height: 'fit-content',\n\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n cursor: 'pointer'\n }\n })\n}\n","// External Libraries\nimport { useMemo, useRef } from 'react'\n\n// Components\nimport { Menu } from './components/Menu'\nimport { BasePopover } from '@components/commons/structure/BasePopover'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Utils\nimport { normalizeMenuOptions } from './utils'\n\n// Types\nimport type { ContextMenuProps, MenuOption } from './types'\nimport type { PopoverTriggerRenderProps } from '../Popover/types'\n\nexport * as ContextMenuTypes from './types'\n\n// Styles\nimport { createContextMenuStyles } from './styles'\n\nexport const ContextMenu = <T extends string>(props: ContextMenuProps<T>) => {\n const {\n trigger,\n options,\n offsetX = 0,\n offsetY = 8,\n columnWidth = 240,\n placement = 'bottom-start',\n onSelect\n } = props\n\n // Refs\n const scopeRef = useRef<string>(makeScopeId())\n\n const items = useMemo(() => normalizeMenuOptions(options), [options])\n const floatingOptions = useMemo(\n () => ({\n offsetX,\n offsetY,\n placement\n }),\n [offsetX, offsetY, placement]\n )\n\n // Hooks\n const { styles } = useThemedStyles(props, createContextMenuStyles, {\n applyCommonProps: true,\n override: props.styles,\n pick: p => [p.options, p.columnWidth, p.placement]\n })\n\n // Functions\n function makeScopeId() {\n if (typeof crypto !== 'undefined' && crypto.randomUUID)\n return crypto.randomUUID()\n return `scope_${Math.random().toString(16).slice(2)}`\n }\n\n function handleSelect(item: MenuOption<T>, close: () => void) {\n if (item.type === 'action') {\n onSelect(item.id)\n if (item.closeOnSelect ?? true) close()\n }\n\n if (item.type === 'switch') {\n item.onCheckedChange(!item.checked)\n if (item.closeOnSelect ?? false) close()\n }\n }\n\n function renderTrigger({\n ref,\n ariaExpanded,\n onClick\n }: PopoverTriggerRenderProps) {\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: <Not needed>\n // biome-ignore lint/a11y/useKeyWithClickEvents: <Not needed>\n <span\n ref={ref as any}\n style={styles.trigger}\n aria-expanded={ariaExpanded}\n onClick={onClick}\n >\n {trigger}\n </span>\n )\n }\n\n return (\n <BasePopover\n floatingOptions={floatingOptions}\n dismissScope={scopeRef.current}\n trigger={renderTrigger}\n >\n <Menu\n depth={0}\n items={items}\n onHover={() => {}}\n width={columnWidth}\n dismissScope={scopeRef.current}\n onSelect={item => handleSelect(item as MenuOption<T>, close)}\n />\n </BasePopover>\n )\n}\n"],"mappings":";;;;;;;;AAIA,SAAgB,oBAAuB,EAAE,MAAM,UAA2B;AACxE,QAAO,OAAO;EACZ,QAAQ;GACN,OAAO;GACP,WAAW;GAEX,SAAS;GACT,YAAY;GACZ,gBAAgB;GAChB,KAAK;GAEL,cAAc;GAEd,eAAe;GACf,cAAc;GAEd,YAAY;GAEZ,iBACE,KAAK,YAAY,SACb,oCACA;GAEN,SAAS,EACP,WAAW;IACT,YAAY;IACZ,iBAAiB;IAClB,EACF;GACF;EACD,eAAe;GACb,OAAO;GACP,YAAY;GACZ,SAAS;GACT,YAAY;GACb;EACF,CAAC;;;;;ACrBJ,MAAa,WAA6B,UAA2B;CACnE,MAAM,EAAE,MAAM,OAAO,OAAO,SAAS,aAAa;CAClD,MAAM,UAAU,KAAK,SAAS;CAE9B,MAAM,CAAC,SAAS,cAAc,SAAS,MAAM;CAC7C,MAAM,aAAa,OAAsB,KAAK;CAC9C,MAAM,YAAY,OAAiC,KAAK;CACxD,MAAMA,kBAAmC;EACvC,SAAS;EACT,SAAS;EACT,UAAU;EACV,gBAAgB;EAChB,WAAW;EACZ;CAGD,MAAM,EAAE,QAAQ,YAAY,gBAAgB,OAAO,qBAAqB;EACtE,kBAAkB;EAClB,UAAU,MAAM;EAChB,OAAM,MAAK,CAAC,EAAE,OAAO;EACtB,CAAC;CAGF,SAAS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,UAAU;AAC1B,QAAK,gBAAgB,CAAC,KAAK,QAAQ;AACnC,OAAI,KAAK,iBAAiB,MAAO,UAAO;;;CAI5C,SAAS,cAAc,EACrB,KACA,cACA,WAC4B;AAC5B,SAGE,oBAAC;GACM;GACL,OAAO,OAAO;GACd,iBAAe;GACN;aAER;IACI;;AAIX,QACE,oBAAC;EACkB;EACjB,cAAc,SAAS;EACvB,SAAS;YAET,oBAAC;GACC,OAAO;GACA;GACP,eAAe;GACf,OAAO;GACP,cAAc,SAAS;GACvB,WAAU,SAAQ,aAAa,MAAuB,MAAM;IAC5D;GACU"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { n as styled, t as useThemedStyles } from "./useThemedStyles-wIbjybs1.js";
|
|
2
|
+
import { t as Typography } from "./Typography-nqFP5MkW.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/components/commons/toolkit/Label/index.tsx
|
|
6
|
+
const Label = (props) => {
|
|
7
|
+
const { label, color, htmlFor, required, requiredColor, variant = "b2", ...rest } = props;
|
|
8
|
+
return /* @__PURE__ */ jsx("label", {
|
|
9
|
+
htmlFor,
|
|
10
|
+
children: /* @__PURE__ */ jsxs(Typography, {
|
|
11
|
+
variant,
|
|
12
|
+
color: color ?? "var(px-text-primary)",
|
|
13
|
+
...rest,
|
|
14
|
+
children: [label, required ? /* @__PURE__ */ jsxs(Typography, {
|
|
15
|
+
as: "span",
|
|
16
|
+
variant: "b2",
|
|
17
|
+
color: requiredColor ?? "var(--px-text-error)",
|
|
18
|
+
children: [" ", "*"]
|
|
19
|
+
}) : null]
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/components/commons/toolkit/ErrorMessage/styles.ts
|
|
26
|
+
function createErrorMessageStyles() {
|
|
27
|
+
return styled({ container: {
|
|
28
|
+
display: "block",
|
|
29
|
+
fontWeight: 400,
|
|
30
|
+
lineHeight: "1rem",
|
|
31
|
+
fontSize: "0.75rem",
|
|
32
|
+
fontFamily: "inherit",
|
|
33
|
+
color: "var(--px-text-error)"
|
|
34
|
+
} });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/components/commons/toolkit/ErrorMessage/index.tsx
|
|
39
|
+
const ErrorMessage = (props) => {
|
|
40
|
+
const { styles } = useThemedStyles(props, createErrorMessageStyles);
|
|
41
|
+
return /* @__PURE__ */ jsx("span", {
|
|
42
|
+
style: styles.container,
|
|
43
|
+
children: props.message
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { Label as n, ErrorMessage as t };
|
|
49
|
+
//# sourceMappingURL=ErrorMessage-CXCrWEmT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorMessage-CXCrWEmT.js","names":["Label: React.FC<LabelProps>","ErrorMessage: React.FC<ErrorMessageProps>"],"sources":["../src/components/commons/toolkit/Label/index.tsx","../src/components/commons/toolkit/ErrorMessage/styles.ts","../src/components/commons/toolkit/ErrorMessage/index.tsx"],"sourcesContent":["// Components\nimport { Typography } from '@components/commons/toolkit/Typography'\n\n// Types\nimport type { LabelProps } from './types'\n\nexport const Label: React.FC<LabelProps> = props => {\n const {\n label,\n color,\n htmlFor,\n required,\n requiredColor,\n variant = 'b2',\n ...rest\n } = props\n\n return (\n <label htmlFor={htmlFor}>\n <Typography\n variant={variant}\n color={color ?? 'var(px-text-primary)'}\n {...rest}\n >\n {label}\n\n {required ? (\n <Typography\n as=\"span\"\n variant=\"b2\"\n color={requiredColor ?? 'var(--px-text-error)'}\n >\n {' '}\n *\n </Typography>\n ) : null}\n </Typography>\n </label>\n )\n}\n","// Types\nimport { styled } from '@hooks/useThemedStyles/types'\n\nexport function createErrorMessageStyles() {\n return styled({\n container: {\n display: 'block',\n fontWeight: 400,\n lineHeight: '1rem',\n fontSize: '0.75rem',\n fontFamily: 'inherit',\n color: 'var(--px-text-error)'\n }\n })\n}\n","// External Libraries\nimport type React from 'react'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Types\nimport type { ErrorMessageProps } from './types'\n\n// Styles\nimport { createErrorMessageStyles } from './styles'\n\nexport const ErrorMessage: React.FC<ErrorMessageProps> = props => {\n // Hooks\n const { styles } = useThemedStyles(props, createErrorMessageStyles)\n\n return <span style={styles.container}>{props.message}</span>\n}\n"],"mappings":";;;;;AAMA,MAAaA,SAA8B,UAAS;CAClD,MAAM,EACJ,OACA,OACA,SACA,UACA,eACA,UAAU,MACV,GAAG,SACD;AAEJ,QACE,oBAAC;EAAe;YACd,qBAAC;GACU;GACT,OAAO,SAAS;GAChB,GAAI;cAEH,OAEA,WACC,qBAAC;IACC,IAAG;IACH,SAAQ;IACR,OAAO,iBAAiB;eAEvB,KAAI;KAEM,GACX;IACO;GACP;;;;;AClCZ,SAAgB,2BAA2B;AACzC,QAAO,OAAO,EACZ,WAAW;EACT,SAAS;EACT,YAAY;EACZ,YAAY;EACZ,UAAU;EACV,YAAY;EACZ,OAAO;EACR,EACF,CAAC;;;;;ACDJ,MAAaC,gBAA4C,UAAS;CAEhE,MAAM,EAAE,WAAW,gBAAgB,OAAO,yBAAyB;AAEnE,QAAO,oBAAC;EAAK,OAAO,OAAO;YAAY,MAAM;GAAe"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as styled, t as useThemedStyles } from "./useThemedStyles-
|
|
1
|
+
import { n as styled, t as useThemedStyles } from "./useThemedStyles-wIbjybs1.js";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
|
|
@@ -239,4 +239,4 @@ const Icon = (props) => {
|
|
|
239
239
|
|
|
240
240
|
//#endregion
|
|
241
241
|
export { Icon as t };
|
|
242
|
-
//# sourceMappingURL=Icon-
|
|
242
|
+
//# sourceMappingURL=Icon-gUBGQxTT.js.map
|