softable-pixels-web 1.2.39 → 1.2.41
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/{Chip-0yO5bwim.js → Chip-4yKggGpF.js} +2 -1
- package/dist/{Chip-0yO5bwim.js.map → Chip-4yKggGpF.js.map} +1 -1
- package/dist/{ChipList-CmO2ctak.js → ChipList-MHNN5Q3u.js} +2 -2
- package/dist/{ChipList-CmO2ctak.js.map → ChipList-MHNN5Q3u.js.map} +1 -1
- package/dist/{ContextMenu-_72bEVKL.js → ContextMenu-CG3Anq1A.js} +2 -2
- package/dist/{ContextMenu-_72bEVKL.js.map → ContextMenu-CG3Anq1A.js.map} +1 -1
- package/dist/{Switch-D3Eitmnj.js → Switch-BQhkSPJw.js} +7 -4
- package/dist/Switch-BQhkSPJw.js.map +1 -0
- package/dist/chip-list.js +2 -2
- package/dist/chip.js +1 -1
- package/dist/context-menu.js +2 -2
- package/dist/{index-DoLWDzDX.d.ts → index-DjfLWx6f.d.ts} +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/switch.d.ts +1 -1
- package/dist/switch.js +1 -1
- package/package.json +1 -1
- package/dist/Switch-D3Eitmnj.js.map +0 -1
|
@@ -54,6 +54,7 @@ const Chip = (props) => {
|
|
|
54
54
|
props.onClick?.(props.data);
|
|
55
55
|
}
|
|
56
56
|
return /* @__PURE__ */ jsxs(Component, {
|
|
57
|
+
type: "button",
|
|
57
58
|
disabled: isDisabled,
|
|
58
59
|
style: styles.container,
|
|
59
60
|
className: classes.container,
|
|
@@ -69,4 +70,4 @@ const Chip = (props) => {
|
|
|
69
70
|
|
|
70
71
|
//#endregion
|
|
71
72
|
export { types_exports as n, Chip as t };
|
|
72
|
-
//# sourceMappingURL=Chip-
|
|
73
|
+
//# sourceMappingURL=Chip-4yKggGpF.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip-
|
|
1
|
+
{"version":3,"file":"Chip-4yKggGpF.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 whiteSpace: 'nowrap',\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 type=\"button\"\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\" color=\"inherit\">\n {props.data.label}\n </Typography>\n </Component>\n )\n}\n"],"mappings":";;;;;AAIA,SAAgB,iBAAiB,OAAkB;AACjD,QAAO,OAAO,EACZ,WAAW;EACT,SAAS;EACT,YAAY;EAEZ,aAAa;EACb,WAAW;EACX,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa,MAAM,KAAK,OAAO,WAAW;EAE1C,QAAQ,CAAC,MAAM,WAAW,YAAY;EAEtC,WAAW;EACX,aAAa;EACb,OAAO,MAAM,aAAa,UAAU;EACpC,iBAAiB,MAAM,aACnB,4BACA;EAEJ,YAAY;EACZ,YAAY,MAAM,WAAW,SAAS;EACtC,eAAe,MAAM,WAAW,SAAS;EACzC,cAAc,MAAM,WAAW,YAAY;EAC3C,kBAAkB,MAAM,WAAW,SAAS;EAE5C,YAAY;EACZ,SAAS,cAAc,MAAM,GAAG,KAAM;EAEtC,SAAS;GACP,WAAW,EACT,SAAS,MAAM,WAAW,IAAI,KAC/B;GAED,cAAc;IACZ,SAAS;IACT,QAAQ;IACT;GACF;EACF,EACF,CAAC;;AAGJ,SAAS,cAAc,OAAkB;AACvC,KAAI,CAAC,MAAM,SAAU,QAAO;AAC5B,QAAO,MAAM,gBAAgB,MAAM,KAAK;;;;;;;;;AElC1C,MAAaA,QAA4B,UAAS;CAEhD,MAAM,EAAE,QAAQ,YAAY,gBAAgB,OAAO,iBAAiB;CAGpE,MAAM,YAAY,MAAM,WAAW,SAAS;CAC5C,MAAM,aAAa,MAAM,gBAAgB,MAAM,KAAK;CAGpD,SAAS,cAAc;AACrB,MAAI,cAAc,MAAM,SAAU;AAClC,QAAM,UAAU,MAAM,KAAK;;AAG7B,QACE,qBAAC;EACC,MAAK;EACL,UAAU;EACV,OAAO,OAAO;EACd,WAAW,QAAQ;EACnB,SAAS;aAER,MAAM,KAAK,MAEZ,oBAAC;GAAW,SAAQ;GAAK,YAAW;GAAU,OAAM;aACjD,MAAM,KAAK;IACD;GACH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as styled, t as useThemedStyles } from "./useThemedStyles-Dco_54KA.js";
|
|
2
|
-
import { t as Chip } from "./Chip-
|
|
2
|
+
import { t as Chip } from "./Chip-4yKggGpF.js";
|
|
3
3
|
import { t as Label } from "./Label-CBUa-x13.js";
|
|
4
4
|
import { t as ErrorMessage } from "./ErrorMessage-6pG4hFId.js";
|
|
5
5
|
import { useEffect, useState } from "react";
|
|
@@ -111,4 +111,4 @@ const ChipList = (props) => {
|
|
|
111
111
|
|
|
112
112
|
//#endregion
|
|
113
113
|
export { ChipList as t };
|
|
114
|
-
//# sourceMappingURL=ChipList-
|
|
114
|
+
//# sourceMappingURL=ChipList-MHNN5Q3u.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChipList-
|
|
1
|
+
{"version":3,"file":"ChipList-MHNN5Q3u.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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;IACb,UAAU,MAAM;IAChB,eAAe,MAAM;IACrB,GAAI,MAAM;KACV;GAGJ,oBAAC;IAAI,OAAO,OAAO;cAAgB,eAAe;KAAO;GAExD,MAAM,eACL,oBAAC,gBAAa,SAAS,MAAM,eAAgB,GAC3C;;GACA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as styled, t as useThemedStyles } from "./useThemedStyles-Dco_54KA.js";
|
|
2
2
|
import { t as Typography } from "./Typography-CcQTHV-F.js";
|
|
3
|
-
import { t as Switch } from "./Switch-
|
|
3
|
+
import { t as Switch } from "./Switch-BQhkSPJw.js";
|
|
4
4
|
import { t as BasePopover } from "./BasePopover-CY-9StFD.js";
|
|
5
5
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
6
6
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -325,4 +325,4 @@ const ContextMenu = (props) => {
|
|
|
325
325
|
|
|
326
326
|
//#endregion
|
|
327
327
|
export { types_exports as n, ContextMenu as t };
|
|
328
|
-
//# sourceMappingURL=ContextMenu-
|
|
328
|
+
//# sourceMappingURL=ContextMenu-CG3Anq1A.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu-_72bEVKL.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\n gap: '0.5rem',\n borderRadius: '0.5rem',\n paddingInline: '0.5rem',\n paddingBlock: '0.25rem',\n\n userSelect: 'none',\n cursor: item.disabled ? 'not-allowed' : 'pointer',\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 { type MouseEvent, 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(e?: MouseEvent<HTMLButtonElement>) {\n e?.stopPropagation()\n e?.preventDefault()\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') {\n return (\n <Switch\n fitContent\n checked={item.checked}\n onChange={() => handleClick()}\n />\n )\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\n// Types\nimport type { TypeStyles } from '@hooks/useThemedStyles/types'\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?: TypeStyles<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, useState } 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 // States\n const [open, setOpen] = useState(false)\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 open={open}\n minWidth=\"fit-content\"\n floatingOptions={floatingOptions}\n dismissScope={scopeRef.current}\n trigger={renderTrigger}\n onOpenChange={setOpen}\n >\n <Menu\n depth={0}\n items={items}\n onHover={() => {}}\n width={columnWidth}\n dismissScope={scopeRef.current}\n onSelect={item =>\n handleSelect(item as MenuOption<T>, () => setOpen(false))\n }\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;GAEhB,KAAK;GACL,cAAc;GACd,eAAe;GACf,cAAc;GAEd,YAAY;GACZ,QAAQ,KAAK,WAAW,gBAAgB;GAExC,iBACE,KAAK,YAAY,SACb,oCACA;GAEN,SAAS,EACP,WAAW;IACT,YAAY;IACZ,i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e,aAAa,CAAC;CAG9C,MAAM,CAAC,MAAM,WAAW,SAAS,MAAM;CAEvC,MAAM,QAAQ,cAAc,qBAAqB,QAAQ,EAAE,CAAC,QAAQ,CAAC;CACrE,MAAM,kBAAkB,eACf;EACL;EACA;EACA;EACD,GACD;EAAC;EAAS;EAAS;EAAU,CAC9B;CAGD,MAAM,EAAE,WAAW,gBAAgB,OAAO,yBAAyB;EACjE,kBAAkB;EAClB,UAAU,MAAM;EAChB,OAAM,MAAK;GAAC,EAAE;GAAS,EAAE;GAAa,EAAE;GAAU;EACnD,CAAC;CAGF,SAAS,cAAc;AACrB,MAAI,OAAO,WAAW,eAAe,OAAO,WAC1C,QAAO,OAAO,YAAY;AAC5B,SAAO,SAAS,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE;;CAGrD,SAAS,aAAa,MAAqB,SAAmB;AAC5D,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;EACO;EACN,UAAS;EACQ;EACjB,cAAc,SAAS;EACvB,SAAS;EACT,cAAc;YAEd,oBAAC;GACC,OAAO;GACA;GACP,eAAe;GACf,OAAO;GACP,cAAc,SAAS;GACvB,WAAU,SACR,aAAa,YAA6B,QAAQ,MAAM,CAAC;IAE3D;GACU"}
|
|
1
|
+
{"version":3,"file":"ContextMenu-CG3Anq1A.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\n gap: '0.5rem',\n borderRadius: '0.5rem',\n paddingInline: '0.5rem',\n paddingBlock: '0.25rem',\n\n userSelect: 'none',\n cursor: item.disabled ? 'not-allowed' : 'pointer',\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 { type MouseEvent, 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(e?: MouseEvent<HTMLButtonElement>) {\n e?.stopPropagation()\n e?.preventDefault()\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') {\n return (\n <Switch\n fitContent\n checked={item.checked}\n onChange={() => handleClick()}\n />\n )\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\n// Types\nimport type { TypeStyles } from '@hooks/useThemedStyles/types'\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?: TypeStyles<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, useState } 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 // States\n const [open, setOpen] = useState(false)\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 open={open}\n minWidth=\"fit-content\"\n floatingOptions={floatingOptions}\n dismissScope={scopeRef.current}\n trigger={renderTrigger}\n onOpenChange={setOpen}\n >\n <Menu\n depth={0}\n items={items}\n onHover={() => {}}\n width={columnWidth}\n dismissScope={scopeRef.current}\n onSelect={item =>\n handleSelect(item as MenuOption<T>, () => setOpen(false))\n }\n />\n </B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;EACjB,cAAc,SAAS;EACvB,SAAS;EACT,cAAc;YAEd,oBAAC;GACC,OAAO;GACA;GACP,eAAe;GACf,OAAO;GACP,cAAc,SAAS;GACvB,WAAU,SACR,aAAa,YAA6B,QAAQ,MAAM,CAAC;IAE3D;GACU"}
|
|
@@ -3,14 +3,15 @@ import { t as Typography } from "./Typography-CcQTHV-F.js";
|
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/components/commons/toolkit/Switch/styles.ts
|
|
6
|
-
function createSwitchThumbStyles({ checked, fitContent, colorActive, colorInactive, colorIndicator }) {
|
|
6
|
+
function createSwitchThumbStyles({ checked, disabled, fitContent, colorActive, colorInactive, colorIndicator }) {
|
|
7
7
|
return styled({
|
|
8
8
|
wrapper: {
|
|
9
9
|
width: fitContent ? "fit-content" : "100%",
|
|
10
10
|
display: "flex",
|
|
11
11
|
alignItems: "center",
|
|
12
12
|
justifyContent: "space-between",
|
|
13
|
-
columnGap: "0.5rem"
|
|
13
|
+
columnGap: "0.5rem",
|
|
14
|
+
opacity: disabled ? .5 : 1
|
|
14
15
|
},
|
|
15
16
|
container: {
|
|
16
17
|
width: "2.5rem",
|
|
@@ -21,6 +22,7 @@ function createSwitchThumbStyles({ checked, fitContent, colorActive, colorInacti
|
|
|
21
22
|
marginLeft: "0.5rem",
|
|
22
23
|
borderRadius: "2rem",
|
|
23
24
|
padding: "0.125rem",
|
|
25
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
24
26
|
transition: "background-color 0.5s",
|
|
25
27
|
backgroundColor: checked ? colorActive ?? "var(--px-color-success)" : colorInactive ?? "var(--px-color-disabled)"
|
|
26
28
|
},
|
|
@@ -45,9 +47,10 @@ const Switch = (props) => {
|
|
|
45
47
|
const { label, checked, onChange } = props;
|
|
46
48
|
const { styles } = useThemedStyles(props, createSwitchThumbStyles, {
|
|
47
49
|
applyCommonProps: true,
|
|
48
|
-
pick: (p) => [p.checked]
|
|
50
|
+
pick: (p) => [p.checked, p.disabled]
|
|
49
51
|
});
|
|
50
52
|
function handleChange(e) {
|
|
53
|
+
if (props.disabled) return;
|
|
51
54
|
e.stopPropagation();
|
|
52
55
|
e.preventDefault();
|
|
53
56
|
onChange?.(!checked);
|
|
@@ -68,4 +71,4 @@ const Switch = (props) => {
|
|
|
68
71
|
|
|
69
72
|
//#endregion
|
|
70
73
|
export { Switch as t };
|
|
71
|
-
//# sourceMappingURL=Switch-
|
|
74
|
+
//# sourceMappingURL=Switch-BQhkSPJw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Switch-BQhkSPJw.js","names":["Switch: React.FC<SwitchThumbProps>"],"sources":["../src/components/commons/toolkit/Switch/styles.ts","../src/components/commons/toolkit/Switch/index.tsx"],"sourcesContent":["// Types\nimport type { SwitchThumbProps } from './types'\n\n// Styles\nimport { styled } from '@hooks/useThemedStyles/types'\n\nexport function createSwitchThumbStyles({\n checked,\n disabled,\n fitContent,\n colorActive,\n colorInactive,\n colorIndicator\n}: SwitchThumbProps) {\n return styled({\n wrapper: {\n width: fitContent ? 'fit-content' : '100%',\n\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n\n columnGap: '0.5rem',\n opacity: disabled ? 0.5 : 1\n },\n container: {\n width: '2.5rem',\n height: '1.5rem',\n\n position: 'relative',\n\n display: 'inline-flex',\n alignItems: 'center',\n marginLeft: '0.5rem',\n\n borderRadius: '2rem',\n padding: '0.125rem',\n cursor: disabled ? 'not-allowed' : 'pointer',\n\n transition: 'background-color 0.5s',\n backgroundColor: checked\n ? (colorActive ?? 'var(--px-color-success)')\n : (colorInactive ?? 'var(--px-color-disabled)')\n },\n\n indicator: {\n height: '1.25rem',\n width: '1.25rem',\n\n position: 'absolute',\n left: '0.125rem',\n top: '0.125rem',\n\n borderRadius: '9999px',\n backgroundColor: colorIndicator ?? 'var(--px-surface)',\n\n transition: 'transform 0.5s',\n transform: checked ? 'translateX(1rem)' : 'translateX(0)',\n willChange: 'transform'\n }\n })\n}\n","// External Libraries\n/** biome-ignore-all lint/a11y/noStaticElementInteractions: Not Needed */\n/** biome-ignore-all lint/a11y/useKeyWithClickEvents: Not Needed */\nimport type React from 'react'\nimport type { MouseEvent } from 'react'\n\n// Components\nimport { Typography } from '../Typography'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Types\nimport type { SwitchThumbProps } from './types'\n\n// Styles\nimport { createSwitchThumbStyles } from './styles'\n\nexport const Switch: React.FC<SwitchThumbProps> = props => {\n const { label, checked, onChange } = props\n\n // Hooks\n const { styles } = useThemedStyles(props, createSwitchThumbStyles, {\n applyCommonProps: true,\n pick: p => [p.checked, p.disabled]\n })\n\n // Functions\n function handleChange(e: MouseEvent<HTMLSpanElement>) {\n if (props.disabled) return\n\n e.stopPropagation()\n e.preventDefault()\n\n onChange?.(!checked)\n }\n\n return (\n <div style={styles.wrapper}>\n {label ? (\n <Typography variant=\"b2\" color=\"var(px-text-primary)\">\n {label}\n </Typography>\n ) : null}\n\n <span style={styles.container} onClick={handleChange}>\n <span style={styles.indicator} />\n </span>\n </div>\n )\n}\n"],"mappings":";;;;;AAMA,SAAgB,wBAAwB,EACtC,SACA,UACA,YACA,aACA,eACA,kBACmB;AACnB,QAAO,OAAO;EACZ,SAAS;GACP,OAAO,aAAa,gBAAgB;GAEpC,SAAS;GACT,YAAY;GACZ,gBAAgB;GAEhB,WAAW;GACX,SAAS,WAAW,KAAM;GAC3B;EACD,WAAW;GACT,OAAO;GACP,QAAQ;GAER,UAAU;GAEV,SAAS;GACT,YAAY;GACZ,YAAY;GAEZ,cAAc;GACd,SAAS;GACT,QAAQ,WAAW,gBAAgB;GAEnC,YAAY;GACZ,iBAAiB,UACZ,eAAe,4BACf,iBAAiB;GACvB;EAED,WAAW;GACT,QAAQ;GACR,OAAO;GAEP,UAAU;GACV,MAAM;GACN,KAAK;GAEL,cAAc;GACd,iBAAiB,kBAAkB;GAEnC,YAAY;GACZ,WAAW,UAAU,qBAAqB;GAC1C,YAAY;GACb;EACF,CAAC;;;;;AC1CJ,MAAaA,UAAqC,UAAS;CACzD,MAAM,EAAE,OAAO,SAAS,aAAa;CAGrC,MAAM,EAAE,WAAW,gBAAgB,OAAO,yBAAyB;EACjE,kBAAkB;EAClB,OAAM,MAAK,CAAC,EAAE,SAAS,EAAE,SAAS;EACnC,CAAC;CAGF,SAAS,aAAa,GAAgC;AACpD,MAAI,MAAM,SAAU;AAEpB,IAAE,iBAAiB;AACnB,IAAE,gBAAgB;AAElB,aAAW,CAAC,QAAQ;;AAGtB,QACE,qBAAC;EAAI,OAAO,OAAO;aAChB,QACC,oBAAC;GAAW,SAAQ;GAAK,OAAM;aAC5B;IACU,GACX,MAEJ,oBAAC;GAAK,OAAO,OAAO;GAAW,SAAS;aACtC,oBAAC,UAAK,OAAO,OAAO,YAAa;IAC5B;GACH"}
|
package/dist/chip-list.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "./useThemedStyles-Dco_54KA.js";
|
|
2
2
|
import "./Typography-CcQTHV-F.js";
|
|
3
|
-
import "./Chip-
|
|
3
|
+
import "./Chip-4yKggGpF.js";
|
|
4
4
|
import "./Label-CBUa-x13.js";
|
|
5
5
|
import "./ErrorMessage-6pG4hFId.js";
|
|
6
|
-
import { t as ChipList } from "./ChipList-
|
|
6
|
+
import { t as ChipList } from "./ChipList-MHNN5Q3u.js";
|
|
7
7
|
|
|
8
8
|
export { ChipList };
|
package/dist/chip.js
CHANGED
package/dist/context-menu.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "./useThemedStyles-Dco_54KA.js";
|
|
2
2
|
import "./Typography-CcQTHV-F.js";
|
|
3
|
-
import "./Switch-
|
|
3
|
+
import "./Switch-BQhkSPJw.js";
|
|
4
4
|
import "./useDismiss-Dpzg5Xpf.js";
|
|
5
5
|
import "./useFloating-D-2IDIWG.js";
|
|
6
6
|
import "./Popover-BV_1hBez.js";
|
|
7
7
|
import "./BasePopover-CY-9StFD.js";
|
|
8
|
-
import { n as types_exports, t as ContextMenu } from "./ContextMenu-
|
|
8
|
+
import { n as types_exports, t as ContextMenu } from "./ContextMenu-CG3Anq1A.js";
|
|
9
9
|
|
|
10
10
|
export { ContextMenu, types_exports as ContextMenuTypes };
|
|
@@ -5,6 +5,7 @@ interface SwitchThumbProps {
|
|
|
5
5
|
fitContent?: boolean;
|
|
6
6
|
label?: string;
|
|
7
7
|
checked: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
8
9
|
colorIndicator?: string;
|
|
9
10
|
colorActive?: string;
|
|
10
11
|
colorInactive?: string;
|
|
@@ -15,4 +16,4 @@ interface SwitchThumbProps {
|
|
|
15
16
|
declare const Switch: React.FC<SwitchThumbProps>;
|
|
16
17
|
//#endregion
|
|
17
18
|
export { Switch as t };
|
|
18
|
-
//# sourceMappingURL=index-
|
|
19
|
+
//# sourceMappingURL=index-DjfLWx6f.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ import { n as types_d_exports$2, t as ContextMenu } from "./index-Bo6Mz8jJ.js";
|
|
|
24
24
|
import { InfoSummary, InfoSummaryItem, InfoSummaryProps } from "./info-summary.js";
|
|
25
25
|
import { t as Pagination } from "./index-D5kC89SC.js";
|
|
26
26
|
import { ScrollPaginationContainer } from "./scroll-pagination-container.js";
|
|
27
|
-
import { t as Switch } from "./index-
|
|
27
|
+
import { t as Switch } from "./index-DjfLWx6f.js";
|
|
28
28
|
import { n as types_d_exports$7, t as TabSwitch } from "./index-BQRzf4rc.js";
|
|
29
29
|
import { Typography } from "./typography.js";
|
|
30
30
|
import { a as ThemeName, c as ThemeRegistry, i as ThemeMode, l as ThemeTokens, n as useTheme, o as ThemePersistence, r as ThemeContextData, s as ThemeProviderProps, t as ThemeProvider } from "./index-DPmfBsga.js";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./useThemedStyles-Dco_54KA.js";
|
|
2
2
|
import { t as Typography } from "./Typography-CcQTHV-F.js";
|
|
3
|
-
import { t as Switch } from "./Switch-
|
|
3
|
+
import { t as Switch } from "./Switch-BQhkSPJw.js";
|
|
4
4
|
import { t as useDismiss } from "./useDismiss-Dpzg5Xpf.js";
|
|
5
5
|
import { t as useFloating } from "./useFloating-D-2IDIWG.js";
|
|
6
6
|
import { n as types_exports$5, t as Popover } from "./Popover-BV_1hBez.js";
|
|
@@ -13,11 +13,11 @@ import { n as types_exports$8, t as TabSwitch } from "./TabSwitch-UPXOZTf4.js";
|
|
|
13
13
|
import { t as CheckItem } from "./CheckItem-CE27veSs.js";
|
|
14
14
|
import { t as InfoSummary } from "./InfoSummary-D8x-t44q.js";
|
|
15
15
|
import { t as BasePopover } from "./BasePopover-CY-9StFD.js";
|
|
16
|
-
import { n as types_exports$2, t as ContextMenu } from "./ContextMenu-
|
|
17
|
-
import { n as types_exports, t as Chip } from "./Chip-
|
|
16
|
+
import { n as types_exports$2, t as ContextMenu } from "./ContextMenu-CG3Anq1A.js";
|
|
17
|
+
import { n as types_exports, t as Chip } from "./Chip-4yKggGpF.js";
|
|
18
18
|
import "./Label-CBUa-x13.js";
|
|
19
19
|
import "./ErrorMessage-6pG4hFId.js";
|
|
20
|
-
import { t as ChipList } from "./ChipList-
|
|
20
|
+
import { t as ChipList } from "./ChipList-MHNN5Q3u.js";
|
|
21
21
|
import { t as IconButton } from "./IconButton-R8wpGZU_.js";
|
|
22
22
|
import { t as Pagination } from "./Pagination-i2_x464D.js";
|
|
23
23
|
import "./Loader-BTp8PCMz.js";
|
package/dist/switch.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as Switch } from "./index-
|
|
1
|
+
import { t as Switch } from "./index-DjfLWx6f.js";
|
|
2
2
|
export { Switch };
|
package/dist/switch.js
CHANGED
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Switch-D3Eitmnj.js","names":["Switch: React.FC<SwitchThumbProps>"],"sources":["../src/components/commons/toolkit/Switch/styles.ts","../src/components/commons/toolkit/Switch/index.tsx"],"sourcesContent":["// Types\nimport type { SwitchThumbProps } from './types'\n\n// Styles\nimport { styled } from '@hooks/useThemedStyles/types'\n\nexport function createSwitchThumbStyles({\n checked,\n fitContent,\n colorActive,\n colorInactive,\n colorIndicator\n}: SwitchThumbProps) {\n return styled({\n wrapper: {\n width: fitContent ? 'fit-content' : '100%',\n\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n\n columnGap: '0.5rem'\n },\n container: {\n width: '2.5rem',\n height: '1.5rem',\n\n position: 'relative',\n\n display: 'inline-flex',\n alignItems: 'center',\n marginLeft: '0.5rem',\n\n borderRadius: '2rem',\n padding: '0.125rem',\n\n transition: 'background-color 0.5s',\n backgroundColor: checked\n ? (colorActive ?? 'var(--px-color-success)')\n : (colorInactive ?? 'var(--px-color-disabled)')\n },\n\n indicator: {\n height: '1.25rem',\n width: '1.25rem',\n\n position: 'absolute',\n left: '0.125rem',\n top: '0.125rem',\n\n borderRadius: '9999px',\n backgroundColor: colorIndicator ?? 'var(--px-surface)',\n\n transition: 'transform 0.5s',\n transform: checked ? 'translateX(1rem)' : 'translateX(0)',\n willChange: 'transform'\n }\n })\n}\n","// External Libraries\n/** biome-ignore-all lint/a11y/noStaticElementInteractions: Not Needed */\n/** biome-ignore-all lint/a11y/useKeyWithClickEvents: Not Needed */\nimport type React from 'react'\nimport type { MouseEvent } from 'react'\n\n// Components\nimport { Typography } from '../Typography'\n\n// Hooks\nimport { useThemedStyles } from '@hooks/useThemedStyles'\n\n// Types\nimport type { SwitchThumbProps } from './types'\n\n// Styles\nimport { createSwitchThumbStyles } from './styles'\n\nexport const Switch: React.FC<SwitchThumbProps> = props => {\n const { label, checked, onChange } = props\n\n // Hooks\n const { styles } = useThemedStyles(props, createSwitchThumbStyles, {\n applyCommonProps: true,\n pick: p => [p.checked]\n })\n\n // Functions\n function handleChange(e: MouseEvent<HTMLSpanElement>) {\n e.stopPropagation()\n e.preventDefault()\n\n onChange?.(!checked)\n }\n\n return (\n <div style={styles.wrapper}>\n {label ? (\n <Typography variant=\"b2\" color=\"var(px-text-primary)\">\n {label}\n </Typography>\n ) : null}\n\n <span style={styles.container} onClick={handleChange}>\n <span style={styles.indicator} />\n </span>\n </div>\n )\n}\n"],"mappings":";;;;;AAMA,SAAgB,wBAAwB,EACtC,SACA,YACA,aACA,eACA,kBACmB;AACnB,QAAO,OAAO;EACZ,SAAS;GACP,OAAO,aAAa,gBAAgB;GAEpC,SAAS;GACT,YAAY;GACZ,gBAAgB;GAEhB,WAAW;GACZ;EACD,WAAW;GACT,OAAO;GACP,QAAQ;GAER,UAAU;GAEV,SAAS;GACT,YAAY;GACZ,YAAY;GAEZ,cAAc;GACd,SAAS;GAET,YAAY;GACZ,iBAAiB,UACZ,eAAe,4BACf,iBAAiB;GACvB;EAED,WAAW;GACT,QAAQ;GACR,OAAO;GAEP,UAAU;GACV,MAAM;GACN,KAAK;GAEL,cAAc;GACd,iBAAiB,kBAAkB;GAEnC,YAAY;GACZ,WAAW,UAAU,qBAAqB;GAC1C,YAAY;GACb;EACF,CAAC;;;;;ACvCJ,MAAaA,UAAqC,UAAS;CACzD,MAAM,EAAE,OAAO,SAAS,aAAa;CAGrC,MAAM,EAAE,WAAW,gBAAgB,OAAO,yBAAyB;EACjE,kBAAkB;EAClB,OAAM,MAAK,CAAC,EAAE,QAAQ;EACvB,CAAC;CAGF,SAAS,aAAa,GAAgC;AACpD,IAAE,iBAAiB;AACnB,IAAE,gBAAgB;AAElB,aAAW,CAAC,QAAQ;;AAGtB,QACE,qBAAC;EAAI,OAAO,OAAO;aAChB,QACC,oBAAC;GAAW,SAAQ;GAAK,OAAM;aAC5B;IACU,GACX,MAEJ,oBAAC;GAAK,OAAO,OAAO;GAAW,SAAS;aACtC,oBAAC,UAAK,OAAO,OAAO,YAAa;IAC5B;GACH"}
|