@mks2508/mks-ui 0.5.2 → 0.5.7
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/react-ui/index.js +8 -3
- package/dist/react-ui/primitives/index.js +5 -0
- package/dist/react-ui/primitives/waapi/Gooey/Gooey.types.d.ts +120 -0
- package/dist/react-ui/primitives/waapi/Gooey/Gooey.types.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.d.ts +10 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.js +190 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyFilter.d.ts +7 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyFilter.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyFilter.js +78 -0
- package/dist/react-ui/primitives/waapi/Gooey/MorphPath.d.ts +7 -0
- package/dist/react-ui/primitives/waapi/Gooey/MorphPath.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/MorphPath.js +51 -0
- package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.d.ts +94 -0
- package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.js +182 -0
- package/dist/react-ui/primitives/waapi/Gooey/index.d.ts +28 -0
- package/dist/react-ui/primitives/waapi/Gooey/index.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/index.js +5 -0
- package/dist/react-ui/primitives/waapi/Gooey/useMorphPath.d.ts +7 -0
- package/dist/react-ui/primitives/waapi/Gooey/useMorphPath.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/useMorphPath.js +47 -0
- package/dist/react-ui/primitives/waapi/index.d.ts +2 -0
- package/dist/react-ui/primitives/waapi/index.d.ts.map +1 -1
- package/dist/react-ui/primitives/waapi/index.js +6 -0
- package/dist/react-ui/ui/DataCard/DataCard.styles.d.ts +26 -16
- package/dist/react-ui/ui/DataCard/DataCard.styles.d.ts.map +1 -1
- package/dist/react-ui/ui/DataCard/DataCard.styles.js +36 -74
- package/dist/react-ui/ui/DataCard/DataCard.types.d.ts +50 -70
- package/dist/react-ui/ui/DataCard/DataCard.types.d.ts.map +1 -1
- package/dist/react-ui/ui/DataCard/index.d.ts +24 -93
- package/dist/react-ui/ui/DataCard/index.d.ts.map +1 -1
- package/dist/react-ui/ui/DataCard/index.js +76 -118
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle-DOR3Ld-k.css +376 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.css +376 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.js +0 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.d.ts +20 -8
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.d.ts.map +1 -1
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.js +55 -27
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.types.d.ts +69 -14
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.types.d.ts.map +1 -1
- package/dist/react-ui/ui/DynamicToggle/index.d.ts +22 -20
- package/dist/react-ui/ui/DynamicToggle/index.d.ts.map +1 -1
- package/dist/react-ui/ui/DynamicToggle/index.js +133 -96
- package/dist/react-ui/ui/Switch/index.js +1 -1
- package/dist/react-ui/ui/index.js +2 -2
- package/package.json +2 -2
- package/src/css.d.ts +1 -0
- package/src/react-ui/primitives/waapi/Gooey/Gooey.types.ts +141 -0
- package/src/react-ui/primitives/waapi/Gooey/GooeyCanvas.tsx +217 -0
- package/src/react-ui/primitives/waapi/Gooey/GooeyFilter.tsx +77 -0
- package/src/react-ui/primitives/waapi/Gooey/MorphPath.tsx +58 -0
- package/src/react-ui/primitives/waapi/Gooey/gooey-utils.ts +253 -0
- package/src/react-ui/primitives/waapi/Gooey/index.ts +50 -0
- package/src/react-ui/primitives/waapi/Gooey/useMorphPath.ts +48 -0
- package/src/react-ui/primitives/waapi/index.ts +23 -0
- package/src/react-ui/ui/DataCard/DataCard.styles.ts +45 -101
- package/src/react-ui/ui/DataCard/DataCard.types.ts +52 -73
- package/src/react-ui/ui/DataCard/index.tsx +118 -184
- package/src/react-ui/ui/DynamicToggle/DynamicToggle.css +320 -94
- package/src/react-ui/ui/DynamicToggle/DynamicToggle.styles.ts +60 -40
- package/src/react-ui/ui/DynamicToggle/DynamicToggle.types.ts +101 -14
- package/src/react-ui/ui/DynamicToggle/index.tsx +172 -96
- package/src/react-ui/ui/DynamicToggle/prototype-v7-ios.html +413 -0
- package/src/react-ui/ui/DynamicToggle/prototype-v7.html +615 -0
- package/src/react-ui/ui/DynamicToggle/prototype-v8-gooey-safari.html +560 -0
- package/src/react-ui/ui/DynamicToggle/prototype-v8b-react-structure.html +227 -0
- package/src/react-ui/ui/DynamicToggle/prototype.html +419 -0
- package/src/react-ui/ui/Switch/index.tsx +1 -1
- /package/dist/react-ui/blocks/Terminal/panel/{terminal-filter-dropdown.module-DAcl_XQZ.css → terminal-filter-dropdown.module-C6oDcFBS.css} +0 -0
- /package/dist/react-ui/blocks/Terminal/panel/{terminal-session-tabs.module-DNAop5e3.css → terminal-session-tabs.module-D_-sgyza.css} +0 -0
- /package/dist/react-ui/components/MorphingPopover/{morphing-popover.module-BJrjXisF.css → morphing-popover.module-B1ftlaYj.css} +0 -0
|
@@ -1,29 +1,31 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './DynamicToggle.css';
|
|
2
|
+
import { dynamicToggleVariants } from './DynamicToggle.styles';
|
|
3
|
+
import type { DynamicToggleContextType, IDynamicToggleProps, IDynamicToggleOptionProps, IDynamicToggleGroupProps } from './DynamicToggle.types';
|
|
4
|
+
declare const useDynamicToggle: () => DynamicToggleContextType;
|
|
2
5
|
/**
|
|
3
|
-
* Root container — pill-shaped toggle
|
|
4
|
-
*
|
|
5
|
-
* @param props - Component props
|
|
6
|
-
* @returns React component
|
|
6
|
+
* Root container — pill-shaped toggle with expanding sub-options and group label.
|
|
7
7
|
*/
|
|
8
|
-
declare function DynamicToggle({ slots, className, children, ...props }: IDynamicToggleProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare function DynamicToggle({ variant, size, shape, slots, config, disabled, className, children, 'aria-label': ariaLabel, ...props }: IDynamicToggleProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare namespace DynamicToggle {
|
|
10
|
+
var displayName: string;
|
|
11
|
+
}
|
|
9
12
|
/**
|
|
10
|
-
* A single toggle option —
|
|
11
|
-
* Can be used at the top level or inside a DynamicToggleGroup.
|
|
12
|
-
*
|
|
13
|
-
* @param props - Component props
|
|
14
|
-
* @returns React component
|
|
13
|
+
* A single toggle option — hidden radio + visible label.
|
|
15
14
|
*/
|
|
16
15
|
declare function DynamicToggleOption({ value, children, className }: IDynamicToggleOptionProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare namespace DynamicToggleOption {
|
|
17
|
+
var displayName: string;
|
|
18
|
+
}
|
|
17
19
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @param props - Component props
|
|
22
|
-
* @returns React component
|
|
20
|
+
* Expandable group — registers with root on mount, renders sub-options.
|
|
21
|
+
* The group label is rendered by the root based on registered info.
|
|
23
22
|
*/
|
|
24
|
-
declare function DynamicToggleGroup({ label, children, className }: IDynamicToggleGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
declare function DynamicToggleGroup({ label, labelPosition, collapsedMode, children, className, }: IDynamicToggleGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
declare namespace DynamicToggleGroup {
|
|
25
|
+
var displayName: string;
|
|
26
|
+
}
|
|
27
|
+
export { DynamicToggle, DynamicToggleOption, DynamicToggleGroup, useDynamicToggle, dynamicToggleVariants, };
|
|
28
|
+
export type { IDynamicToggleProps, IDynamicToggleOptionProps, IDynamicToggleGroupProps, IDynamicToggleConfig, DynamicToggleContextType, DynamicToggleCollapsedMode, DynamicToggleMorphMode, } from './DynamicToggle.types';
|
|
29
|
+
export type { DynamicToggleSlot, DynamicToggleVariantProps } from './DynamicToggle.styles';
|
|
28
30
|
export { dynamicToggleStyles } from './DynamicToggle.styles';
|
|
29
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react-ui/ui/DynamicToggle/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react-ui/ui/DynamicToggle/index.tsx"],"names":[],"mappings":"AA8BA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAuB,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,KAAK,EACV,wBAAwB,EAExB,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,uBAAuB,CAAC;AAM/B,QAAA,MAA8B,gBAAgB,gCACsB,CAAC;AAmCrE;;GAEG;AACH,iBAAS,aAAa,CAAC,EACrB,OAAO,EACP,IAAI,EACJ,KAAK,EACL,KAAK,EACL,MAAM,EACN,QAAgB,EAChB,SAAS,EACT,QAAQ,EACR,YAAY,EAAE,SAAS,EACvB,GAAG,KAAK,EACT,EAAE,mBAAmB,2CAiGrB;kBA5GQ,aAAa;;;AAkHtB;;GAEG;AACH,iBAAS,mBAAmB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,yBAAyB,2CA2BrF;kBA3BQ,mBAAmB;;;AAiC5B;;;GAGG;AACH,iBAAS,kBAAkB,CAAC,EAC1B,KAAK,EACL,aAAqB,EACrB,aAAuB,EACvB,QAAQ,EACR,SAAS,GACV,EAAE,wBAAwB,2CA0C1B;kBAhDQ,kBAAkB;;;AA2D3B,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,GACtB,CAAC;AAEF,YAAY,EACV,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -1,123 +1,137 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { cn } from "../../lib/utils.js";
|
|
4
|
+
import { GooeyCanvas } from "../../primitives/waapi/Gooey/GooeyCanvas.js";
|
|
4
5
|
import { getStrictContext } from "../../lib/get-strict-context.js";
|
|
5
6
|
import { useControlledState } from "../../hooks/State/UseControlledState.js";
|
|
6
|
-
import
|
|
7
|
+
import "./DynamicToggle.js";
|
|
8
|
+
import { dynamicToggleStyles, dynamicToggleVariants } from "./DynamicToggle.styles.js";
|
|
7
9
|
import * as React$1 from "react";
|
|
8
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
11
|
|
|
10
12
|
//#region src/react-ui/ui/DynamicToggle/index.tsx
|
|
11
13
|
/**
|
|
12
|
-
* DynamicToggle — CSS-animated toggle
|
|
14
|
+
* DynamicToggle — CSS-animated toggle with expanding sub-options and group label.
|
|
13
15
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
16
|
+
* Pure CSS animation via `:has(:checked)` on hidden radio inputs.
|
|
17
|
+
* When the group is active, a group label grows out of the pill.
|
|
18
|
+
* Optional gooey morph via `config.morphMode` for organic junction.
|
|
19
|
+
*
|
|
20
|
+
* Supports exactly 1 `DynamicToggleOption` + 1 `DynamicToggleGroup` (with 2 sub-options).
|
|
17
21
|
*
|
|
18
22
|
* @module @mks2508/mks-ui/react/ui/DynamicToggle
|
|
19
23
|
*
|
|
20
24
|
* @example
|
|
21
25
|
* ```tsx
|
|
22
|
-
* <DynamicToggle value="tree" onValueChange={setVal}>
|
|
26
|
+
* <DynamicToggle value="tree" onValueChange={setVal} size="sm" shape="pill">
|
|
23
27
|
* <DynamicToggleOption value="tree">Tree</DynamicToggleOption>
|
|
24
|
-
* <DynamicToggleGroup label="Changes">
|
|
28
|
+
* <DynamicToggleGroup label="Changes" collapsedMode="title" labelPosition="top">
|
|
25
29
|
* <DynamicToggleOption value="flat">Flat</DynamicToggleOption>
|
|
26
30
|
* <DynamicToggleOption value="grouped">Grouped</DynamicToggleOption>
|
|
27
31
|
* </DynamicToggleGroup>
|
|
28
32
|
* </DynamicToggle>
|
|
29
33
|
* ```
|
|
30
34
|
*/
|
|
31
|
-
const DT_CSS_ID = "mks-dynamic-toggle-css";
|
|
32
|
-
/** Reads the CSS file content at build time via rolldown */
|
|
33
|
-
const DT_CSS = `
|
|
34
|
-
:root{--dt-duration:0.22s;--dt-ease:cubic-bezier(0.22,0.61,0.36,1);--dt-drop-off:0.45}
|
|
35
|
-
[data-slot="dt-track"]{grid-template-columns:repeat(4,1fr)}
|
|
36
|
-
[data-slot="dt-track"]>label:first-of-type,[data-slot="dt-group"]{grid-column:span 2}
|
|
37
|
-
[data-slot="dt-indicator"]{transition:translate var(--dt-duration) var(--dt-ease)}
|
|
38
|
-
[data-slot="dt-track"]:has(>input:checked) [data-slot="dt-indicator"]{translate:0 0}
|
|
39
|
-
[data-slot="dt-track"]:not(:has(>input:checked)) [data-slot="dt-indicator"]{translate:100% 0}
|
|
40
|
-
[data-slot="dt-track"]:has(>input:checked)>label{color:var(--card)}
|
|
41
|
-
[data-slot="dt-track"]:not(:has(>input:checked))>label{color:var(--foreground);opacity:var(--dt-drop-off)}
|
|
42
|
-
[data-slot="dt-group"]{container-type:size;grid-template-columns:1fr 1fr}
|
|
43
|
-
[data-slot="dt-group-label"]{translate:-50% -80%;transition:translate var(--dt-duration) var(--dt-ease),scale var(--dt-duration) var(--dt-ease)}
|
|
44
|
-
[data-slot="dt-group"]:has(input:checked) [data-slot="dt-group-label"]{translate:-50% -250%;scale:0.85}
|
|
45
|
-
[data-slot="dt-group-indicator"]{transition:translate var(--dt-duration) var(--dt-ease),clip-path var(--dt-duration) var(--dt-ease),background var(--dt-duration) var(--dt-ease);clip-path:inset(73cqh calc(50% + 1px) calc(27cqh - 2px) calc(50% - 3px) round 100px);translate:-50% 0;background:var(--foreground)}
|
|
46
|
-
[data-slot="dt-group"]:has(input:checked) [data-slot="dt-group-indicator"]{background:var(--card);clip-path:inset(0 0 0 0 round 100px)}
|
|
47
|
-
[data-slot="dt-group"]:has(input:nth-of-type(1):checked) [data-slot="dt-group-indicator"]{translate:-100% 0}
|
|
48
|
-
[data-slot="dt-group"]:has(input:nth-of-type(2):checked) [data-slot="dt-group-indicator"]{translate:0 0}
|
|
49
|
-
[data-slot="dt-group"] label{color:var(--muted-foreground);transition:color var(--dt-duration) var(--dt-ease),opacity var(--dt-duration) var(--dt-ease)}
|
|
50
|
-
[data-slot="dt-group"] label span{transition:scale var(--dt-duration) var(--dt-ease)}
|
|
51
|
-
[data-slot="dt-track"]:has(>input:checked) [data-slot="dt-group"] label{color:var(--muted-foreground)}
|
|
52
|
-
[data-slot="dt-group"]:has(input:checked) label{color:var(--muted-foreground);opacity:0.75}
|
|
53
|
-
[data-slot="dt-group"]:has(input:nth-of-type(1):checked) label:nth-of-type(1),[data-slot="dt-group"]:has(input:nth-of-type(2):checked) label:nth-of-type(2){color:var(--foreground);opacity:1}
|
|
54
|
-
[data-slot="dt-group"] label:nth-of-type(1) span{scale:0.75;transform-origin:150% 150%}
|
|
55
|
-
[data-slot="dt-group"] label:nth-of-type(2) span{scale:0.75;transform-origin:-65% 150%}
|
|
56
|
-
[data-slot="dt-group"]:has(input:checked) label span{scale:1}
|
|
57
|
-
[data-slot="dt-radio"]{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}
|
|
58
|
-
`;
|
|
59
|
-
function useDynamicToggleCSS() {
|
|
60
|
-
React$1.useEffect(() => {
|
|
61
|
-
if (typeof document === "undefined") return;
|
|
62
|
-
if (document.getElementById(DT_CSS_ID)) return;
|
|
63
|
-
const style = document.createElement("style");
|
|
64
|
-
style.id = DT_CSS_ID;
|
|
65
|
-
style.textContent = DT_CSS;
|
|
66
|
-
document.head.appendChild(style);
|
|
67
|
-
}, []);
|
|
68
|
-
}
|
|
69
35
|
const [DynamicToggleProvider, useDynamicToggle] = getStrictContext("DynamicToggleContext");
|
|
36
|
+
const useIsomorphicLayoutEffect = typeof window !== "undefined" ? React$1.useLayoutEffect : React$1.useEffect;
|
|
37
|
+
const SIZE_HEIGHT_PX = {
|
|
38
|
+
sm: 30,
|
|
39
|
+
default: 38,
|
|
40
|
+
lg: 44
|
|
41
|
+
};
|
|
42
|
+
const SIZE_WIDTH_PX = {
|
|
43
|
+
sm: 210,
|
|
44
|
+
default: 260,
|
|
45
|
+
lg: 320
|
|
46
|
+
};
|
|
47
|
+
const SHAPE_RADIUS = {
|
|
48
|
+
pill: 9999,
|
|
49
|
+
rounded: 12,
|
|
50
|
+
square: 6
|
|
51
|
+
};
|
|
70
52
|
/**
|
|
71
|
-
* Root container — pill-shaped toggle
|
|
72
|
-
*
|
|
73
|
-
* @param props - Component props
|
|
74
|
-
* @returns React component
|
|
53
|
+
* Root container — pill-shaped toggle with expanding sub-options and group label.
|
|
75
54
|
*/
|
|
76
|
-
function DynamicToggle({ slots, className, children, ...props }) {
|
|
77
|
-
useDynamicToggleCSS();
|
|
55
|
+
function DynamicToggle({ variant, size, shape, slots, config, disabled = false, className, children, "aria-label": ariaLabel, ...props }) {
|
|
78
56
|
const [value, setValue] = useControlledState({
|
|
79
57
|
value: props.value,
|
|
80
58
|
defaultValue: props.defaultValue ?? "",
|
|
81
59
|
onChange: props.onValueChange
|
|
82
60
|
});
|
|
83
61
|
const groupName = React$1.useId();
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
62
|
+
const [groupLabel, setGroupLabel] = React$1.useState("");
|
|
63
|
+
const [groupValues, setGroupValues] = React$1.useState([]);
|
|
64
|
+
const [groupPosition, setGroupPosition] = React$1.useState("top");
|
|
65
|
+
const [groupCollapsedMode, setGroupCollapsedMode] = React$1.useState("title");
|
|
66
|
+
const registerGroup = React$1.useCallback((label, values, position, collapsedMode) => {
|
|
67
|
+
setGroupLabel(label);
|
|
68
|
+
setGroupValues(values);
|
|
69
|
+
setGroupPosition(position);
|
|
70
|
+
setGroupCollapsedMode(collapsedMode);
|
|
71
|
+
}, []);
|
|
72
|
+
const groupActive = groupValues.includes(value);
|
|
73
|
+
const morphMode = config?.morphMode ?? "none";
|
|
74
|
+
const resolvedVariant = variant ?? "default";
|
|
75
|
+
const effectiveMorphMode = resolvedVariant === "ghost" || resolvedVariant === "outline" ? "none" : morphMode;
|
|
76
|
+
const showGroupLabel = (config?.labelAnimation ?? "morph") !== "none" && groupPosition !== "hidden" && groupLabel;
|
|
77
|
+
const heightPx = SIZE_HEIGHT_PX[size ?? "default"] ?? 32;
|
|
78
|
+
const style = {
|
|
79
|
+
...config?.duration && { "--dt-dur": `${config.duration}s` },
|
|
80
|
+
...config?.indicatorDuration && { "--dt-indicator-dur": `${config.indicatorDuration}s` },
|
|
81
|
+
...config?.indicatorEasing && { "--dt-indicator-ease": config.indicatorEasing }
|
|
82
|
+
};
|
|
83
|
+
const hasStyle = Object.keys(style).length > 0;
|
|
84
|
+
const groupLabelElement = showGroupLabel ? /* @__PURE__ */ jsx("div", {
|
|
85
|
+
"data-slot": "dt-group-label",
|
|
86
|
+
"data-position": groupPosition,
|
|
87
|
+
className: cn(dynamicToggleStyles.groupLabel, slots?.groupLabel),
|
|
88
|
+
children: /* @__PURE__ */ jsx("span", { children: groupLabel || "\xA0" })
|
|
89
|
+
}) : null;
|
|
93
90
|
return /* @__PURE__ */ jsx(DynamicToggleProvider, {
|
|
94
91
|
value: {
|
|
95
92
|
value,
|
|
96
93
|
setValue,
|
|
97
94
|
groupName,
|
|
98
|
-
groupActive
|
|
95
|
+
groupActive,
|
|
96
|
+
disabled,
|
|
97
|
+
registerGroup
|
|
99
98
|
},
|
|
100
|
-
children: /* @__PURE__ */
|
|
99
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
101
100
|
"data-slot": "dt-root",
|
|
101
|
+
"data-morph": effectiveMorphMode !== "none" ? effectiveMorphMode : void 0,
|
|
102
|
+
"data-indicator": config?.forceTranslateIndicator ? "translate" : void 0,
|
|
102
103
|
"data-group-active": groupActive || void 0,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
})
|
|
104
|
+
"data-disabled": disabled || void 0,
|
|
105
|
+
role: "radiogroup",
|
|
106
|
+
"aria-label": ariaLabel,
|
|
107
|
+
style: hasStyle ? style : void 0,
|
|
108
|
+
className: cn(dynamicToggleVariants({
|
|
109
|
+
variant,
|
|
110
|
+
size,
|
|
111
|
+
shape
|
|
112
|
+
}), slots?.root, className),
|
|
113
|
+
children: [
|
|
114
|
+
effectiveMorphMode === "filter" && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(GooeyCanvas, {
|
|
115
|
+
height: heightPx,
|
|
116
|
+
width: SIZE_WIDTH_PX[size ?? "default"] ?? 260,
|
|
117
|
+
radius: SHAPE_RADIUS[shape ?? "pill"] ?? 9999,
|
|
118
|
+
expanded: groupActive
|
|
119
|
+
}), groupLabelElement] }),
|
|
120
|
+
effectiveMorphMode === "path" && groupLabelElement,
|
|
121
|
+
/* @__PURE__ */ jsxs("div", {
|
|
122
|
+
"data-slot": "dt-track",
|
|
123
|
+
className: cn(dynamicToggleStyles.track, slots?.track),
|
|
124
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
125
|
+
"data-slot": "dt-indicator",
|
|
126
|
+
className: cn(dynamicToggleStyles.indicator, slots?.indicator)
|
|
127
|
+
}), children]
|
|
128
|
+
})
|
|
129
|
+
]
|
|
112
130
|
})
|
|
113
131
|
});
|
|
114
132
|
}
|
|
115
133
|
/**
|
|
116
|
-
* A single toggle option —
|
|
117
|
-
* Can be used at the top level or inside a DynamicToggleGroup.
|
|
118
|
-
*
|
|
119
|
-
* @param props - Component props
|
|
120
|
-
* @returns React component
|
|
134
|
+
* A single toggle option — hidden radio + visible label.
|
|
121
135
|
*/
|
|
122
136
|
function DynamicToggleOption({ value, children, className }) {
|
|
123
137
|
const ctx = useDynamicToggle();
|
|
@@ -130,40 +144,63 @@ function DynamicToggleOption({ value, children, className }) {
|
|
|
130
144
|
className: cn(dynamicToggleStyles.option, className),
|
|
131
145
|
children: /* @__PURE__ */ jsx("span", { children })
|
|
132
146
|
}), /* @__PURE__ */ jsx("input", {
|
|
133
|
-
|
|
147
|
+
className: "sr-only",
|
|
134
148
|
type: "radio",
|
|
135
149
|
name: ctx.groupName,
|
|
136
150
|
id,
|
|
137
151
|
value,
|
|
138
152
|
checked: isActive,
|
|
153
|
+
disabled: ctx.disabled,
|
|
139
154
|
onChange: () => ctx.setValue(value)
|
|
140
155
|
})] });
|
|
141
156
|
}
|
|
142
157
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* @param props - Component props
|
|
147
|
-
* @returns React component
|
|
158
|
+
* Expandable group — registers with root on mount, renders sub-options.
|
|
159
|
+
* The group label is rendered by the root based on registered info.
|
|
148
160
|
*/
|
|
149
|
-
function DynamicToggleGroup({ label, children, className }) {
|
|
161
|
+
function DynamicToggleGroup({ label, labelPosition = "top", collapsedMode = "title", children, className }) {
|
|
162
|
+
const ctx = useDynamicToggle();
|
|
163
|
+
const optsText = React$1.useMemo(() => {
|
|
164
|
+
const labels = [];
|
|
165
|
+
React$1.Children.forEach(children, (child) => {
|
|
166
|
+
if (React$1.isValidElement(child)) {
|
|
167
|
+
const p = child.props;
|
|
168
|
+
if (p.children) labels.push(String(p.children));
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
return labels.join(" · ");
|
|
172
|
+
}, [children]);
|
|
173
|
+
useIsomorphicLayoutEffect(() => {
|
|
174
|
+
const values = [];
|
|
175
|
+
React$1.Children.forEach(children, (child) => {
|
|
176
|
+
if (React$1.isValidElement(child)) {
|
|
177
|
+
const p = child.props;
|
|
178
|
+
if (p.value) values.push(p.value);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
ctx.registerGroup(label, values, labelPosition, collapsedMode);
|
|
182
|
+
}, [
|
|
183
|
+
label,
|
|
184
|
+
labelPosition,
|
|
185
|
+
collapsedMode,
|
|
186
|
+
children,
|
|
187
|
+
ctx.registerGroup
|
|
188
|
+
]);
|
|
150
189
|
return /* @__PURE__ */ jsxs("div", {
|
|
151
190
|
"data-slot": "dt-group",
|
|
191
|
+
"data-collapsed": collapsedMode,
|
|
192
|
+
"data-label": label,
|
|
193
|
+
"data-opts": collapsedMode !== "title" ? optsText : void 0,
|
|
152
194
|
className: cn(dynamicToggleStyles.group, className),
|
|
153
|
-
children: [
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
children: label
|
|
158
|
-
}),
|
|
159
|
-
/* @__PURE__ */ jsx("div", {
|
|
160
|
-
"data-slot": "dt-group-indicator",
|
|
161
|
-
className: dynamicToggleStyles.groupIndicator
|
|
162
|
-
}),
|
|
163
|
-
children
|
|
164
|
-
]
|
|
195
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
196
|
+
"data-slot": "dt-group-indicator",
|
|
197
|
+
className: dynamicToggleStyles.groupIndicator
|
|
198
|
+
}), children]
|
|
165
199
|
});
|
|
166
200
|
}
|
|
201
|
+
DynamicToggle.displayName = "DynamicToggle";
|
|
202
|
+
DynamicToggleOption.displayName = "DynamicToggleOption";
|
|
203
|
+
DynamicToggleGroup.displayName = "DynamicToggleGroup";
|
|
167
204
|
|
|
168
205
|
//#endregion
|
|
169
|
-
export { DynamicToggle, DynamicToggleGroup, DynamicToggleOption };
|
|
206
|
+
export { DynamicToggle, DynamicToggleGroup, DynamicToggleOption, useDynamicToggle };
|
|
@@ -39,5 +39,5 @@ import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScro
|
|
|
39
39
|
import { dataCardStyles, dataCardVariants } from "./DataCard/DataCard.styles.js";
|
|
40
40
|
import { DataCard, DataCardActions, DataCardBracket, DataCardLabel, DataCardToggle, DataCardValue, useDataCard } from "./DataCard/index.js";
|
|
41
41
|
import { TextFlow } from "./TextFlow/index.js";
|
|
42
|
-
import { dynamicToggleStyles } from "./DynamicToggle/DynamicToggle.styles.js";
|
|
43
|
-
import { DynamicToggle, DynamicToggleGroup, DynamicToggleOption } from "./DynamicToggle/index.js";
|
|
42
|
+
import { dynamicToggleStyles, dynamicToggleVariants } from "./DynamicToggle/DynamicToggle.styles.js";
|
|
43
|
+
import { DynamicToggle, DynamicToggleGroup, DynamicToggleOption, useDynamicToggle } from "./DynamicToggle/index.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mks2508/mks-ui",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
4
4
|
"description": "UI component library - Shadcn/Animate UI based with DevEnv components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
],
|
|
50
50
|
"scripts": {
|
|
51
51
|
"dev": "vite",
|
|
52
|
-
"build": "rm -rf dist && bunx rolldown --config rolldown.config.ts && bunx tsc --emitDeclarationOnly && bunx tsc-alias && cp src/index.css dist/index.css",
|
|
52
|
+
"build": "rm -rf dist && bunx rolldown --config rolldown.config.ts && bunx tsc --emitDeclarationOnly && bunx tsc-alias && cp src/index.css dist/index.css && mkdir -p dist/react-ui/ui/DynamicToggle && cp src/react-ui/ui/DynamicToggle/DynamicToggle.css dist/react-ui/ui/DynamicToggle/DynamicToggle.css",
|
|
53
53
|
"typecheck": "bunx tsc --noEmit",
|
|
54
54
|
"lint": "bunx oxlint .",
|
|
55
55
|
"preview": "vite preview",
|
package/src/css.d.ts
CHANGED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gooey morphing primitive types.
|
|
3
|
+
*
|
|
4
|
+
* @module @mks2508/mks-ui/react/primitives/waapi/Gooey
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ReactNode } from 'react';
|
|
8
|
+
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// GooeyFilter
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Props for the GooeyFilter SVG filter definition.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <GooeyFilter id="my-goo" blur={8} />
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export interface IGooeyFilterProps {
|
|
22
|
+
/** Unique filter ID — referenced via `filter: url(#id)` */
|
|
23
|
+
id: string;
|
|
24
|
+
/** Gaussian blur stdDeviation (default: 8) */
|
|
25
|
+
blur?: number;
|
|
26
|
+
/** Alpha channel multiplier in feColorMatrix (default: 20) */
|
|
27
|
+
alphaGain?: number;
|
|
28
|
+
/** Alpha channel offset in feColorMatrix (default: -10) */
|
|
29
|
+
alphaOffset?: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
// GooeyCanvas
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Props for the GooeyCanvas container.
|
|
38
|
+
*
|
|
39
|
+
* Wraps children with an SVG gooey filter. All same-colored children
|
|
40
|
+
* inside automatically merge visually into an organic blob.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* <GooeyCanvas height={40}>
|
|
45
|
+
* <div className="bg-card rounded-full h-10 w-64" />
|
|
46
|
+
* <div className="bg-card absolute bottom-full w-32 h-6" />
|
|
47
|
+
* </GooeyCanvas>
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export interface IGooeyCanvasProps {
|
|
51
|
+
/** Blur radius override. If omitted, auto-calculated from `height`. */
|
|
52
|
+
blur?: number;
|
|
53
|
+
/** Pill height in px (default: 32) */
|
|
54
|
+
height?: number;
|
|
55
|
+
/** Pill width in px (default: 260) */
|
|
56
|
+
width?: number;
|
|
57
|
+
/** Border radius in px (default: 9999) */
|
|
58
|
+
radius?: number;
|
|
59
|
+
/** Fill color (default: 'var(--card)') */
|
|
60
|
+
fillColor?: string;
|
|
61
|
+
/** Bubble height in px when expanded (default: 40% of height) */
|
|
62
|
+
bubbleHeight?: number;
|
|
63
|
+
/** Bubble inset from edges as fraction 0-1 (default: 0.2) */
|
|
64
|
+
bubbleInset?: number;
|
|
65
|
+
/** Whether the bubble is expanded */
|
|
66
|
+
expanded?: boolean;
|
|
67
|
+
/** Drop-shadow outline blur in px (default: 0.5) */
|
|
68
|
+
outlineBlur?: number;
|
|
69
|
+
/** Drop-shadow outline color (default: 'var(--border)') */
|
|
70
|
+
outlineColor?: string;
|
|
71
|
+
/** Number of stacked drop-shadows for outline thickness (default: 2) */
|
|
72
|
+
outlineLayers?: number;
|
|
73
|
+
/** Alpha gain override */
|
|
74
|
+
alphaGain?: number;
|
|
75
|
+
/** Alpha offset override */
|
|
76
|
+
alphaOffset?: number;
|
|
77
|
+
/** Expand animation duration in ms (default: 550) */
|
|
78
|
+
expandDuration?: number;
|
|
79
|
+
/** Collapse animation duration in ms (default: 400) */
|
|
80
|
+
collapseDuration?: number;
|
|
81
|
+
/** Expand easing override (default: SPRING_GENTLE) */
|
|
82
|
+
expandEasing?: string;
|
|
83
|
+
/** Collapse easing override (default: EASE_OUT_CUBIC) */
|
|
84
|
+
collapseEasing?: string;
|
|
85
|
+
/** Extra className on the filter container */
|
|
86
|
+
className?: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// MorphPath
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Props for the MorphPath SVG path component.
|
|
95
|
+
*
|
|
96
|
+
* Renders a parametric `<path>` that morphs from a pill shape to a
|
|
97
|
+
* pill+body blob based on the `progress` value.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```tsx
|
|
101
|
+
* <svg>
|
|
102
|
+
* <MorphPath pillWidth={260} bodyWidth={180} totalHeight={60} progress={0.5} fill="var(--card)" />
|
|
103
|
+
* </svg>
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export interface IMorphPathProps extends React.SVGProps<SVGPathElement> {
|
|
107
|
+
/** Pill width in px */
|
|
108
|
+
pillWidth: number;
|
|
109
|
+
/** Body (expanded area) width in px */
|
|
110
|
+
bodyWidth: number;
|
|
111
|
+
/** Total height (pill + body) in px */
|
|
112
|
+
totalHeight: number;
|
|
113
|
+
/** Morph progress: 0 = pill only, 1 = fully expanded */
|
|
114
|
+
progress: number;
|
|
115
|
+
/** Pill height (default: 34) */
|
|
116
|
+
pillHeight?: number;
|
|
117
|
+
/** Body expansion direction relative to pill */
|
|
118
|
+
direction?: 'down' | 'up';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
122
|
+
// useMorphPath
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Options for the useMorphPath hook.
|
|
127
|
+
*/
|
|
128
|
+
export interface IUseMorphPathOptions {
|
|
129
|
+
/** Pill width in px */
|
|
130
|
+
pillWidth: number;
|
|
131
|
+
/** Body width in px */
|
|
132
|
+
bodyWidth: number;
|
|
133
|
+
/** Total height in px */
|
|
134
|
+
totalHeight: number;
|
|
135
|
+
/** Morph progress 0→1 */
|
|
136
|
+
progress: number;
|
|
137
|
+
/** Pill height (default: 34) */
|
|
138
|
+
pillHeight?: number;
|
|
139
|
+
/** Body direction */
|
|
140
|
+
direction?: 'down' | 'up';
|
|
141
|
+
}
|