@patternmode/swatch 0.9.3 → 0.10.1
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/README.md +23 -0
- package/dist/DistributionBar/distribution-bar-root.d.ts +3 -3
- package/dist/DistributionBar/distribution-bar-root.d.ts.map +1 -1
- package/dist/Swatch/swatch-atmosphere.d.ts.map +1 -1
- package/dist/Swatch/swatch-colors.d.ts.map +1 -1
- package/dist/Swatch/swatch-root.d.ts +1 -1
- package/dist/Swatch/swatch-root.d.ts.map +1 -1
- package/dist/Swatch/swatch-types.d.ts +52 -12
- package/dist/Swatch/swatch-types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +88 -47
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/swatch.d.ts +1 -1
- package/dist/swatch.d.ts.map +1 -1
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -33,6 +33,29 @@ export function Example() {
|
|
|
33
33
|
|
|
34
34
|
Use `color` for a solid fill, `background` for a CSS background value, or `colors` for weighted palette stops. `Swatch` remains representation-only: compose selection around it, or pass `onRemove` when the swatch should expose its built-in remove request affordance.
|
|
35
35
|
|
|
36
|
+
## Rendering as a child element
|
|
37
|
+
|
|
38
|
+
By default `Swatch` renders its own `<figure>` wrapper. Pass `asChild` to render
|
|
39
|
+
the swatch styling _through_ a single child element instead — the Radix Slot
|
|
40
|
+
pattern. Swatch merges its `className`, `style` (including the
|
|
41
|
+
`--patternmode-swatch-size` / `--patternmode-swatch-fill` variables), `data-*`
|
|
42
|
+
attributes, and remaining props onto the child, and injects the fill / scrim
|
|
43
|
+
layers inside it. The child's own props win on conflict, and event handlers are
|
|
44
|
+
composed.
|
|
45
|
+
|
|
46
|
+
Use this when the swatch must _be_ an interactive element, such as a `<button>`
|
|
47
|
+
cell in a color matrix:
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
<Swatch asChild color="#315c4b" flat shape="block" size="lg">
|
|
51
|
+
<button onClick={() => select("#315c4b")} type="button" />
|
|
52
|
+
</Swatch>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`asChild` requires exactly one React element child and does not support
|
|
56
|
+
`onRemove` (its remove affordance cannot be composed into an arbitrary slotted
|
|
57
|
+
element). Wrap a default Swatch when a remove control is required.
|
|
58
|
+
|
|
36
59
|
## Optimized images
|
|
37
60
|
|
|
38
61
|
Swatch can frame media via `children`, but it does not optimize images itself.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HTMLAttributes } from "react";
|
|
2
2
|
import type { DistributionBarSegment } from "./distribution-bar-math";
|
|
3
|
-
export interface DistributionDisplayProps extends Omit<HTMLAttributes<
|
|
3
|
+
export interface DistributionDisplayProps extends Omit<HTMLAttributes<HTMLElement>, "role" | "onSelect"> {
|
|
4
4
|
/** Label used in summary legends for assigned segment weight. */
|
|
5
5
|
assignedLabel?: string;
|
|
6
6
|
/** Label used when `emptyValue` contributes unassigned weight. */
|
|
@@ -51,6 +51,6 @@ export interface DistributionBarProps extends Omit<HTMLAttributes<HTMLFieldSetEl
|
|
|
51
51
|
*/
|
|
52
52
|
step?: number;
|
|
53
53
|
}
|
|
54
|
-
export declare const DistributionDisplay: ({ "aria-label": ariaLabel, assignedLabel, className, emptyLabel, emptyValue, legend, onSegmentSelect, segments, selectedSegmentId, ...props }: DistributionDisplayProps) => import("react
|
|
55
|
-
export declare const DistributionBar: ({ "aria-label": ariaLabel, className, legend, minValue, onChange, segments, step, ...props }: DistributionBarProps) => import("react
|
|
54
|
+
export declare const DistributionDisplay: ({ "aria-label": ariaLabel, assignedLabel, className, emptyLabel, emptyValue, legend, onSegmentSelect, segments, selectedSegmentId, ...props }: DistributionDisplayProps) => import("react").JSX.Element;
|
|
55
|
+
export declare const DistributionBar: ({ "aria-label": ariaLabel, className, legend, minValue, onChange, segments, step, ...props }: DistributionBarProps) => import("react").JSX.Element;
|
|
56
56
|
//# sourceMappingURL=distribution-bar-root.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"distribution-bar-root.d.ts","sourceRoot":"","sources":["../../src/DistributionBar/distribution-bar-root.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAiB,cAAc,EAAiB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"distribution-bar-root.d.ts","sourceRoot":"","sources":["../../src/DistributionBar/distribution-bar-root.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAiB,cAAc,EAAiB,MAAM,OAAO,CAAC;AAO1E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEtE,MAAM,WAAW,wBAAyB,SAAQ,IAAI,CACpD,cAAc,CAAC,WAAW,CAAC,EAC3B,MAAM,GAAG,UAAU,CACpB;IACC,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,KAAK,CAAC;IACxC;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAC5D,QAAQ,EAAE,sBAAsB,EAAE,CAAC;IACnC,mEAAmE;IACnE,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAChD,cAAc,CAAC,mBAAmB,CAAC,EACnC,UAAU,CACX;IACC;;;;OAIG;IACH,MAAM,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,sBAAsB,EAAE,KAAK,IAAI,CAAC;IACxD,6EAA6E;IAC7E,QAAQ,EAAE,sBAAsB,EAAE,CAAC;IACnC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAsND,eAAO,MAAM,mBAAmB,GAAI,+IAWjC,wBAAwB,gCAwD1B,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,8FAS7B,oBAAoB,gCA+EtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swatch-atmosphere.d.ts","sourceRoot":"","sources":["../../src/Swatch/swatch-atmosphere.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,WAAW,uBAAuB;IACtC,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAoDD,eAAO,MAAM,6BAA6B,GACxC,QAAQ,eAAe,EAAE,GAAG,SAAS,EACrC,UAAS,uBAA4B,KACpC,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"swatch-atmosphere.d.ts","sourceRoot":"","sources":["../../src/Swatch/swatch-atmosphere.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,WAAW,uBAAuB;IACtC,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAoDD,eAAO,MAAM,6BAA6B,GACxC,QAAQ,eAAe,EAAE,GAAG,SAAS,EACrC,UAAS,uBAA4B,KACpC,MAAM,GAAG,SA6BX,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swatch-colors.d.ts","sourceRoot":"","sources":["../../src/Swatch/swatch-colors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AA2BtD,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,OAW5C,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,QAAQ,eAAe,EAAE,GAAG,SAAS,KACpC,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"swatch-colors.d.ts","sourceRoot":"","sources":["../../src/Swatch/swatch-colors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AA2BtD,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,OAW5C,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,QAAQ,eAAe,EAAE,GAAG,SAAS,KACpC,MAAM,GAAG,SAyBX,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SwatchProps } from "./swatch-types";
|
|
2
|
-
export declare const Swatch: ({ "aria-label": ariaLabel, background, children, className, color, colors, density, flat, gravity, icon: Icon, isLight, objectFit, objectPosition, onRemove, raised, removeLabel, role: _role, selected, shape, showRing, size, style, texture, unavailable, ...props }: SwatchProps) => import("react
|
|
2
|
+
export declare const Swatch: ({ "aria-label": ariaLabel, asChild, background, children, className, color, colors, density, flat, gravity, icon: Icon, isLight, objectFit, objectPosition, onRemove, raised, removeLabel, role: _role, selected, shape, showRing, size, style, texture, unavailable, ...props }: SwatchProps) => import("react").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=swatch-root.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swatch-root.d.ts","sourceRoot":"","sources":["../../src/Swatch/swatch-root.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"swatch-root.d.ts","sourceRoot":"","sources":["../../src/Swatch/swatch-root.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAmKlD,eAAO,MAAM,MAAM,GAAI,kRA2BpB,WAAW,gCA4Fb,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ObjectFit } from "@patternmode/system";
|
|
2
|
-
import type { ComponentType, HTMLAttributes, ReactNode, SVGProps } from "react";
|
|
2
|
+
import type { ComponentType, HTMLAttributes, ReactElement, ReactNode, SVGProps } from "react";
|
|
3
3
|
export declare const SWATCH_SIZES: readonly ["2xs", "xs", "sm", "base", "lg", "xl", "2xl", "3xl", "4xl", "5xl", "6xl", "7xl"];
|
|
4
4
|
export declare const SWATCH_SIZE_VALUES: {
|
|
5
5
|
readonly "4xl": "4.5rem";
|
|
@@ -26,16 +26,14 @@ export type SwatchColorStop = string | {
|
|
|
26
26
|
};
|
|
27
27
|
type SwatchIcon = ComponentType<SVGProps<SVGSVGElement>>;
|
|
28
28
|
export declare const getSwatchSizeVariableStyle: (size: SwatchSize, variableName?: string) => Record<string, string>;
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Visual and behavioural props shared by every Swatch rendering mode. These
|
|
31
|
+
* map deterministically to the fill, scrim, shape, and size treatment
|
|
32
|
+
* regardless of whether the swatch renders its own wrapper or an `asChild`
|
|
33
|
+
* element.
|
|
34
|
+
*/
|
|
35
|
+
export interface SwatchSharedProps extends HTMLAttributes<HTMLElement> {
|
|
30
36
|
background?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Optional media rendered inside the swatch frame.
|
|
33
|
-
*
|
|
34
|
-
* Swatch does not optimize image elements itself. Next.js consumers can pass
|
|
35
|
-
* their own `next/image` `Image` component here and use `objectFit` /
|
|
36
|
-
* `objectPosition` to align it with the swatch shape.
|
|
37
|
-
*/
|
|
38
|
-
children?: ReactNode;
|
|
39
37
|
color?: string;
|
|
40
38
|
colors?: SwatchColorStop[];
|
|
41
39
|
/**
|
|
@@ -74,9 +72,7 @@ export interface SwatchProps extends HTMLAttributes<HTMLElement> {
|
|
|
74
72
|
* Default `"center"`.
|
|
75
73
|
*/
|
|
76
74
|
objectPosition?: string;
|
|
77
|
-
onRemove?: () => void;
|
|
78
75
|
raised?: boolean;
|
|
79
|
-
removeLabel?: string;
|
|
80
76
|
/**
|
|
81
77
|
* Shows selected state and optional icon overlay.
|
|
82
78
|
*
|
|
@@ -114,5 +110,49 @@ export interface SwatchProps extends HTMLAttributes<HTMLElement> {
|
|
|
114
110
|
*/
|
|
115
111
|
unavailable?: boolean;
|
|
116
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Default Swatch props: the swatch renders its own wrapper element
|
|
115
|
+
* (`<figure>`, or `<fieldset>` when `onRemove` is set).
|
|
116
|
+
*/
|
|
117
|
+
export interface SwatchDefaultProps extends SwatchSharedProps {
|
|
118
|
+
/**
|
|
119
|
+
* Render the swatch styling onto a provided child element instead of an
|
|
120
|
+
* own wrapper. See {@link SwatchAsChildProps}.
|
|
121
|
+
*
|
|
122
|
+
* Default `false`.
|
|
123
|
+
*/
|
|
124
|
+
asChild?: false;
|
|
125
|
+
/**
|
|
126
|
+
* Optional media rendered inside the swatch frame.
|
|
127
|
+
*
|
|
128
|
+
* Swatch does not optimize image elements itself. Next.js consumers can pass
|
|
129
|
+
* their own `next/image` `Image` component here and use `objectFit` /
|
|
130
|
+
* `objectPosition` to align it with the swatch shape.
|
|
131
|
+
*/
|
|
132
|
+
children?: ReactNode;
|
|
133
|
+
/** Renders a remove affordance and calls this after stopping propagation. */
|
|
134
|
+
onRemove?: () => void;
|
|
135
|
+
/** Accessible label for the remove affordance. Defaults to the swatch label. */
|
|
136
|
+
removeLabel?: string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* `asChild` Swatch props: the swatch merges its className, style (size/fill
|
|
140
|
+
* CSS variables), data attributes, and other props onto the single React
|
|
141
|
+
* element passed as `children`, rendering through it (Radix Slot pattern)
|
|
142
|
+
* instead of emitting its own wrapper. Use this when the swatch must *be* an
|
|
143
|
+
* interactive element, such as a `<button>` cell in a color matrix.
|
|
144
|
+
*
|
|
145
|
+
* `onRemove` is unsupported in this mode — its remove affordance cannot be
|
|
146
|
+
* composed into an arbitrary slotted element. Wrap a default Swatch instead
|
|
147
|
+
* when a remove control is required.
|
|
148
|
+
*/
|
|
149
|
+
export interface SwatchAsChildProps extends SwatchSharedProps {
|
|
150
|
+
asChild: true;
|
|
151
|
+
/** The single element the swatch styling is merged onto and rendered through. */
|
|
152
|
+
children: ReactElement;
|
|
153
|
+
onRemove?: never;
|
|
154
|
+
removeLabel?: never;
|
|
155
|
+
}
|
|
156
|
+
export type SwatchProps = SwatchDefaultProps | SwatchAsChildProps;
|
|
117
157
|
export {};
|
|
118
158
|
//# sourceMappingURL=swatch-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swatch-types.d.ts","sourceRoot":"","sources":["../../src/Swatch/swatch-types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"swatch-types.d.ts","sourceRoot":"","sources":["../../src/Swatch/swatch-types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9F,eAAO,MAAM,YAAY,4FAA8D,CAAC;AAExF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;CAMgB,CAAC;AAEhD,eAAO,MAAM,aAAa,gDAAiD,CAAC;AAE5E,eAAO,MAAM,eAAe,yBAA0B,CAAC;AAEvD,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AACvD,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AACzD,MAAM,MAAM,aAAa,GAAG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ACH,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D;;;;;OAKG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,gFAAgF;IAChF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,OAAO,EAAE,IAAI,CAAC;IACd,iFAAiF;IACjF,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB;AAED,MAAM,MAAM,WAAW,GAAG,kBAAkB,GAAG,kBAAkB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { DistributionBar, type DistributionBarProps, type DistributionBarSegment, type DistributionBarSegmentUpdate, DistributionDisplay, type DistributionDisplayProps, getDistributionBoundaryPercent, getDistributionTotal, getSwatchAtmosphereBackground, getSwatchColorsBackground, getSwatchSizeVariableStyle, moveDistributionBoundary, removeDistributionSegment, SWATCH_SHAPES, SWATCH_SIZE_VALUES, SWATCH_SIZES, SWATCH_TEXTURES, Swatch, type SwatchAtmosphereOptions, type SwatchColorStop, type SwatchProps, type SwatchShape, type SwatchSize, type SwatchTexture, updateDistributionSegment, } from "./swatch";
|
|
1
|
+
export { DistributionBar, type DistributionBarProps, type DistributionBarSegment, type DistributionBarSegmentUpdate, DistributionDisplay, type DistributionDisplayProps, getDistributionBoundaryPercent, getDistributionTotal, getSwatchAtmosphereBackground, getSwatchColorsBackground, getSwatchSizeVariableStyle, moveDistributionBoundary, removeDistributionSegment, SWATCH_SHAPES, SWATCH_SIZE_VALUES, SWATCH_SIZES, SWATCH_TEXTURES, Swatch, type SwatchAsChildProps, type SwatchAtmosphereOptions, type SwatchColorStop, type SwatchDefaultProps, type SwatchProps, type SwatchShape, type SwatchSharedProps, type SwatchSize, type SwatchTexture, updateDistributionSegment, } from "./swatch";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,8BAA8B,EAC9B,oBAAoB,EACpB,6BAA6B,EAC7B,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EACzB,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,MAAM,EACN,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,yBAAyB,GAC1B,MAAM,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,8BAA8B,EAC9B,oBAAoB,EACpB,6BAA6B,EAC7B,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EACzB,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,MAAM,EACN,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,yBAAyB,GAC1B,MAAM,UAAU,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { PATTERNMODE_SIZES, PATTERNMODE_SIZE_VALUES, getObjectSizingStyle, joinC
|
|
|
2
2
|
import { LazyMotion, domMax, m } from "motion/react";
|
|
3
3
|
import { useRef } from "react";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Slot, Slottable } from "@radix-ui/react-slot";
|
|
5
6
|
//#region src/DistributionBar/distribution-bar-math.ts
|
|
6
7
|
const sanitizeValue = (value) => Number.isFinite(value) ? Math.max(0, value) : 0;
|
|
7
8
|
const clamp$1 = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
@@ -102,7 +103,9 @@ const DistributionSegments = ({ emptyValue = 0, onSegmentSelect, segments, selec
|
|
|
102
103
|
"aria-pressed": isSelected,
|
|
103
104
|
className: "patternmode-distribution-bar__segment",
|
|
104
105
|
"data-selected": isSelected ? "true" : void 0,
|
|
105
|
-
onClick: () =>
|
|
106
|
+
onClick: () => {
|
|
107
|
+
onSegmentSelect(segment);
|
|
108
|
+
},
|
|
106
109
|
style: segmentStyle,
|
|
107
110
|
type: "button"
|
|
108
111
|
}, segment.id);
|
|
@@ -120,17 +123,22 @@ const DistributionSegments = ({ emptyValue = 0, onSegmentSelect, segments, selec
|
|
|
120
123
|
});
|
|
121
124
|
const DistributionSegmentLegend = ({ emptyLabel, emptyValue = 0, segments, total }) => /* @__PURE__ */ jsxs("div", {
|
|
122
125
|
className: "patternmode-distribution-bar__legend",
|
|
123
|
-
children: [segments.map((segment) =>
|
|
124
|
-
/* @__PURE__ */
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
126
|
+
children: [segments.map((segment) => {
|
|
127
|
+
return /* @__PURE__ */ jsxs("span", { children: [
|
|
128
|
+
/* @__PURE__ */ jsx("span", {
|
|
129
|
+
"aria-hidden": "true",
|
|
130
|
+
className: "patternmode-distribution-bar__swatch",
|
|
131
|
+
style: {
|
|
132
|
+
"--patternmode-distribution-segment-color": segment.color,
|
|
133
|
+
backgroundColor: void 0
|
|
134
|
+
}
|
|
135
|
+
}),
|
|
136
|
+
segment.label ?? segment.id,
|
|
137
|
+
" ",
|
|
138
|
+
getDerivedDistributionPercentage(segment.value, total),
|
|
139
|
+
"%"
|
|
140
|
+
] }, segment.id);
|
|
141
|
+
}), emptyValue > 0 && emptyLabel !== void 0 && emptyLabel !== "" ? /* @__PURE__ */ jsxs("span", { children: [
|
|
134
142
|
/* @__PURE__ */ jsx("span", {
|
|
135
143
|
"aria-hidden": "true",
|
|
136
144
|
className: "patternmode-distribution-bar__swatch patternmode-distribution-bar__swatch--empty"
|
|
@@ -165,8 +173,12 @@ const DistributionBarHandle = ({ "aria-label": ariaLabel, boundaryPercent, onDra
|
|
|
165
173
|
dragElastic: 0,
|
|
166
174
|
dragMomentum: false,
|
|
167
175
|
dragSnapToOrigin: true,
|
|
168
|
-
onDrag: (_event, info) =>
|
|
169
|
-
|
|
176
|
+
onDrag: (_event, info) => {
|
|
177
|
+
onDrag(info);
|
|
178
|
+
},
|
|
179
|
+
onDragEnd: (_event, info) => {
|
|
180
|
+
onDragEnd(info);
|
|
181
|
+
},
|
|
170
182
|
onDragStart,
|
|
171
183
|
onKeyDown,
|
|
172
184
|
style: { left: `calc(${boundaryPercent}% - 1.375rem)` },
|
|
@@ -265,10 +277,16 @@ const DistributionBar = ({ "aria-label": ariaLabel, className, legend = "segment
|
|
|
265
277
|
return /* @__PURE__ */ jsx(DistributionBarHandle, {
|
|
266
278
|
"aria-label": `Adjust ${segment.label ?? segment.id} and ${nextSegment?.label ?? nextSegment?.id} distribution`,
|
|
267
279
|
boundaryPercent,
|
|
268
|
-
onDrag: (info) =>
|
|
269
|
-
|
|
280
|
+
onDrag: (info) => {
|
|
281
|
+
handleDrag(boundaryIndex, info);
|
|
282
|
+
},
|
|
283
|
+
onDragEnd: (info) => {
|
|
284
|
+
handleDragEnd(boundaryIndex, info);
|
|
285
|
+
},
|
|
270
286
|
onDragStart: handleDragStart,
|
|
271
|
-
onKeyDown: (event) =>
|
|
287
|
+
onKeyDown: (event) => {
|
|
288
|
+
handleKeyDown(event, boundaryIndex);
|
|
289
|
+
}
|
|
272
290
|
}, `${segment.id}-${nextSegment?.id ?? "end"}`);
|
|
273
291
|
})]
|
|
274
292
|
}), legend === "segments" ? /* @__PURE__ */ jsx(DistributionSegmentLegend, {
|
|
@@ -340,24 +358,26 @@ const POOLS = [
|
|
|
340
358
|
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
341
359
|
const normalizeHex$1 = (color) => {
|
|
342
360
|
const value = color.trim().replace(/^#/u, "");
|
|
343
|
-
if (/^[\da-f]{3}$/iu.test(value)) return [
|
|
361
|
+
if (/^[\da-f]{3}$/iu.test(value)) return `${value[0]}${value[0]}${value[1]}${value[1]}${value[2]}${value[2]}`;
|
|
344
362
|
if (/^[\da-f]{6}$/iu.test(value)) return value;
|
|
345
363
|
return null;
|
|
346
364
|
};
|
|
347
365
|
const withAlpha = (color, alpha) => {
|
|
348
366
|
const hex = normalizeHex$1(color);
|
|
349
|
-
if (hex) return `#${hex}${Math.round(clamp(alpha, 0, 255)).toString(16).padStart(2, "0")}`;
|
|
367
|
+
if (hex !== null) return `#${hex}${Math.round(clamp(alpha, 0, 255)).toString(16).padStart(2, "0")}`;
|
|
350
368
|
return `color-mix(in srgb, ${color} ${Math.round(clamp(alpha, 0, 255) / 255 * 100)}%, transparent)`;
|
|
351
369
|
};
|
|
352
370
|
const getSwatchAtmosphereBackground = (colors, options = {}) => {
|
|
353
|
-
if (
|
|
371
|
+
if (colors === void 0 || colors.length === 0) return;
|
|
354
372
|
const density = clamp(options.density ?? .5, 0, 1);
|
|
355
373
|
const gravity = clamp(options.gravity ?? 0, -1, 1);
|
|
356
374
|
const gy = Math.round(gravity * 8);
|
|
357
375
|
const reach = Math.round(50 + (1 - density) * 15);
|
|
358
376
|
return colors.map((stop, index) => {
|
|
359
377
|
const color = typeof stop === "string" ? stop : stop.color;
|
|
360
|
-
const
|
|
378
|
+
const pool = POOLS[index % POOLS.length];
|
|
379
|
+
if (pool === void 0) throw new Error("Expected atmosphere pool to exist.");
|
|
380
|
+
const [x, y, baseAlpha, radiusDelta, gravitySign] = pool;
|
|
361
381
|
const cycle = Math.floor(index / POOLS.length);
|
|
362
382
|
const alpha = Math.max(34, baseAlpha - cycle * 34);
|
|
363
383
|
const focalY = clamp(y + gravitySign * gy, 0, 100);
|
|
@@ -369,7 +389,7 @@ const getSwatchAtmosphereBackground = (colors, options = {}) => {
|
|
|
369
389
|
//#region src/Swatch/swatch-colors.ts
|
|
370
390
|
const normalizeHex = (hex) => {
|
|
371
391
|
const value = hex.trim().replace(/^#/u, "");
|
|
372
|
-
if (/^[\da-f]{3}$/iu.test(value)) return [
|
|
392
|
+
if (/^[\da-f]{3}$/iu.test(value)) return `${value[0]}${value[0]}${value[1]}${value[1]}${value[2]}${value[2]}`;
|
|
373
393
|
if (/^[\da-f]{6}$/iu.test(value)) return value;
|
|
374
394
|
return null;
|
|
375
395
|
};
|
|
@@ -381,15 +401,16 @@ const getRatioWeight = (ratio) => {
|
|
|
381
401
|
const formatPercent = (value) => `${Number.isInteger(value) ? value : Number(value.toFixed(2))}%`;
|
|
382
402
|
const isLightColor = (color) => {
|
|
383
403
|
const normalized = normalizeHex(color);
|
|
384
|
-
if (
|
|
404
|
+
if (normalized === null) return false;
|
|
385
405
|
const red = Number.parseInt(normalized.slice(0, 2), 16);
|
|
386
406
|
const green = Number.parseInt(normalized.slice(2, 4), 16);
|
|
387
407
|
const blue = Number.parseInt(normalized.slice(4, 6), 16);
|
|
388
408
|
return (.299 * red + .587 * green + .114 * blue) / 255 > .62;
|
|
389
409
|
};
|
|
390
410
|
const getSwatchColorsBackground = (colors) => {
|
|
391
|
-
if (
|
|
392
|
-
|
|
411
|
+
if (colors === void 0 || colors.length === 0) return;
|
|
412
|
+
const [singleColor] = colors;
|
|
413
|
+
if (colors.length === 1 && singleColor !== void 0) return toColorStop(singleColor).color;
|
|
393
414
|
const stops = colors.map(toColorStop);
|
|
394
415
|
const weights = stops.map((stop) => getRatioWeight(stop.ratio));
|
|
395
416
|
const rawTotal = weights.reduce((sum, ratio) => sum + ratio, 0);
|
|
@@ -435,7 +456,7 @@ const SwatchContent = ({ children, flat, Icon, mediaStyle, selected, unavailable
|
|
|
435
456
|
"aria-hidden": "true",
|
|
436
457
|
className: "patternmode-swatch__fill"
|
|
437
458
|
}),
|
|
438
|
-
children ? /* @__PURE__ */ jsx("span", {
|
|
459
|
+
children !== void 0 && children !== null ? /* @__PURE__ */ jsx("span", {
|
|
439
460
|
className: "patternmode-swatch__media",
|
|
440
461
|
style: mediaStyle,
|
|
441
462
|
children
|
|
@@ -469,7 +490,7 @@ const getSwatchFill = ({ background, color, colors, density, gravity, texture })
|
|
|
469
490
|
};
|
|
470
491
|
const getSwatchTone = ({ background, color, colorsBackground, isLight }) => {
|
|
471
492
|
if (isLight !== void 0) return isLight ? "light" : "dark";
|
|
472
|
-
if (color && !background && !colorsBackground && isLightColor(color)) return "light";
|
|
493
|
+
if (color !== void 0 && color !== "" && !(background !== void 0 && background !== "") && !(colorsBackground !== void 0 && colorsBackground !== "") && isLightColor(color)) return "light";
|
|
473
494
|
return "dark";
|
|
474
495
|
};
|
|
475
496
|
const getSwatchDataProps = ({ flat, lightTone, raised, selected, shape, showRing, size, unavailable }) => ({
|
|
@@ -483,7 +504,32 @@ const getSwatchDataProps = ({ flat, lightTone, raised, selected, shape, showRing
|
|
|
483
504
|
"data-tone": lightTone,
|
|
484
505
|
"data-unavailable": unavailable ? "true" : void 0
|
|
485
506
|
});
|
|
486
|
-
const
|
|
507
|
+
const RemovableSwatch = ({ ariaLabel, children, className, dataProps, onRemove, removeLabel, rootStyle, props }) => {
|
|
508
|
+
const handleRemove = (event) => {
|
|
509
|
+
event.stopPropagation();
|
|
510
|
+
onRemove();
|
|
511
|
+
};
|
|
512
|
+
return /* @__PURE__ */ jsxs("fieldset", {
|
|
513
|
+
...props,
|
|
514
|
+
...dataProps,
|
|
515
|
+
"aria-label": ariaLabel,
|
|
516
|
+
className: joinClassNames("patternmode-swatch", className),
|
|
517
|
+
style: rootStyle,
|
|
518
|
+
children: [children, /* @__PURE__ */ jsx("button", {
|
|
519
|
+
"aria-label": removeLabel,
|
|
520
|
+
className: "patternmode-swatch__remove",
|
|
521
|
+
onClick: handleRemove,
|
|
522
|
+
type: "button",
|
|
523
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
524
|
+
"aria-hidden": "true",
|
|
525
|
+
fill: "none",
|
|
526
|
+
viewBox: "0 0 20 20",
|
|
527
|
+
children: /* @__PURE__ */ jsx("path", { d: "M5.5 5.5l9 9M14.5 5.5l-9 9" })
|
|
528
|
+
})
|
|
529
|
+
})]
|
|
530
|
+
});
|
|
531
|
+
};
|
|
532
|
+
const Swatch = ({ "aria-label": ariaLabel, asChild = false, background, children, className, color, colors, density, flat = false, gravity, icon: Icon, isLight, objectFit, objectPosition, onRemove, raised = false, removeLabel, role: _role, selected = false, shape = "circle", showRing = true, size = "base", style, texture, unavailable = false, ...props }) => {
|
|
487
533
|
const { colorsBackground, fill } = getSwatchFill({
|
|
488
534
|
background,
|
|
489
535
|
color,
|
|
@@ -498,7 +544,7 @@ const Swatch = ({ "aria-label": ariaLabel, background, children, className, colo
|
|
|
498
544
|
colorsBackground,
|
|
499
545
|
isLight
|
|
500
546
|
});
|
|
501
|
-
const resolvedRemoveLabel = removeLabel ?? (ariaLabel ? `Remove ${ariaLabel}` : "Remove");
|
|
547
|
+
const resolvedRemoveLabel = removeLabel ?? (ariaLabel !== void 0 && ariaLabel !== "" ? `Remove ${ariaLabel}` : "Remove");
|
|
502
548
|
const rootStyle = {
|
|
503
549
|
...getSwatchSizeVariableStyle(size),
|
|
504
550
|
"--patternmode-swatch-fill": fill,
|
|
@@ -518,36 +564,31 @@ const Swatch = ({ "aria-label": ariaLabel, background, children, className, colo
|
|
|
518
564
|
size,
|
|
519
565
|
unavailable
|
|
520
566
|
});
|
|
521
|
-
const handleRemove = (event) => {
|
|
522
|
-
event.stopPropagation();
|
|
523
|
-
onRemove?.();
|
|
524
|
-
};
|
|
525
567
|
const swatchContent = /* @__PURE__ */ jsx(SwatchContent, {
|
|
526
568
|
flat,
|
|
527
569
|
Icon,
|
|
528
570
|
mediaStyle,
|
|
529
571
|
selected,
|
|
530
572
|
unavailable,
|
|
531
|
-
children
|
|
573
|
+
children: asChild ? void 0 : children
|
|
532
574
|
});
|
|
533
|
-
if (
|
|
575
|
+
if (asChild) return /* @__PURE__ */ jsxs(Slot, {
|
|
534
576
|
...props,
|
|
535
577
|
...dataProps,
|
|
536
578
|
"aria-label": ariaLabel,
|
|
537
579
|
className: joinClassNames("patternmode-swatch", className),
|
|
538
580
|
style: rootStyle,
|
|
539
|
-
children: [swatchContent, /* @__PURE__ */ jsx(
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
})]
|
|
581
|
+
children: [swatchContent, /* @__PURE__ */ jsx(Slottable, { children })]
|
|
582
|
+
});
|
|
583
|
+
if (onRemove !== void 0) return /* @__PURE__ */ jsx(RemovableSwatch, {
|
|
584
|
+
ariaLabel,
|
|
585
|
+
className,
|
|
586
|
+
dataProps,
|
|
587
|
+
onRemove,
|
|
588
|
+
props,
|
|
589
|
+
removeLabel: resolvedRemoveLabel,
|
|
590
|
+
rootStyle,
|
|
591
|
+
children: swatchContent
|
|
551
592
|
});
|
|
552
593
|
return /* @__PURE__ */ jsx("figure", {
|
|
553
594
|
...props,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["clamp","normalizeHex"],"sources":["../src/DistributionBar/distribution-bar-math.ts","../src/DistributionBar/distribution-bar-root.tsx","../src/Swatch/swatch-atmosphere.ts","../src/Swatch/swatch-colors.ts","../src/Swatch/swatch-types.ts","../src/Swatch/swatch-root.tsx"],"sourcesContent":["/** Weighted segment used by DistributionBar and DistributionDisplay. */\nexport interface DistributionBarSegment {\n color: string;\n id: string;\n label?: string;\n /** Relative weight, not a persisted percentage. Invalid or negative values render as 0. */\n value: number;\n}\n\n/** Segment metadata update; weight changes happen through boundary movement. */\nexport type DistributionBarSegmentUpdate = Partial<Omit<DistributionBarSegment, \"value\">> & {\n value?: never;\n};\n\nconst sanitizeValue = (value: number): number => (Number.isFinite(value) ? Math.max(0, value) : 0);\n\nconst clamp = (value: number, min: number, max: number): number =>\n Math.min(Math.max(value, min), max);\n\nconst roundValue = (value: number): number => Number(value.toFixed(1));\n\n/** Sums sanitized segment weights, treating invalid or negative values as 0. */\nexport const getDistributionTotal = (segments: DistributionBarSegment[]): number =>\n segments.reduce((sum, segment) => sum + sanitizeValue(segment.value), 0);\n\n/** Returns the percentage position of the boundary after `boundaryIndex`. */\nexport const getDistributionBoundaryPercent = (\n segments: DistributionBarSegment[],\n boundaryIndex: number,\n): number => {\n const total = getDistributionTotal(segments);\n if (total <= 0) {\n return 0;\n }\n\n const boundaryValue = segments\n .slice(0, boundaryIndex + 1)\n .reduce((sum, segment) => sum + sanitizeValue(segment.value), 0);\n return roundValue((boundaryValue / total) * 100);\n};\n\n/**\n * Moves the boundary between two adjacent segments while preserving their sum.\n *\n * `deltaValue` is applied to the left segment and subtracted from the right\n * segment. `minValue` prevents either side of the pair from collapsing below a\n * caller-defined minimum.\n */\nexport const moveDistributionBoundary = (\n segments: DistributionBarSegment[],\n boundaryIndex: number,\n deltaValue: number,\n minValue: number,\n): DistributionBarSegment[] => {\n const left = segments[boundaryIndex];\n const right = segments[boundaryIndex + 1];\n if (!(left && right)) {\n return segments;\n }\n\n const pairTotal = sanitizeValue(left.value) + sanitizeValue(right.value);\n const clampedMin = Math.max(0, Math.min(minValue, pairTotal / 2));\n const nextLeft = clamp(\n sanitizeValue(left.value) + deltaValue,\n clampedMin,\n pairTotal - clampedMin,\n );\n const nextRight = pairTotal - nextLeft;\n\n return segments.map((segment, index) => {\n if (index === boundaryIndex) {\n return { ...segment, value: roundValue(nextLeft) };\n }\n if (index === boundaryIndex + 1) {\n return { ...segment, value: roundValue(nextRight) };\n }\n return segment;\n });\n};\n\n/** Removes a segment and redistributes its weight proportionally to the rest. */\nexport const removeDistributionSegment = (\n segments: DistributionBarSegment[],\n segmentId: string,\n): DistributionBarSegment[] => {\n if (segments.length <= 1) {\n return segments;\n }\n\n const removed = segments.find((segment) => segment.id === segmentId);\n if (!removed) {\n return segments;\n }\n\n const remaining = segments.filter((segment) => segment.id !== segmentId);\n const removedValue = sanitizeValue(removed.value);\n const remainingTotal = getDistributionTotal(remaining);\n if (remainingTotal <= 0) {\n const equalValue = removedValue / remaining.length;\n return remaining.map((segment) => ({\n ...segment,\n value: roundValue(equalValue),\n }));\n }\n\n let assignedValue = 0;\n const originalTotal = getDistributionTotal(segments);\n return remaining.map((segment, index) => {\n if (index === remaining.length - 1) {\n return { ...segment, value: roundValue(originalTotal - assignedValue) };\n }\n\n const nextValue = roundValue(\n sanitizeValue(segment.value) + (removedValue * sanitizeValue(segment.value)) / remainingTotal,\n );\n assignedValue += nextValue;\n return { ...segment, value: nextValue };\n });\n};\n\n/** Updates non-weight segment metadata such as label or color. */\nexport const updateDistributionSegment = (\n segments: DistributionBarSegment[],\n segmentId: string,\n update: DistributionBarSegmentUpdate,\n): DistributionBarSegment[] =>\n segments.map((segment) => (segment.id === segmentId ? { ...segment, ...update } : segment));\n","import { joinClassNames } from \"@patternmode/system\";\nimport { domMax, LazyMotion, m } from \"motion/react\";\nimport type { PanInfo } from \"motion/react\";\nimport type { CSSProperties, HTMLAttributes, KeyboardEvent } from \"react\";\nimport { useRef } from \"react\";\n\nimport {\n getDistributionBoundaryPercent,\n getDistributionTotal,\n moveDistributionBoundary,\n} from \"./distribution-bar-math\";\nimport type { DistributionBarSegment } from \"./distribution-bar-math\";\n\nexport interface DistributionDisplayProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n \"role\" | \"onSelect\"\n> {\n /** Label used in summary legends for assigned segment weight. */\n assignedLabel?: string;\n /** Label used when `emptyValue` contributes unassigned weight. */\n emptyLabel?: string;\n /**\n * Extra unassigned weight included in derived percentage calculations.\n *\n * Default `0`.\n */\n emptyValue?: number;\n /**\n * Legend style for the read-only display.\n *\n * Default `\"segments\"`.\n */\n legend?: \"segments\" | \"summary\" | false;\n /**\n * When provided, each segment renders as a button and selecting one\n * invokes this callback. Pair with `selectedSegmentId` to mark a segment\n * as selected (renders a ring). Read-only by default.\n */\n onSegmentSelect?: (segment: DistributionBarSegment) => void;\n segments: DistributionBarSegment[];\n /** Id of the selected segment — renders a ring on that segment. */\n selectedSegmentId?: string;\n}\n\nexport interface DistributionBarProps extends Omit<\n HTMLAttributes<HTMLFieldSetElement>,\n \"onChange\"\n> {\n /**\n * Show the per-segment legend below the bar, or hide it.\n *\n * Default `\"segments\"`.\n */\n legend?: \"segments\" | false;\n /**\n * Minimum weight each side of a dragged boundary must retain.\n *\n * Default `4`.\n */\n minValue?: number;\n /** Receives the full next segment list after drag or keyboard boundary moves. */\n onChange?: (segments: DistributionBarSegment[]) => void;\n /** Weighted segments; displayed percentages are derived from their total. */\n segments: DistributionBarSegment[];\n /**\n * Keyboard adjustment amount for boundary handles.\n *\n * Default `1`.\n */\n step?: number;\n}\n\ninterface DistributionSegmentsProps {\n emptyValue?: number;\n onSegmentSelect?: (segment: DistributionBarSegment) => void;\n segments: DistributionBarSegment[];\n selectedSegmentId?: string;\n total: number;\n}\n\ninterface DistributionSegmentLegendProps {\n emptyLabel?: string;\n emptyValue?: number;\n segments: DistributionBarSegment[];\n total: number;\n}\n\ninterface DistributionSummaryLegendProps {\n assignedLabel: string;\n emptyLabel: string;\n emptyValue: number;\n total: number;\n}\n\ninterface DistributionBarHandleProps {\n \"aria-label\": string;\n boundaryPercent: number;\n onDrag: (info: PanInfo) => void;\n onDragEnd: (info: PanInfo) => void;\n onDragStart: () => void;\n onKeyDown: (event: KeyboardEvent<HTMLButtonElement>) => void;\n}\n\nconst getRenderableDistributionValue = (value: number): number =>\n Number.isFinite(value) ? Math.max(0, value) : 0;\n\nconst getDerivedDistributionPercentage = (value: number, total: number): number => {\n if (!(total > 0 && Number.isFinite(value))) {\n return 0;\n }\n\n return Math.round((Math.max(0, value) / total) * 100);\n};\n\nconst getDistributionDisplayTotal = (\n segments: DistributionBarSegment[],\n emptyValue: number,\n): number => getDistributionTotal(segments) + getRenderableDistributionValue(emptyValue);\n\nconst getDistributionDisplayAccessibleLabel = (\n segments: DistributionBarSegment[],\n emptyValue: number,\n emptyLabel: string,\n total: number,\n): string => {\n const segmentLabels = segments.map(\n (segment) =>\n `${segment.label ?? segment.id} ${getDerivedDistributionPercentage(segment.value, total)}%`,\n );\n if (emptyValue > 0) {\n segmentLabels.push(`${emptyLabel} ${getDerivedDistributionPercentage(emptyValue, total)}%`);\n }\n\n return segmentLabels.join(\", \");\n};\n\nconst DistributionSegments = ({\n emptyValue = 0,\n onSegmentSelect,\n segments,\n selectedSegmentId,\n total,\n}: DistributionSegmentsProps) => (\n <div className=\"patternmode-distribution-bar__segments\">\n {segments.map((segment) => {\n const segmentStyle = {\n \"--patternmode-distribution-segment-color\": segment.color,\n width:\n total > 0 ? `${(getRenderableDistributionValue(segment.value) / total) * 100}%` : \"0%\",\n } as CSSProperties;\n const isSelected = selectedSegmentId === segment.id;\n\n if (onSegmentSelect) {\n return (\n <button\n aria-label={`${segment.label ?? segment.id} ${getDerivedDistributionPercentage(segment.value, total)}%`}\n aria-pressed={isSelected}\n className=\"patternmode-distribution-bar__segment\"\n data-selected={isSelected ? \"true\" : undefined}\n key={segment.id}\n onClick={() => onSegmentSelect(segment)}\n style={segmentStyle}\n type=\"button\"\n />\n );\n }\n\n return (\n <div\n aria-hidden=\"true\"\n className=\"patternmode-distribution-bar__segment\"\n data-selected={isSelected ? \"true\" : undefined}\n key={segment.id}\n style={segmentStyle}\n />\n );\n })}\n {emptyValue > 0 ? (\n <div\n aria-hidden=\"true\"\n className=\"patternmode-distribution-bar__segment patternmode-distribution-bar__segment--empty\"\n style={{\n width:\n total > 0 ? `${(getRenderableDistributionValue(emptyValue) / total) * 100}%` : \"0%\",\n }}\n />\n ) : null}\n </div>\n);\n\nconst DistributionSegmentLegend = ({\n emptyLabel,\n emptyValue = 0,\n segments,\n total,\n}: DistributionSegmentLegendProps) => (\n <div className=\"patternmode-distribution-bar__legend\">\n {segments.map((segment) => (\n <span key={segment.id}>\n <span\n aria-hidden=\"true\"\n className=\"patternmode-distribution-bar__swatch\"\n style={\n {\n \"--patternmode-distribution-segment-color\": segment.color,\n } as CSSProperties\n }\n />\n {segment.label ?? segment.id} {getDerivedDistributionPercentage(segment.value, total)}%\n </span>\n ))}\n {emptyValue > 0 && emptyLabel ? (\n <span>\n <span\n aria-hidden=\"true\"\n className=\"patternmode-distribution-bar__swatch patternmode-distribution-bar__swatch--empty\"\n />\n {emptyLabel} {getDerivedDistributionPercentage(emptyValue, total)}%\n </span>\n ) : null}\n </div>\n);\n\nconst DistributionSummaryLegend = ({\n assignedLabel,\n emptyLabel,\n emptyValue,\n total,\n}: DistributionSummaryLegendProps) => {\n const emptyPercentage = getDerivedDistributionPercentage(emptyValue, total);\n\n return (\n <div className=\"patternmode-distribution-bar__legend\">\n <span>\n {Math.max(0, 100 - emptyPercentage)}% {assignedLabel}\n </span>\n {emptyValue > 0 ? (\n <span>\n {emptyPercentage}% {emptyLabel}\n </span>\n ) : null}\n </div>\n );\n};\n\nconst DistributionBarHandle = ({\n \"aria-label\": ariaLabel,\n boundaryPercent,\n onDrag,\n onDragEnd,\n onDragStart,\n onKeyDown,\n}: DistributionBarHandleProps) => (\n <LazyMotion features={domMax}>\n <m.button\n aria-label={ariaLabel}\n className=\"patternmode-distribution-bar__handle\"\n drag=\"x\"\n dragElastic={0}\n dragMomentum={false}\n dragSnapToOrigin\n onDrag={(_event, info) => onDrag(info)}\n onDragEnd={(_event, info) => onDragEnd(info)}\n onDragStart={onDragStart}\n onKeyDown={onKeyDown}\n style={{ left: `calc(${boundaryPercent}% - 1.375rem)` }}\n transformTemplate={() => \"none\"}\n type=\"button\"\n />\n </LazyMotion>\n);\n\nexport const DistributionDisplay = ({\n \"aria-label\": ariaLabel,\n assignedLabel = \"assigned\",\n className,\n emptyLabel = \"unassigned\",\n emptyValue = 0,\n legend = \"segments\",\n onSegmentSelect,\n segments,\n selectedSegmentId,\n ...props\n}: DistributionDisplayProps) => {\n const total = getDistributionDisplayTotal(segments, emptyValue);\n const interactive = Boolean(onSegmentSelect);\n const accessibleLabel =\n ariaLabel ?? getDistributionDisplayAccessibleLabel(segments, emptyValue, emptyLabel, total);\n\n const content = (\n <>\n <div className=\"patternmode-distribution-bar__track\">\n <DistributionSegments\n emptyValue={emptyValue}\n onSegmentSelect={onSegmentSelect}\n segments={segments}\n selectedSegmentId={selectedSegmentId}\n total={total}\n />\n </div>\n {legend === \"segments\" ? (\n <DistributionSegmentLegend\n emptyLabel={emptyLabel}\n emptyValue={emptyValue}\n segments={segments}\n total={total}\n />\n ) : null}\n {legend === \"summary\" ? (\n <DistributionSummaryLegend\n assignedLabel={assignedLabel}\n emptyLabel={emptyLabel}\n emptyValue={emptyValue}\n total={total}\n />\n ) : null}\n </>\n );\n const sharedClassName = joinClassNames(\"patternmode-distribution-display\", className);\n\n return interactive ? (\n <fieldset\n {...(props as HTMLAttributes<HTMLFieldSetElement>)}\n aria-label={accessibleLabel}\n className={sharedClassName}\n data-slot=\"distribution-display\"\n >\n {content}\n </fieldset>\n ) : (\n <figure\n {...props}\n aria-label={accessibleLabel}\n className={sharedClassName}\n data-slot=\"distribution-display\"\n >\n {content}\n </figure>\n );\n};\n\nexport const DistributionBar = ({\n \"aria-label\": ariaLabel,\n className,\n legend = \"segments\",\n minValue = 4,\n onChange,\n segments,\n step = 1,\n ...props\n}: DistributionBarProps) => {\n const trackRef = useRef<HTMLDivElement>(null);\n const dragStartSegmentsRef = useRef<DistributionBarSegment[] | null>(null);\n const total = getDistributionTotal(segments);\n\n const moveBoundary = (boundaryIndex: number, deltaValue: number, sourceSegments = segments) => {\n onChange?.(moveDistributionBoundary(sourceSegments, boundaryIndex, deltaValue, minValue));\n };\n\n const handleDragStart = () => {\n dragStartSegmentsRef.current = segments;\n };\n\n const handleDrag = (boundaryIndex: number, info: PanInfo) => {\n const sourceSegments = dragStartSegmentsRef.current ?? segments;\n const sourceTotal = getDistributionTotal(sourceSegments);\n const trackWidth = trackRef.current?.getBoundingClientRect().width ?? 0;\n if (!(trackWidth > 0 && sourceTotal > 0)) {\n return;\n }\n\n moveBoundary(boundaryIndex, (info.offset.x / trackWidth) * sourceTotal, sourceSegments);\n };\n\n const handleDragEnd = (boundaryIndex: number, info: PanInfo) => {\n handleDrag(boundaryIndex, info);\n dragStartSegmentsRef.current = null;\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLButtonElement>, boundaryIndex: number) => {\n if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n moveBoundary(boundaryIndex, -step);\n }\n if (event.key === \"ArrowRight\") {\n event.preventDefault();\n moveBoundary(boundaryIndex, step);\n }\n };\n\n return (\n <fieldset\n {...props}\n aria-label={ariaLabel}\n className={joinClassNames(\"patternmode-distribution-bar\", className)}\n data-slot=\"distribution-bar\"\n >\n <div className=\"patternmode-distribution-bar__track\" ref={trackRef}>\n <DistributionSegments segments={segments} total={total} />\n {segments.slice(0, -1).map((segment, boundaryIndex) => {\n const nextSegment = segments[boundaryIndex + 1];\n const boundaryPercent = getDistributionBoundaryPercent(segments, boundaryIndex);\n const label = `Adjust ${segment.label ?? segment.id} and ${\n nextSegment?.label ?? nextSegment?.id\n } distribution`;\n return (\n <DistributionBarHandle\n aria-label={label}\n boundaryPercent={boundaryPercent}\n key={`${segment.id}-${nextSegment?.id ?? \"end\"}`}\n onDrag={(info) => handleDrag(boundaryIndex, info)}\n onDragEnd={(info) => handleDragEnd(boundaryIndex, info)}\n onDragStart={handleDragStart}\n onKeyDown={(event) => handleKeyDown(event, boundaryIndex)}\n />\n );\n })}\n </div>\n {legend === \"segments\" ? (\n <DistributionSegmentLegend segments={segments} total={total} />\n ) : null}\n </fieldset>\n );\n};\n","import type { SwatchColorStop } from \"./swatch-types\";\n\nexport interface SwatchAtmosphereOptions {\n /** 0 = diffuse, wide wash · 1 = dense, tight pools. Default 0.5. */\n density?: number;\n /** -1 = grounds (pools sink) · 1 = lifts (pools rise). Default 0. */\n gravity?: number;\n}\n\n/**\n * Per-pool layout for the atmosphere fill:\n * `[focal x%, focal y%, base alpha (0-255), radius delta %, gravity sign]`.\n *\n * The first three entries reproduce the original three-pool blend identity\n * gradient exactly; further entries extend the pattern for palettes with\n * more than three colors.\n */\nconst POOLS: readonly (readonly [number, number, number, number, number])[] = [\n [30, 42, 0xcc, 0, -1],\n [72, 58, 0x99, -5, 1],\n [45, 65, 0x77, 8, -1],\n [62, 32, 0x66, 3, 1],\n [24, 72, 0x55, -3, -1],\n [80, 40, 0x44, 6, 1],\n];\n\n/**\n * Build a soft, layered radial \"atmosphere\" background from color stops — a\n * stack of overlapping elliptical pools rather than a flat or linear fill.\n * Density controls how far each pool reaches; gravity shifts the pools\n * vertically. Returns `undefined` when there are no colors.\n */\n\nconst clamp = (value: number, min: number, max: number): number =>\n Math.min(max, Math.max(min, value));\n\nconst normalizeHex = (color: string): string | null => {\n const value = color.trim().replace(/^#/u, \"\");\n if (/^[\\da-f]{3}$/iu.test(value)) {\n return [...value].map((part) => part + part).join(\"\");\n }\n if (/^[\\da-f]{6}$/iu.test(value)) {\n return value;\n }\n return null;\n};\n\nconst withAlpha = (color: string, alpha: number): string => {\n const hex = normalizeHex(color);\n if (hex) {\n const suffix = Math.round(clamp(alpha, 0, 255))\n .toString(16)\n .padStart(2, \"0\");\n return `#${hex}${suffix}`;\n }\n const percent = Math.round((clamp(alpha, 0, 255) / 255) * 100);\n return `color-mix(in srgb, ${color} ${percent}%, transparent)`;\n};\n\nexport const getSwatchAtmosphereBackground = (\n colors: SwatchColorStop[] | undefined,\n options: SwatchAtmosphereOptions = {},\n): string | undefined => {\n if (!colors || colors.length === 0) {\n return undefined;\n }\n\n const density = clamp(options.density ?? 0.5, 0, 1);\n const gravity = clamp(options.gravity ?? 0, -1, 1);\n const gy = Math.round(gravity * 8);\n const reach = Math.round(50 + (1 - density) * 15);\n\n const layers = colors.map((stop, index) => {\n const color = typeof stop === \"string\" ? stop : stop.color;\n const pool = POOLS[index % POOLS.length] as (typeof POOLS)[number];\n const [x, y, baseAlpha, radiusDelta, gravitySign] = pool;\n // Each wrap past the palette length fades the extra pools further back.\n const cycle = Math.floor(index / POOLS.length);\n const alpha = Math.max(0x22, baseAlpha - cycle * 0x22);\n const focalY = clamp(y + gravitySign * gy, 0, 100);\n const radius = Math.max(8, reach + radiusDelta);\n return `radial-gradient(ellipse at ${x}% ${focalY}%, ${withAlpha(\n color,\n alpha,\n )} 0%, transparent ${radius}%)`;\n });\n\n return layers.join(\", \");\n};\n","import type { SwatchColorStop } from \"./swatch-types\";\n\nconst normalizeHex = (hex: string): string | null => {\n const value = hex.trim().replace(/^#/u, \"\");\n if (/^[\\da-f]{3}$/iu.test(value)) {\n return [...value].map((part) => part + part).join(\"\");\n }\n if (/^[\\da-f]{6}$/iu.test(value)) {\n return value;\n }\n return null;\n};\n\nconst toColorStop = (stop: SwatchColorStop): { color: string; ratio?: number } =>\n typeof stop === \"string\" ? { color: stop } : stop;\n\nconst getRatioWeight = (ratio: number | undefined): number => {\n if (ratio === undefined) {\n return 1;\n }\n\n return Number.isFinite(ratio) ? Math.max(0, ratio) : 0;\n};\n\nconst formatPercent = (value: number): string =>\n `${Number.isInteger(value) ? value : Number(value.toFixed(2))}%`;\n\nexport const isLightColor = (color: string): boolean => {\n const normalized = normalizeHex(color);\n if (!normalized) {\n return false;\n }\n\n const red = Number.parseInt(normalized.slice(0, 2), 16);\n const green = Number.parseInt(normalized.slice(2, 4), 16);\n const blue = Number.parseInt(normalized.slice(4, 6), 16);\n const luminance = (0.299 * red + 0.587 * green + 0.114 * blue) / 255;\n return luminance > 0.62;\n};\n\nexport const getSwatchColorsBackground = (\n colors: SwatchColorStop[] | undefined,\n): string | undefined => {\n if (!colors || colors.length === 0) {\n return undefined;\n }\n\n if (colors.length === 1) {\n return toColorStop(colors[0] as SwatchColorStop).color;\n }\n\n const stops = colors.map(toColorStop);\n const weights = stops.map((stop) => getRatioWeight(stop.ratio));\n const rawTotal = weights.reduce((sum, ratio) => sum + ratio, 0);\n const useEqualWeights = rawTotal <= 0;\n const total = useEqualWeights ? stops.length : rawTotal;\n let cursor = 0;\n const parts = stops.map((stop, index) => {\n const ratio = useEqualWeights ? 1 : (weights[index] ?? 0);\n const start = cursor;\n const end = index === stops.length - 1 ? 100 : cursor + (ratio / total) * 100;\n cursor = end;\n return `${stop.color} ${formatPercent(start)} ${formatPercent(end)}`;\n });\n\n return `linear-gradient(90deg, ${parts.join(\", \")})`;\n};\n","import { PATTERNMODE_SIZE_VALUES, PATTERNMODE_SIZES } from \"@patternmode/system\";\nimport type { ObjectFit } from \"@patternmode/system\";\nimport type { ComponentType, HTMLAttributes, ReactNode, SVGProps } from \"react\";\n\nexport const SWATCH_SIZES = [...PATTERNMODE_SIZES, \"4xl\", \"5xl\", \"6xl\", \"7xl\"] as const;\n\nexport const SWATCH_SIZE_VALUES = {\n ...PATTERNMODE_SIZE_VALUES,\n \"4xl\": \"4.5rem\",\n \"5xl\": \"5rem\",\n \"6xl\": \"5.5rem\",\n \"7xl\": \"6rem\",\n} as const satisfies Record<SwatchSize, string>;\n\nexport const SWATCH_SHAPES = [\"circle\", \"pill\", \"square\", \"block\"] as const;\n\nexport const SWATCH_TEXTURES = [\"atmosphere\"] as const;\n\nexport type SwatchSize = (typeof SWATCH_SIZES)[number];\nexport type SwatchShape = (typeof SWATCH_SHAPES)[number];\nexport type SwatchTexture = (typeof SWATCH_TEXTURES)[number];\nexport type SwatchColorStop = string | { color: string; ratio?: number };\ntype SwatchIcon = ComponentType<SVGProps<SVGSVGElement>>;\n\nexport const getSwatchSizeVariableStyle = (\n size: SwatchSize,\n variableName = \"--patternmode-swatch-size\",\n): Record<string, string> => ({\n [variableName]: SWATCH_SIZE_VALUES[size],\n});\n\nexport interface SwatchProps extends HTMLAttributes<HTMLElement> {\n background?: string;\n /**\n * Optional media rendered inside the swatch frame.\n *\n * Swatch does not optimize image elements itself. Next.js consumers can pass\n * their own `next/image` `Image` component here and use `objectFit` /\n * `objectPosition` to align it with the swatch shape.\n */\n children?: ReactNode;\n color?: string;\n colors?: SwatchColorStop[];\n /**\n * Atmosphere density (0 = diffuse wash, 1 = dense pools). Only applies when\n * `texture=\"atmosphere\"`.\n *\n * Default `0.5`.\n */\n density?: number;\n /**\n * Render a precise, flat color block: no top-to-bottom scrim gradient and\n * no drop shadow. Use for data visualisation where the fill must read as\n * the exact color value.\n *\n * Default `false`.\n */\n flat?: boolean;\n /**\n * Atmosphere gravity (-1 = pools sink, 1 = pools rise). Only applies when\n * `texture=\"atmosphere\"`.\n *\n * Default `0`.\n */\n gravity?: number;\n icon?: SwatchIcon;\n isLight?: boolean;\n /**\n * Object-fit mode applied to media children through CSS variables.\n *\n * Default `\"cover\"`.\n */\n objectFit?: ObjectFit;\n /**\n * Object-position value applied to media children through CSS variables.\n *\n * Default `\"center\"`.\n */\n objectPosition?: string;\n onRemove?: () => void;\n raised?: boolean;\n removeLabel?: string;\n /**\n * Shows selected state and optional icon overlay.\n *\n * Default `false`.\n */\n selected?: boolean;\n /**\n * Rendered swatch shape.\n *\n * Default `\"circle\"`.\n */\n shape?: SwatchShape;\n /**\n * Whether selected swatches render their ring treatment.\n *\n * Default `true`.\n */\n showRing?: boolean;\n /**\n * Size token used for the swatch dimensions.\n *\n * Default `\"base\"`.\n */\n size?: SwatchSize;\n /**\n * Render supplied colors as a soft, layered radial atmosphere — overlapping\n * color pools — instead of a ratio-encoded weighted palette. Pair with\n * `density` and `gravity` to shape the pools.\n */\n texture?: SwatchTexture;\n /**\n * Marks the swatch as unavailable.\n *\n * Default `false`.\n */\n unavailable?: boolean;\n}\n","import { getObjectSizingStyle, joinClassNames } from \"@patternmode/system\";\nimport type { CSSProperties, MouseEvent } from \"react\";\n\nimport { getSwatchAtmosphereBackground } from \"./swatch-atmosphere\";\nimport { getSwatchColorsBackground, isLightColor } from \"./swatch-colors\";\nimport { getSwatchSizeVariableStyle } from \"./swatch-types\";\nimport type { SwatchProps } from \"./swatch-types\";\n\ninterface SwatchContentProps {\n children: SwatchProps[\"children\"];\n flat: boolean;\n Icon: SwatchProps[\"icon\"];\n mediaStyle: CSSProperties;\n selected: boolean;\n unavailable: boolean;\n}\n\nconst SwatchContent = ({\n children,\n flat,\n Icon,\n mediaStyle,\n selected,\n unavailable,\n}: SwatchContentProps) => (\n <>\n <span aria-hidden=\"true\" className=\"patternmode-swatch__fill\" />\n {children ? (\n <span className=\"patternmode-swatch__media\" style={mediaStyle}>\n {children}\n </span>\n ) : null}\n {flat ? null : <span aria-hidden=\"true\" className=\"patternmode-swatch__scrim\" />}\n {selected && Icon ? (\n <span className=\"patternmode-swatch__icon\">\n <Icon aria-hidden=\"true\" focusable=\"false\" />\n </span>\n ) : null}\n {unavailable ? <span aria-hidden=\"true\" className=\"patternmode-swatch__slash\" /> : null}\n </>\n);\n\nconst getSwatchFill = ({\n background,\n color,\n colors,\n density,\n gravity,\n texture,\n}: Pick<SwatchProps, \"background\" | \"color\" | \"colors\" | \"density\" | \"gravity\" | \"texture\">) => {\n const colorsBackground = getSwatchColorsBackground(colors);\n const atmosphereBackground =\n texture === \"atmosphere\"\n ? getSwatchAtmosphereBackground(colors, { density, gravity })\n : undefined;\n\n return {\n colorsBackground,\n fill: background ?? atmosphereBackground ?? colorsBackground ?? color,\n };\n};\n\nconst getSwatchTone = ({\n background,\n color,\n colorsBackground,\n isLight,\n}: {\n background: SwatchProps[\"background\"];\n color: SwatchProps[\"color\"];\n colorsBackground: string | undefined;\n isLight: SwatchProps[\"isLight\"];\n}) => {\n if (isLight !== undefined) {\n return isLight ? \"light\" : \"dark\";\n }\n\n if (color && !background && !colorsBackground && isLightColor(color as string)) {\n return \"light\";\n }\n\n return \"dark\";\n};\n\nconst getSwatchDataProps = ({\n flat,\n lightTone,\n raised,\n selected,\n shape,\n showRing,\n size,\n unavailable,\n}: {\n flat: boolean;\n lightTone: \"dark\" | \"light\";\n raised: boolean;\n selected: boolean;\n shape: SwatchProps[\"shape\"];\n showRing: boolean;\n size: SwatchProps[\"size\"];\n unavailable: boolean;\n}) => ({\n \"data-flat\": flat ? \"true\" : undefined,\n \"data-raised\": raised ? \"true\" : undefined,\n \"data-selected\": selected ? \"true\" : undefined,\n \"data-shape\": shape,\n \"data-show-ring\": showRing ? \"true\" : \"false\",\n \"data-size\": size,\n \"data-slot\": \"swatch\",\n \"data-tone\": lightTone,\n \"data-unavailable\": unavailable ? \"true\" : undefined,\n});\n\nexport const Swatch = ({\n \"aria-label\": ariaLabel,\n background,\n children,\n className,\n color,\n colors,\n density,\n flat = false,\n gravity,\n icon: Icon,\n isLight,\n objectFit,\n objectPosition,\n onRemove,\n raised = false,\n removeLabel,\n role: _role,\n selected = false,\n shape = \"circle\",\n showRing = true,\n size = \"base\",\n style,\n texture,\n unavailable = false,\n ...props\n}: SwatchProps) => {\n const { colorsBackground, fill } = getSwatchFill({\n background,\n color,\n colors,\n density,\n gravity,\n texture,\n });\n const lightTone = getSwatchTone({\n background,\n color,\n colorsBackground,\n isLight,\n });\n const resolvedRemoveLabel = removeLabel ?? (ariaLabel ? `Remove ${ariaLabel}` : \"Remove\");\n\n const rootStyle = {\n ...getSwatchSizeVariableStyle(size),\n \"--patternmode-swatch-fill\": fill,\n ...style,\n } as CSSProperties;\n const mediaStyle = getObjectSizingStyle({\n fit: objectFit,\n position: objectPosition,\n }) as CSSProperties;\n const dataProps = getSwatchDataProps({\n flat,\n lightTone,\n raised,\n selected,\n shape,\n showRing,\n size,\n unavailable,\n });\n\n const handleRemove = (event: MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation();\n onRemove?.();\n };\n\n const swatchContent = (\n <SwatchContent\n flat={flat}\n Icon={Icon}\n mediaStyle={mediaStyle}\n selected={selected}\n unavailable={unavailable}\n >\n {children}\n </SwatchContent>\n );\n\n if (onRemove) {\n return (\n <fieldset\n {...props}\n {...dataProps}\n aria-label={ariaLabel}\n className={joinClassNames(\"patternmode-swatch\", className)}\n style={rootStyle}\n >\n {swatchContent}\n <button\n aria-label={resolvedRemoveLabel}\n className=\"patternmode-swatch__remove\"\n onClick={handleRemove}\n type=\"button\"\n >\n <svg aria-hidden=\"true\" fill=\"none\" viewBox=\"0 0 20 20\">\n <path d=\"M5.5 5.5l9 9M14.5 5.5l-9 9\" />\n </svg>\n </button>\n </fieldset>\n );\n }\n\n return (\n <figure\n {...props}\n {...dataProps}\n aria-label={ariaLabel}\n className={joinClassNames(\"patternmode-swatch\", className)}\n style={rootStyle}\n >\n {swatchContent}\n </figure>\n );\n};\n"],"mappings":";;;;;AAcA,MAAM,iBAAiB,UAA2B,OAAO,SAAS,KAAK,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI;AAEhG,MAAMA,WAAS,OAAe,KAAa,QACzC,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAEpC,MAAM,cAAc,UAA0B,OAAO,MAAM,QAAQ,CAAC,CAAC;;AAGrE,MAAa,wBAAwB,aACnC,SAAS,QAAQ,KAAK,YAAY,MAAM,cAAc,QAAQ,KAAK,GAAG,CAAC;;AAGzE,MAAa,kCACX,UACA,kBACW;CACX,MAAM,QAAQ,qBAAqB,QAAQ;CAC3C,IAAI,SAAS,GACX,OAAO;CAMT,OAAO,WAHe,SACnB,MAAM,GAAG,gBAAgB,CAAC,EAC1B,QAAQ,KAAK,YAAY,MAAM,cAAc,QAAQ,KAAK,GAAG,CACjC,IAAI,QAAS,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AC,UAAD;EACE,GAAI;EACJ,GAAI;EACJ,cAAY;EACZ,WAAW,eAAe,sBAAsB,SAAS;EACzD,OAAO;YAEN;CACK,CAAA;AAEZ"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["clamp","normalizeHex"],"sources":["../src/DistributionBar/distribution-bar-math.ts","../src/DistributionBar/distribution-bar-root.tsx","../src/Swatch/swatch-atmosphere.ts","../src/Swatch/swatch-colors.ts","../src/Swatch/swatch-types.ts","../src/Swatch/swatch-root.tsx"],"sourcesContent":["/** Weighted segment used by DistributionBar and DistributionDisplay. */\nexport interface DistributionBarSegment {\n color: string;\n id: string;\n label?: string;\n /** Relative weight, not a persisted percentage. Invalid or negative values render as 0. */\n value: number;\n}\n\n/** Segment metadata update; weight changes happen through boundary movement. */\nexport type DistributionBarSegmentUpdate = Partial<Omit<DistributionBarSegment, \"value\">> & {\n value?: never;\n};\n\nconst sanitizeValue = (value: number): number => (Number.isFinite(value) ? Math.max(0, value) : 0);\n\nconst clamp = (value: number, min: number, max: number): number =>\n Math.min(Math.max(value, min), max);\n\nconst roundValue = (value: number): number => Number(value.toFixed(1));\n\n/** Sums sanitized segment weights, treating invalid or negative values as 0. */\nexport const getDistributionTotal = (segments: DistributionBarSegment[]): number =>\n segments.reduce((sum, segment) => sum + sanitizeValue(segment.value), 0);\n\n/** Returns the percentage position of the boundary after `boundaryIndex`. */\nexport const getDistributionBoundaryPercent = (\n segments: DistributionBarSegment[],\n boundaryIndex: number,\n): number => {\n const total = getDistributionTotal(segments);\n if (total <= 0) {\n return 0;\n }\n\n const boundaryValue = segments\n .slice(0, boundaryIndex + 1)\n .reduce((sum, segment) => sum + sanitizeValue(segment.value), 0);\n return roundValue((boundaryValue / total) * 100);\n};\n\n/**\n * Moves the boundary between two adjacent segments while preserving their sum.\n *\n * `deltaValue` is applied to the left segment and subtracted from the right\n * segment. `minValue` prevents either side of the pair from collapsing below a\n * caller-defined minimum.\n */\nexport const moveDistributionBoundary = (\n segments: DistributionBarSegment[],\n boundaryIndex: number,\n deltaValue: number,\n minValue: number,\n): DistributionBarSegment[] => {\n const left = segments[boundaryIndex];\n const right = segments[boundaryIndex + 1];\n if (!(left && right)) {\n return segments;\n }\n\n const pairTotal = sanitizeValue(left.value) + sanitizeValue(right.value);\n const clampedMin = Math.max(0, Math.min(minValue, pairTotal / 2));\n const nextLeft = clamp(\n sanitizeValue(left.value) + deltaValue,\n clampedMin,\n pairTotal - clampedMin,\n );\n const nextRight = pairTotal - nextLeft;\n\n return segments.map((segment, index) => {\n if (index === boundaryIndex) {\n return { ...segment, value: roundValue(nextLeft) };\n }\n if (index === boundaryIndex + 1) {\n return { ...segment, value: roundValue(nextRight) };\n }\n return segment;\n });\n};\n\n/** Removes a segment and redistributes its weight proportionally to the rest. */\nexport const removeDistributionSegment = (\n segments: DistributionBarSegment[],\n segmentId: string,\n): DistributionBarSegment[] => {\n if (segments.length <= 1) {\n return segments;\n }\n\n const removed = segments.find((segment) => segment.id === segmentId);\n if (!removed) {\n return segments;\n }\n\n const remaining = segments.filter((segment) => segment.id !== segmentId);\n const removedValue = sanitizeValue(removed.value);\n const remainingTotal = getDistributionTotal(remaining);\n if (remainingTotal <= 0) {\n const equalValue = removedValue / remaining.length;\n return remaining.map((segment) => ({\n ...segment,\n value: roundValue(equalValue),\n }));\n }\n\n let assignedValue = 0;\n const originalTotal = getDistributionTotal(segments);\n return remaining.map((segment, index) => {\n if (index === remaining.length - 1) {\n return { ...segment, value: roundValue(originalTotal - assignedValue) };\n }\n\n const nextValue = roundValue(\n sanitizeValue(segment.value) + (removedValue * sanitizeValue(segment.value)) / remainingTotal,\n );\n assignedValue += nextValue;\n return { ...segment, value: nextValue };\n });\n};\n\n/** Updates non-weight segment metadata such as label or color. */\nexport const updateDistributionSegment = (\n segments: DistributionBarSegment[],\n segmentId: string,\n update: DistributionBarSegmentUpdate,\n): DistributionBarSegment[] =>\n segments.map((segment) => (segment.id === segmentId ? { ...segment, ...update } : segment));\n","import { joinClassNames } from \"@patternmode/system\";\nimport { domMax, LazyMotion, m } from \"motion/react\";\nimport type { PanInfo } from \"motion/react\";\nimport type { CSSProperties, HTMLAttributes, KeyboardEvent } from \"react\";\nimport { useRef } from \"react\";\nimport {\n getDistributionBoundaryPercent,\n getDistributionTotal,\n moveDistributionBoundary,\n} from \"./distribution-bar-math\";\nimport type { DistributionBarSegment } from \"./distribution-bar-math\";\n\nexport interface DistributionDisplayProps extends Omit<\n HTMLAttributes<HTMLElement>,\n \"role\" | \"onSelect\"\n> {\n /** Label used in summary legends for assigned segment weight. */\n assignedLabel?: string;\n /** Label used when `emptyValue` contributes unassigned weight. */\n emptyLabel?: string;\n /**\n * Extra unassigned weight included in derived percentage calculations.\n *\n * Default `0`.\n */\n emptyValue?: number;\n /**\n * Legend style for the read-only display.\n *\n * Default `\"segments\"`.\n */\n legend?: \"segments\" | \"summary\" | false;\n /**\n * When provided, each segment renders as a button and selecting one\n * invokes this callback. Pair with `selectedSegmentId` to mark a segment\n * as selected (renders a ring). Read-only by default.\n */\n onSegmentSelect?: (segment: DistributionBarSegment) => void;\n segments: DistributionBarSegment[];\n /** Id of the selected segment — renders a ring on that segment. */\n selectedSegmentId?: string;\n}\n\nexport interface DistributionBarProps extends Omit<\n HTMLAttributes<HTMLFieldSetElement>,\n \"onChange\"\n> {\n /**\n * Show the per-segment legend below the bar, or hide it.\n *\n * Default `\"segments\"`.\n */\n legend?: \"segments\" | false;\n /**\n * Minimum weight each side of a dragged boundary must retain.\n *\n * Default `4`.\n */\n minValue?: number;\n /** Receives the full next segment list after drag or keyboard boundary moves. */\n onChange?: (segments: DistributionBarSegment[]) => void;\n /** Weighted segments; displayed percentages are derived from their total. */\n segments: DistributionBarSegment[];\n /**\n * Keyboard adjustment amount for boundary handles.\n *\n * Default `1`.\n */\n step?: number;\n}\n\ninterface DistributionSegmentsProps {\n emptyValue?: number;\n onSegmentSelect?: (segment: DistributionBarSegment) => void;\n segments: DistributionBarSegment[];\n selectedSegmentId?: string;\n total: number;\n}\n\ninterface DistributionSegmentLegendProps {\n emptyLabel?: string;\n emptyValue?: number;\n segments: DistributionBarSegment[];\n total: number;\n}\n\ninterface DistributionSummaryLegendProps {\n assignedLabel: string;\n emptyLabel: string;\n emptyValue: number;\n total: number;\n}\n\ninterface DistributionBarHandleProps {\n \"aria-label\": string;\n boundaryPercent: number;\n onDrag: (info: PanInfo) => void;\n onDragEnd: (info: PanInfo) => void;\n onDragStart: () => void;\n onKeyDown: (event: KeyboardEvent<HTMLButtonElement>) => void;\n}\n\ntype DistributionSegmentStyle = CSSProperties &\n Partial<Record<`--${string}`, number | string | undefined>>;\n\nconst getRenderableDistributionValue = (value: number): number =>\n Number.isFinite(value) ? Math.max(0, value) : 0;\n\nconst getDerivedDistributionPercentage = (value: number, total: number): number => {\n if (!(total > 0 && Number.isFinite(value))) {\n return 0;\n }\n\n return Math.round((Math.max(0, value) / total) * 100);\n};\n\nconst getDistributionDisplayTotal = (\n segments: DistributionBarSegment[],\n emptyValue: number,\n): number => getDistributionTotal(segments) + getRenderableDistributionValue(emptyValue);\n\nconst getDistributionDisplayAccessibleLabel = (\n segments: DistributionBarSegment[],\n emptyValue: number,\n emptyLabel: string,\n total: number,\n): string => {\n const segmentLabels = segments.map(\n (segment) =>\n `${segment.label ?? segment.id} ${getDerivedDistributionPercentage(segment.value, total)}%`,\n );\n if (emptyValue > 0) {\n segmentLabels.push(`${emptyLabel} ${getDerivedDistributionPercentage(emptyValue, total)}%`);\n }\n\n return segmentLabels.join(\", \");\n};\n\nconst DistributionSegments = ({\n emptyValue = 0,\n onSegmentSelect,\n segments,\n selectedSegmentId,\n total,\n}: DistributionSegmentsProps) => (\n <div className=\"patternmode-distribution-bar__segments\">\n {segments.map((segment) => {\n const segmentStyle = {\n \"--patternmode-distribution-segment-color\": segment.color,\n width:\n total > 0 ? `${(getRenderableDistributionValue(segment.value) / total) * 100}%` : \"0%\",\n } satisfies DistributionSegmentStyle;\n const isSelected = selectedSegmentId === segment.id;\n\n if (onSegmentSelect) {\n return (\n <button\n aria-label={`${segment.label ?? segment.id} ${getDerivedDistributionPercentage(segment.value, total)}%`}\n aria-pressed={isSelected}\n className=\"patternmode-distribution-bar__segment\"\n data-selected={isSelected ? \"true\" : undefined}\n key={segment.id}\n onClick={() => {\n onSegmentSelect(segment);\n }}\n style={segmentStyle}\n type=\"button\"\n />\n );\n }\n\n return (\n <div\n aria-hidden=\"true\"\n className=\"patternmode-distribution-bar__segment\"\n data-selected={isSelected ? \"true\" : undefined}\n key={segment.id}\n style={segmentStyle}\n />\n );\n })}\n {emptyValue > 0 ? (\n <div\n aria-hidden=\"true\"\n className=\"patternmode-distribution-bar__segment patternmode-distribution-bar__segment--empty\"\n style={{\n width:\n total > 0 ? `${(getRenderableDistributionValue(emptyValue) / total) * 100}%` : \"0%\",\n }}\n />\n ) : null}\n </div>\n);\n\nconst DistributionSegmentLegend = ({\n emptyLabel,\n emptyValue = 0,\n segments,\n total,\n}: DistributionSegmentLegendProps) => (\n <div className=\"patternmode-distribution-bar__legend\">\n {segments.map((segment) => {\n const segmentStyle = {\n \"--patternmode-distribution-segment-color\": segment.color,\n backgroundColor: undefined,\n } satisfies DistributionSegmentStyle;\n\n return (\n <span key={segment.id}>\n <span\n aria-hidden=\"true\"\n className=\"patternmode-distribution-bar__swatch\"\n style={segmentStyle}\n />\n {segment.label ?? segment.id} {getDerivedDistributionPercentage(segment.value, total)}%\n </span>\n );\n })}\n {emptyValue > 0 && emptyLabel !== undefined && emptyLabel !== \"\" ? (\n <span>\n <span\n aria-hidden=\"true\"\n className=\"patternmode-distribution-bar__swatch patternmode-distribution-bar__swatch--empty\"\n />\n {emptyLabel} {getDerivedDistributionPercentage(emptyValue, total)}%\n </span>\n ) : null}\n </div>\n);\n\nconst DistributionSummaryLegend = ({\n assignedLabel,\n emptyLabel,\n emptyValue,\n total,\n}: DistributionSummaryLegendProps) => {\n const emptyPercentage = getDerivedDistributionPercentage(emptyValue, total);\n\n return (\n <div className=\"patternmode-distribution-bar__legend\">\n <span>\n {Math.max(0, 100 - emptyPercentage)}% {assignedLabel}\n </span>\n {emptyValue > 0 ? (\n <span>\n {emptyPercentage}% {emptyLabel}\n </span>\n ) : null}\n </div>\n );\n};\n\nconst DistributionBarHandle = ({\n \"aria-label\": ariaLabel,\n boundaryPercent,\n onDrag,\n onDragEnd,\n onDragStart,\n onKeyDown,\n}: DistributionBarHandleProps) => (\n <LazyMotion features={domMax}>\n <m.button\n aria-label={ariaLabel}\n className=\"patternmode-distribution-bar__handle\"\n drag=\"x\"\n dragElastic={0}\n dragMomentum={false}\n dragSnapToOrigin\n onDrag={(_event, info) => {\n onDrag(info);\n }}\n onDragEnd={(_event, info) => {\n onDragEnd(info);\n }}\n onDragStart={onDragStart}\n onKeyDown={onKeyDown}\n style={{ left: `calc(${boundaryPercent}% - 1.375rem)` }}\n transformTemplate={() => \"none\"}\n type=\"button\"\n />\n </LazyMotion>\n);\n\nexport const DistributionDisplay = ({\n \"aria-label\": ariaLabel,\n assignedLabel = \"assigned\",\n className,\n emptyLabel = \"unassigned\",\n emptyValue = 0,\n legend = \"segments\",\n onSegmentSelect,\n segments,\n selectedSegmentId,\n ...props\n}: DistributionDisplayProps) => {\n const total = getDistributionDisplayTotal(segments, emptyValue);\n const interactive = Boolean(onSegmentSelect);\n const accessibleLabel =\n ariaLabel ?? getDistributionDisplayAccessibleLabel(segments, emptyValue, emptyLabel, total);\n\n const content = (\n <>\n <div className=\"patternmode-distribution-bar__track\">\n <DistributionSegments\n emptyValue={emptyValue}\n onSegmentSelect={onSegmentSelect}\n segments={segments}\n selectedSegmentId={selectedSegmentId}\n total={total}\n />\n </div>\n {legend === \"segments\" ? (\n <DistributionSegmentLegend\n emptyLabel={emptyLabel}\n emptyValue={emptyValue}\n segments={segments}\n total={total}\n />\n ) : null}\n {legend === \"summary\" ? (\n <DistributionSummaryLegend\n assignedLabel={assignedLabel}\n emptyLabel={emptyLabel}\n emptyValue={emptyValue}\n total={total}\n />\n ) : null}\n </>\n );\n const sharedClassName = joinClassNames(\"patternmode-distribution-display\", className);\n\n return interactive ? (\n <fieldset\n {...props}\n aria-label={accessibleLabel}\n className={sharedClassName}\n data-slot=\"distribution-display\"\n >\n {content}\n </fieldset>\n ) : (\n <figure\n {...props}\n aria-label={accessibleLabel}\n className={sharedClassName}\n data-slot=\"distribution-display\"\n >\n {content}\n </figure>\n );\n};\n\nexport const DistributionBar = ({\n \"aria-label\": ariaLabel,\n className,\n legend = \"segments\",\n minValue = 4,\n onChange,\n segments,\n step = 1,\n ...props\n}: DistributionBarProps) => {\n const trackRef = useRef<HTMLDivElement>(null);\n const dragStartSegmentsRef = useRef<DistributionBarSegment[] | null>(null);\n const total = getDistributionTotal(segments);\n\n const moveBoundary = (boundaryIndex: number, deltaValue: number, sourceSegments = segments) => {\n onChange?.(moveDistributionBoundary(sourceSegments, boundaryIndex, deltaValue, minValue));\n };\n\n const handleDragStart = () => {\n dragStartSegmentsRef.current = segments;\n };\n\n const handleDrag = (boundaryIndex: number, info: PanInfo) => {\n const sourceSegments = dragStartSegmentsRef.current ?? segments;\n const sourceTotal = getDistributionTotal(sourceSegments);\n const trackWidth = trackRef.current?.getBoundingClientRect().width ?? 0;\n if (!(trackWidth > 0 && sourceTotal > 0)) {\n return;\n }\n\n moveBoundary(boundaryIndex, (info.offset.x / trackWidth) * sourceTotal, sourceSegments);\n };\n\n const handleDragEnd = (boundaryIndex: number, info: PanInfo) => {\n handleDrag(boundaryIndex, info);\n dragStartSegmentsRef.current = null;\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLButtonElement>, boundaryIndex: number) => {\n if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n moveBoundary(boundaryIndex, -step);\n }\n if (event.key === \"ArrowRight\") {\n event.preventDefault();\n moveBoundary(boundaryIndex, step);\n }\n };\n\n return (\n <fieldset\n {...props}\n aria-label={ariaLabel}\n className={joinClassNames(\"patternmode-distribution-bar\", className)}\n data-slot=\"distribution-bar\"\n >\n <div className=\"patternmode-distribution-bar__track\" ref={trackRef}>\n <DistributionSegments segments={segments} total={total} />\n {segments.slice(0, -1).map((segment, boundaryIndex) => {\n const nextSegment = segments[boundaryIndex + 1];\n const boundaryPercent = getDistributionBoundaryPercent(segments, boundaryIndex);\n const label = `Adjust ${segment.label ?? segment.id} and ${\n nextSegment?.label ?? nextSegment?.id\n } distribution`;\n return (\n <DistributionBarHandle\n aria-label={label}\n boundaryPercent={boundaryPercent}\n key={`${segment.id}-${nextSegment?.id ?? \"end\"}`}\n onDrag={(info) => {\n handleDrag(boundaryIndex, info);\n }}\n onDragEnd={(info) => {\n handleDragEnd(boundaryIndex, info);\n }}\n onDragStart={handleDragStart}\n onKeyDown={(event) => {\n handleKeyDown(event, boundaryIndex);\n }}\n />\n );\n })}\n </div>\n {legend === \"segments\" ? (\n <DistributionSegmentLegend segments={segments} total={total} />\n ) : null}\n </fieldset>\n );\n};\n","import type { SwatchColorStop } from \"./swatch-types\";\n\nexport interface SwatchAtmosphereOptions {\n /** 0 = diffuse, wide wash · 1 = dense, tight pools. Default 0.5. */\n density?: number;\n /** -1 = grounds (pools sink) · 1 = lifts (pools rise). Default 0. */\n gravity?: number;\n}\n\n/**\n * Per-pool layout for the atmosphere fill:\n * `[focal x%, focal y%, base alpha (0-255), radius delta %, gravity sign]`.\n *\n * The first three entries reproduce the original three-pool blend identity\n * gradient exactly; further entries extend the pattern for palettes with\n * more than three colors.\n */\nconst POOLS: readonly (readonly [number, number, number, number, number])[] = [\n [30, 42, 0xcc, 0, -1],\n [72, 58, 0x99, -5, 1],\n [45, 65, 0x77, 8, -1],\n [62, 32, 0x66, 3, 1],\n [24, 72, 0x55, -3, -1],\n [80, 40, 0x44, 6, 1],\n];\n\n/**\n * Build a soft, layered radial \"atmosphere\" background from color stops — a\n * stack of overlapping elliptical pools rather than a flat or linear fill.\n * Density controls how far each pool reaches; gravity shifts the pools\n * vertically. Returns `undefined` when there are no colors.\n */\n\nconst clamp = (value: number, min: number, max: number): number =>\n Math.min(max, Math.max(min, value));\n\nconst normalizeHex = (color: string): string | null => {\n const value = color.trim().replace(/^#/u, \"\");\n if (/^[\\da-f]{3}$/iu.test(value)) {\n return `${value[0]}${value[0]}${value[1]}${value[1]}${value[2]}${value[2]}`;\n }\n if (/^[\\da-f]{6}$/iu.test(value)) {\n return value;\n }\n return null;\n};\n\nconst withAlpha = (color: string, alpha: number): string => {\n const hex = normalizeHex(color);\n if (hex !== null) {\n const suffix = Math.round(clamp(alpha, 0, 255))\n .toString(16)\n .padStart(2, \"0\");\n return `#${hex}${suffix}`;\n }\n const percent = Math.round((clamp(alpha, 0, 255) / 255) * 100);\n return `color-mix(in srgb, ${color} ${percent}%, transparent)`;\n};\n\nexport const getSwatchAtmosphereBackground = (\n colors: SwatchColorStop[] | undefined,\n options: SwatchAtmosphereOptions = {},\n): string | undefined => {\n if (colors === undefined || colors.length === 0) {\n return undefined;\n }\n\n const density = clamp(options.density ?? 0.5, 0, 1);\n const gravity = clamp(options.gravity ?? 0, -1, 1);\n const gy = Math.round(gravity * 8);\n const reach = Math.round(50 + (1 - density) * 15);\n\n const layers = colors.map((stop, index) => {\n const color = typeof stop === \"string\" ? stop : stop.color;\n const pool = POOLS[index % POOLS.length];\n if (pool === undefined) {\n throw new Error(\"Expected atmosphere pool to exist.\");\n }\n const [x, y, baseAlpha, radiusDelta, gravitySign] = pool;\n // Each wrap past the palette length fades the extra pools further back.\n const cycle = Math.floor(index / POOLS.length);\n const alpha = Math.max(0x22, baseAlpha - cycle * 0x22);\n const focalY = clamp(y + gravitySign * gy, 0, 100);\n const radius = Math.max(8, reach + radiusDelta);\n return `radial-gradient(ellipse at ${x}% ${focalY}%, ${withAlpha(\n color,\n alpha,\n )} 0%, transparent ${radius}%)`;\n });\n\n return layers.join(\", \");\n};\n","import type { SwatchColorStop } from \"./swatch-types\";\n\nconst normalizeHex = (hex: string): string | null => {\n const value = hex.trim().replace(/^#/u, \"\");\n if (/^[\\da-f]{3}$/iu.test(value)) {\n return `${value[0]}${value[0]}${value[1]}${value[1]}${value[2]}${value[2]}`;\n }\n if (/^[\\da-f]{6}$/iu.test(value)) {\n return value;\n }\n return null;\n};\n\nconst toColorStop = (stop: SwatchColorStop): { color: string; ratio?: number } =>\n typeof stop === \"string\" ? { color: stop } : stop;\n\nconst getRatioWeight = (ratio: number | undefined): number => {\n if (ratio === undefined) {\n return 1;\n }\n\n return Number.isFinite(ratio) ? Math.max(0, ratio) : 0;\n};\n\nconst formatPercent = (value: number): string =>\n `${Number.isInteger(value) ? value : Number(value.toFixed(2))}%`;\n\nexport const isLightColor = (color: string): boolean => {\n const normalized = normalizeHex(color);\n if (normalized === null) {\n return false;\n }\n\n const red = Number.parseInt(normalized.slice(0, 2), 16);\n const green = Number.parseInt(normalized.slice(2, 4), 16);\n const blue = Number.parseInt(normalized.slice(4, 6), 16);\n const luminance = (0.299 * red + 0.587 * green + 0.114 * blue) / 255;\n return luminance > 0.62;\n};\n\nexport const getSwatchColorsBackground = (\n colors: SwatchColorStop[] | undefined,\n): string | undefined => {\n if (colors === undefined || colors.length === 0) {\n return undefined;\n }\n\n const [singleColor] = colors;\n if (colors.length === 1 && singleColor !== undefined) {\n return toColorStop(singleColor).color;\n }\n\n const stops = colors.map(toColorStop);\n const weights = stops.map((stop) => getRatioWeight(stop.ratio));\n const rawTotal = weights.reduce((sum, ratio) => sum + ratio, 0);\n const useEqualWeights = rawTotal <= 0;\n const total = useEqualWeights ? stops.length : rawTotal;\n let cursor = 0;\n const parts = stops.map((stop, index) => {\n const ratio = useEqualWeights ? 1 : (weights[index] ?? 0);\n const start = cursor;\n const end = index === stops.length - 1 ? 100 : cursor + (ratio / total) * 100;\n cursor = end;\n return `${stop.color} ${formatPercent(start)} ${formatPercent(end)}`;\n });\n\n return `linear-gradient(90deg, ${parts.join(\", \")})`;\n};\n","import { PATTERNMODE_SIZE_VALUES, PATTERNMODE_SIZES } from \"@patternmode/system\";\nimport type { ObjectFit } from \"@patternmode/system\";\nimport type { ComponentType, HTMLAttributes, ReactElement, ReactNode, SVGProps } from \"react\";\n\nexport const SWATCH_SIZES = [...PATTERNMODE_SIZES, \"4xl\", \"5xl\", \"6xl\", \"7xl\"] as const;\n\nexport const SWATCH_SIZE_VALUES = {\n ...PATTERNMODE_SIZE_VALUES,\n \"4xl\": \"4.5rem\",\n \"5xl\": \"5rem\",\n \"6xl\": \"5.5rem\",\n \"7xl\": \"6rem\",\n} as const satisfies Record<SwatchSize, string>;\n\nexport const SWATCH_SHAPES = [\"circle\", \"pill\", \"square\", \"block\"] as const;\n\nexport const SWATCH_TEXTURES = [\"atmosphere\"] as const;\n\nexport type SwatchSize = (typeof SWATCH_SIZES)[number];\nexport type SwatchShape = (typeof SWATCH_SHAPES)[number];\nexport type SwatchTexture = (typeof SWATCH_TEXTURES)[number];\nexport type SwatchColorStop = string | { color: string; ratio?: number };\ntype SwatchIcon = ComponentType<SVGProps<SVGSVGElement>>;\n\nexport const getSwatchSizeVariableStyle = (\n size: SwatchSize,\n variableName = \"--patternmode-swatch-size\",\n): Record<string, string> => ({\n [variableName]: SWATCH_SIZE_VALUES[size],\n});\n\n/**\n * Visual and behavioural props shared by every Swatch rendering mode. These\n * map deterministically to the fill, scrim, shape, and size treatment\n * regardless of whether the swatch renders its own wrapper or an `asChild`\n * element.\n */\nexport interface SwatchSharedProps extends HTMLAttributes<HTMLElement> {\n background?: string;\n color?: string;\n colors?: SwatchColorStop[];\n /**\n * Atmosphere density (0 = diffuse wash, 1 = dense pools). Only applies when\n * `texture=\"atmosphere\"`.\n *\n * Default `0.5`.\n */\n density?: number;\n /**\n * Render a precise, flat color block: no top-to-bottom scrim gradient and\n * no drop shadow. Use for data visualisation where the fill must read as\n * the exact color value.\n *\n * Default `false`.\n */\n flat?: boolean;\n /**\n * Atmosphere gravity (-1 = pools sink, 1 = pools rise). Only applies when\n * `texture=\"atmosphere\"`.\n *\n * Default `0`.\n */\n gravity?: number;\n icon?: SwatchIcon;\n isLight?: boolean;\n /**\n * Object-fit mode applied to media children through CSS variables.\n *\n * Default `\"cover\"`.\n */\n objectFit?: ObjectFit;\n /**\n * Object-position value applied to media children through CSS variables.\n *\n * Default `\"center\"`.\n */\n objectPosition?: string;\n raised?: boolean;\n /**\n * Shows selected state and optional icon overlay.\n *\n * Default `false`.\n */\n selected?: boolean;\n /**\n * Rendered swatch shape.\n *\n * Default `\"circle\"`.\n */\n shape?: SwatchShape;\n /**\n * Whether selected swatches render their ring treatment.\n *\n * Default `true`.\n */\n showRing?: boolean;\n /**\n * Size token used for the swatch dimensions.\n *\n * Default `\"base\"`.\n */\n size?: SwatchSize;\n /**\n * Render supplied colors as a soft, layered radial atmosphere — overlapping\n * color pools — instead of a ratio-encoded weighted palette. Pair with\n * `density` and `gravity` to shape the pools.\n */\n texture?: SwatchTexture;\n /**\n * Marks the swatch as unavailable.\n *\n * Default `false`.\n */\n unavailable?: boolean;\n}\n\n/**\n * Default Swatch props: the swatch renders its own wrapper element\n * (`<figure>`, or `<fieldset>` when `onRemove` is set).\n */\nexport interface SwatchDefaultProps extends SwatchSharedProps {\n /**\n * Render the swatch styling onto a provided child element instead of an\n * own wrapper. See {@link SwatchAsChildProps}.\n *\n * Default `false`.\n */\n asChild?: false;\n /**\n * Optional media rendered inside the swatch frame.\n *\n * Swatch does not optimize image elements itself. Next.js consumers can pass\n * their own `next/image` `Image` component here and use `objectFit` /\n * `objectPosition` to align it with the swatch shape.\n */\n children?: ReactNode;\n /** Renders a remove affordance and calls this after stopping propagation. */\n onRemove?: () => void;\n /** Accessible label for the remove affordance. Defaults to the swatch label. */\n removeLabel?: string;\n}\n\n/**\n * `asChild` Swatch props: the swatch merges its className, style (size/fill\n * CSS variables), data attributes, and other props onto the single React\n * element passed as `children`, rendering through it (Radix Slot pattern)\n * instead of emitting its own wrapper. Use this when the swatch must *be* an\n * interactive element, such as a `<button>` cell in a color matrix.\n *\n * `onRemove` is unsupported in this mode — its remove affordance cannot be\n * composed into an arbitrary slotted element. Wrap a default Swatch instead\n * when a remove control is required.\n */\nexport interface SwatchAsChildProps extends SwatchSharedProps {\n asChild: true;\n /** The single element the swatch styling is merged onto and rendered through. */\n children: ReactElement;\n onRemove?: never;\n removeLabel?: never;\n}\n\nexport type SwatchProps = SwatchDefaultProps | SwatchAsChildProps;\n","import { getObjectSizingStyle, joinClassNames } from \"@patternmode/system\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\nimport type { CSSProperties, HTMLAttributes, MouseEvent, ReactNode } from \"react\";\n\nimport { getSwatchAtmosphereBackground } from \"./swatch-atmosphere\";\nimport { getSwatchColorsBackground, isLightColor } from \"./swatch-colors\";\nimport { getSwatchSizeVariableStyle } from \"./swatch-types\";\nimport type { SwatchProps } from \"./swatch-types\";\n\ntype SwatchRootStyle = CSSProperties & Record<\"--patternmode-swatch-fill\", string | undefined>;\n\ninterface SwatchContentProps {\n children: SwatchProps[\"children\"];\n flat: boolean;\n Icon: SwatchProps[\"icon\"];\n mediaStyle: CSSProperties;\n selected: boolean;\n unavailable: boolean;\n}\n\ninterface RemovableSwatchProps {\n ariaLabel: string | undefined;\n children: ReactNode;\n className: string | undefined;\n dataProps: ReturnType<typeof getSwatchDataProps>;\n onRemove: () => void;\n removeLabel: string;\n rootStyle: SwatchRootStyle;\n props: HTMLAttributes<HTMLElement>;\n}\n\nconst SwatchContent = ({\n children,\n flat,\n Icon,\n mediaStyle,\n selected,\n unavailable,\n}: SwatchContentProps) => (\n <>\n <span aria-hidden=\"true\" className=\"patternmode-swatch__fill\" />\n {children !== undefined && children !== null ? (\n <span className=\"patternmode-swatch__media\" style={mediaStyle}>\n {children}\n </span>\n ) : null}\n {flat ? null : <span aria-hidden=\"true\" className=\"patternmode-swatch__scrim\" />}\n {selected && Icon ? (\n <span className=\"patternmode-swatch__icon\">\n <Icon aria-hidden=\"true\" focusable=\"false\" />\n </span>\n ) : null}\n {unavailable ? <span aria-hidden=\"true\" className=\"patternmode-swatch__slash\" /> : null}\n </>\n);\n\nconst getSwatchFill = ({\n background,\n color,\n colors,\n density,\n gravity,\n texture,\n}: Pick<SwatchProps, \"background\" | \"color\" | \"colors\" | \"density\" | \"gravity\" | \"texture\">) => {\n const colorsBackground = getSwatchColorsBackground(colors);\n const atmosphereBackground =\n texture === \"atmosphere\"\n ? getSwatchAtmosphereBackground(colors, { density, gravity })\n : undefined;\n\n return {\n colorsBackground,\n fill: background ?? atmosphereBackground ?? colorsBackground ?? color,\n };\n};\n\nconst getSwatchTone = ({\n background,\n color,\n colorsBackground,\n isLight,\n}: {\n background: SwatchProps[\"background\"];\n color: SwatchProps[\"color\"];\n colorsBackground: string | undefined;\n isLight: SwatchProps[\"isLight\"];\n}) => {\n if (isLight !== undefined) {\n return isLight ? \"light\" : \"dark\";\n }\n\n const hasColor = color !== undefined && color !== \"\";\n const hasBackground = background !== undefined && background !== \"\";\n const hasColorsBackground = colorsBackground !== undefined && colorsBackground !== \"\";\n\n if (hasColor && !hasBackground && !hasColorsBackground && isLightColor(color)) {\n return \"light\";\n }\n\n return \"dark\";\n};\n\nconst getSwatchDataProps = ({\n flat,\n lightTone,\n raised,\n selected,\n shape,\n showRing,\n size,\n unavailable,\n}: {\n flat: boolean;\n lightTone: \"dark\" | \"light\";\n raised: boolean;\n selected: boolean;\n shape: SwatchProps[\"shape\"];\n showRing: boolean;\n size: SwatchProps[\"size\"];\n unavailable: boolean;\n}) => ({\n \"data-flat\": flat ? \"true\" : undefined,\n \"data-raised\": raised ? \"true\" : undefined,\n \"data-selected\": selected ? \"true\" : undefined,\n \"data-shape\": shape,\n \"data-show-ring\": showRing ? \"true\" : \"false\",\n \"data-size\": size,\n \"data-slot\": \"swatch\",\n \"data-tone\": lightTone,\n \"data-unavailable\": unavailable ? \"true\" : undefined,\n});\n\nconst RemovableSwatch = ({\n ariaLabel,\n children,\n className,\n dataProps,\n onRemove,\n removeLabel,\n rootStyle,\n props,\n}: RemovableSwatchProps) => {\n const handleRemove = (event: MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation();\n onRemove();\n };\n\n return (\n <fieldset\n {...props}\n {...dataProps}\n aria-label={ariaLabel}\n className={joinClassNames(\"patternmode-swatch\", className)}\n style={rootStyle}\n >\n {children}\n <button\n aria-label={removeLabel}\n className=\"patternmode-swatch__remove\"\n onClick={handleRemove}\n type=\"button\"\n >\n <svg aria-hidden=\"true\" fill=\"none\" viewBox=\"0 0 20 20\">\n <path d=\"M5.5 5.5l9 9M14.5 5.5l-9 9\" />\n </svg>\n </button>\n </fieldset>\n );\n};\n\nexport const Swatch = ({\n \"aria-label\": ariaLabel,\n asChild = false,\n background,\n children,\n className,\n color,\n colors,\n density,\n flat = false,\n gravity,\n icon: Icon,\n isLight,\n objectFit,\n objectPosition,\n onRemove,\n raised = false,\n removeLabel,\n role: _role,\n selected = false,\n shape = \"circle\",\n showRing = true,\n size = \"base\",\n style,\n texture,\n unavailable = false,\n ...props\n}: SwatchProps) => {\n const { colorsBackground, fill } = getSwatchFill({\n background,\n color,\n colors,\n density,\n gravity,\n texture,\n });\n const lightTone = getSwatchTone({\n background,\n color,\n colorsBackground,\n isLight,\n });\n const resolvedRemoveLabel =\n removeLabel ?? (ariaLabel !== undefined && ariaLabel !== \"\" ? `Remove ${ariaLabel}` : \"Remove\");\n\n const rootStyle: SwatchRootStyle = {\n ...getSwatchSizeVariableStyle(size),\n \"--patternmode-swatch-fill\": fill,\n ...style,\n };\n const mediaStyle: CSSProperties = getObjectSizingStyle({\n fit: objectFit,\n position: objectPosition,\n });\n const dataProps = getSwatchDataProps({\n flat,\n lightTone,\n raised,\n selected,\n shape,\n showRing,\n size,\n unavailable,\n });\n\n const swatchContent = (\n <SwatchContent\n flat={flat}\n Icon={Icon}\n mediaStyle={mediaStyle}\n selected={selected}\n unavailable={unavailable}\n >\n {asChild ? undefined : children}\n </SwatchContent>\n );\n\n if (asChild) {\n return (\n <Slot\n {...props}\n {...dataProps}\n aria-label={ariaLabel}\n className={joinClassNames(\"patternmode-swatch\", className)}\n style={rootStyle}\n >\n {swatchContent}\n <Slottable>{children}</Slottable>\n </Slot>\n );\n }\n\n if (onRemove !== undefined) {\n return (\n <RemovableSwatch\n ariaLabel={ariaLabel}\n className={className}\n dataProps={dataProps}\n onRemove={onRemove}\n props={props}\n removeLabel={resolvedRemoveLabel}\n rootStyle={rootStyle}\n >\n {swatchContent}\n </RemovableSwatch>\n );\n }\n\n return (\n <figure\n {...props}\n {...dataProps}\n aria-label={ariaLabel}\n className={joinClassNames(\"patternmode-swatch\", className)}\n style={rootStyle}\n >\n {swatchContent}\n </figure>\n );\n};\n"],"mappings":";;;;;;AAcA,MAAM,iBAAiB,UAA2B,OAAO,SAAS,KAAK,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI;AAEhG,MAAMA,WAAS,OAAe,KAAa,QACzC,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAEpC,MAAM,cAAc,UAA0B,OAAO,MAAM,QAAQ,CAAC,CAAC;;AAGrE,MAAa,wBAAwB,aACnC,SAAS,QAAQ,KAAK,YAAY,MAAM,cAAc,QAAQ,KAAK,GAAG,CAAC;;AAGzE,MAAa,kCACX,UACA,kBACW;CACX,MAAM,QAAQ,qBAAqB,QAAQ;CAC3C,IAAI,SAAS,GACX,OAAO;CAMT,OAAO,WAHe,SACnB,MAAM,GAAG,gBAAgB,CAAC,EAC1B,QAAQ,KAAK,YAAY,MAAM,cAAc,QAAQ,KAAK,GAAG,CACjC,IAAI,QAAS,GAAG;AACjD;;;;;;;;AASA,MAAa,4BACX,UACA,eACA,YACA,aAC6B;CAC7B,MAAM,OAAO,SAAS;CACtB,MAAM,QAAQ,SAAS,gBAAgB;CACvC,IAAI,EAAE,QAAQ,QACZ,OAAO;CAGT,MAAM,YAAY,cAAc,KAAK,KAAK,IAAI,cAAc,MAAM,KAAK;CACvE,MAAM,aAAa,KAAK,IAAI,GAAG,KAAK,IAAI,UAAU,YAAY,CAAC,CAAC;CAChE,MAAM,WAAWA,QACf,cAAc,KAAK,KAAK,IAAI,YAC5B,YACA,YAAY,UACd;CACA,MAAM,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A;EACA;EACA;CACF,CAAC;CAED,MAAM,gBACJ,oBAAC,eAAD;EACQ;EACA;EACM;EACF;EACG;YAEZ,UAAU,KAAA,IAAY;CACV,CAAA;CAGjB,IAAI,SACF,OACE,qBAAC,MAAD;EACE,GAAI;EACJ,GAAI;EACJ,cAAY;EACZ,WAAW,eAAe,sBAAsB,SAAS;EACzD,OAAO;YALT,CAOG,eACD,oBAAC,WAAD,EAAY,SAAoB,CAAA,CAC5B;;CAIV,IAAI,aAAa,KAAA,GACf,OACE,oBAAC,iBAAD;EACa;EACA;EACA;EACD;EACH;EACP,aAAa;EACF;YAEV;CACc,CAAA;CAIrB,OACE,oBAAC,UAAD;EACE,GAAI;EACJ,GAAI;EACJ,cAAY;EACZ,WAAW,eAAe,sBAAsB,SAAS;EACzD,OAAO;YAEN;CACK,CAAA;AAEZ"}
|
package/dist/styles.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.patternmode-swatch{--patternmode-swatch-size:2rem;--patternmode-swatch-fill:#e3e1dc;--patternmode-swatch-radius:999px;aspect-ratio:1;border-radius:var(--patternmode-swatch-radius);color:#fff;height:var(--patternmode-swatch-size);vertical-align:middle;min-inline-size:0;width:var(--patternmode-swatch-size);border:0;justify-content:center;align-items:center;margin:0;padding:0;transition:box-shadow .14s,opacity .14s,transform .14s;display:inline-flex;position:relative;box-shadow:0 1px 2px #1118271a}.patternmode-swatch[data-tone=light]{color:#1d1d1b}.patternmode-swatch[data-shape=pill]{--patternmode-swatch-radius:999px;aspect-ratio:auto;width:calc(var(--patternmode-swatch-size) * 3)}.patternmode-swatch[data-shape=square]{--patternmode-swatch-radius:7px}.patternmode-swatch[data-shape=block]{--patternmode-swatch-radius:.25rem;aspect-ratio:auto;width:100%;height:100%;display:block}.patternmode-swatch[data-raised=true]{box-shadow:0 1px 2px #1118271a, 0 0 0 2px var(--surface,#fff)}.patternmode-swatch[data-selected=true][data-show-ring=true]{box-shadow:0 1px 2px #1118271a, 0 0 0 2px var(--surface,#fff), 0 0 0 4px var(--accent,#315c4b)}.patternmode-swatch[data-unavailable=true]{opacity:.5}.patternmode-swatch[data-flat=true]{box-shadow:none}.patternmode-swatch__fill,.patternmode-swatch__media,.patternmode-swatch__scrim{border-radius:inherit;position:absolute;inset:0;overflow:hidden}.patternmode-swatch__fill{background:var(--patternmode-swatch-fill)}.patternmode-swatch__media>*{object-fit:inherit;object-position:inherit;width:100%;height:100%;display:block}.patternmode-swatch__scrim{pointer-events:none;background:linear-gradient(#0000 0%,#0003 100%)}.patternmode-swatch__icon{justify-content:center;align-items:center;display:inline-flex;position:absolute;inset:0}.patternmode-swatch__icon svg{stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:2.4px;width:48%;height:48%;display:block}.patternmode-swatch__slash{background:currentColor;border-radius:999px;width:112%;height:2px;position:absolute;transform:rotate(-45deg)}.patternmode-swatch__remove{color:var(--surface,#fff);cursor:pointer;opacity:0;background:0 0;border:0;border-radius:999px;justify-content:center;align-items:center;width:2.75rem;height:2.75rem;padding:0;transition:opacity .14s;display:inline-flex;position:absolute;top:-1.1rem;right:-1.1rem}.patternmode-swatch__remove:before{background:var(--ink,#1d1d1b);border-radius:inherit;content:"";width:1.25rem;height:1.25rem;transition:background .14s;position:absolute}.patternmode-swatch__remove:focus-visible{opacity:1}@media (hover:hover){.patternmode-swatch:hover .patternmode-swatch__remove{opacity:1}.patternmode-swatch__remove:hover:before{background:var(--accent,#315c4b)}}.patternmode-swatch__remove:focus-visible{outline:2px solid var(--accent,#315c4b);outline-offset:2px}.patternmode-swatch__remove svg{stroke:currentColor;stroke-linecap:round;stroke-width:2px;z-index:1;width:.8rem;height:.8rem}@media (prefers-reduced-motion:reduce){.patternmode-swatch,.patternmode-swatch__remove,.patternmode-swatch__remove:before{transition:none}}.patternmode-distribution-bar,.patternmode-distribution-display{min-inline-size:0;border:0;gap:10px;width:100%;margin:0;padding:0;display:grid}.patternmode-distribution-bar__track{height:var(--patternmode-distribution-height,40px);width:100%;position:relative}.patternmode-distribution-bar .patternmode-distribution-bar__track{touch-action:none}.patternmode-distribution-bar__segments{border:1px solid var(--border-soft,#1118271f);border-radius:var(--patternmode-distribution-radius,999px);width:100%;height:100%;display:flex;overflow:hidden}.patternmode-distribution-bar__segment{background:var(--patternmode-distribution-segment-color);border:0;min-width:0;height:100%;margin:0;padding:0;transition:width .48s cubic-bezier(.2,0,0,1)}button.patternmode-distribution-bar__segment{cursor:pointer}button.patternmode-distribution-bar__segment:focus-visible{outline:2px solid var(--accent,#315c4b);outline-offset:-2px;z-index:2}.patternmode-distribution-bar__segment+.patternmode-distribution-bar__segment{box-shadow:inset 1px 0 #fff9}.patternmode-distribution-bar__segment[data-selected=true]{box-shadow:inset 0 0 0
|
|
1
|
+
@layer components{.patternmode-swatch{--patternmode-swatch-size:2rem;--patternmode-swatch-fill:#e3e1dc;--patternmode-swatch-radius:999px;aspect-ratio:1;border-radius:var(--patternmode-swatch-radius);color:#fff;height:var(--patternmode-swatch-size);vertical-align:middle;min-inline-size:0;width:var(--patternmode-swatch-size);border:0;justify-content:center;align-items:center;margin:0;padding:0;transition:box-shadow .14s,opacity .14s,transform .14s;display:inline-flex;position:relative;box-shadow:0 1px 2px #1118271a}.patternmode-swatch[data-tone=light]{color:#1d1d1b}.patternmode-swatch[data-shape=pill]{--patternmode-swatch-radius:999px;aspect-ratio:auto;width:calc(var(--patternmode-swatch-size) * 3)}.patternmode-swatch[data-shape=square]{--patternmode-swatch-radius:7px}.patternmode-swatch[data-shape=block]{--patternmode-swatch-radius:.25rem;aspect-ratio:auto;width:100%;height:100%;display:block}.patternmode-swatch[data-raised=true]{box-shadow:0 1px 2px #1118271a, 0 0 0 2px var(--surface,#fff)}.patternmode-swatch[data-selected=true][data-show-ring=true]{box-shadow:0 1px 2px #1118271a, 0 0 0 2px var(--surface,#fff), 0 0 0 4px var(--accent,#315c4b)}.patternmode-swatch[data-unavailable=true]{opacity:.5}.patternmode-swatch[data-flat=true]{box-shadow:none}.patternmode-swatch__fill,.patternmode-swatch__media,.patternmode-swatch__scrim{border-radius:inherit;position:absolute;inset:0;overflow:hidden}.patternmode-swatch__fill{background:var(--patternmode-swatch-fill)}.patternmode-swatch__media>*{object-fit:inherit;object-position:inherit;width:100%;height:100%;display:block}.patternmode-swatch__scrim{pointer-events:none;background:linear-gradient(#0000 0%,#0003 100%)}.patternmode-swatch__icon{justify-content:center;align-items:center;display:inline-flex;position:absolute;inset:0}.patternmode-swatch__icon svg{stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:2.4px;width:48%;height:48%;display:block}.patternmode-swatch__slash{background:currentColor;border-radius:999px;width:112%;height:2px;position:absolute;transform:rotate(-45deg)}.patternmode-swatch__remove{color:var(--surface,#fff);cursor:pointer;opacity:0;background:0 0;border:0;border-radius:999px;justify-content:center;align-items:center;width:2.75rem;height:2.75rem;padding:0;transition:opacity .14s;display:inline-flex;position:absolute;top:-1.1rem;right:-1.1rem}.patternmode-swatch__remove:before{background:var(--ink,#1d1d1b);border-radius:inherit;content:"";width:1.25rem;height:1.25rem;transition:background .14s;position:absolute}.patternmode-swatch__remove:focus-visible{opacity:1}@media (hover:hover){.patternmode-swatch:hover .patternmode-swatch__remove{opacity:1}.patternmode-swatch__remove:hover:before{background:var(--accent,#315c4b)}}.patternmode-swatch__remove:focus-visible{outline:2px solid var(--accent,#315c4b);outline-offset:2px}.patternmode-swatch__remove svg{stroke:currentColor;stroke-linecap:round;stroke-width:2px;z-index:1;width:.8rem;height:.8rem}@media (prefers-reduced-motion:reduce){.patternmode-swatch,.patternmode-swatch__remove,.patternmode-swatch__remove:before{transition:none}}.patternmode-distribution-bar,.patternmode-distribution-display{min-inline-size:0;border:0;gap:10px;width:100%;margin:0;padding:0;display:grid}.patternmode-distribution-bar__track{height:var(--patternmode-distribution-height,40px);width:100%;position:relative}.patternmode-distribution-bar .patternmode-distribution-bar__track{touch-action:none}.patternmode-distribution-bar__segments{border:1px solid var(--border-soft,#1118271f);border-radius:var(--patternmode-distribution-radius,999px);width:100%;height:100%;display:flex;overflow:hidden}.patternmode-distribution-bar__segment{background:var(--patternmode-distribution-segment-color);border:0;min-width:0;height:100%;margin:0;padding:0;transition:width .48s cubic-bezier(.2,0,0,1)}button.patternmode-distribution-bar__segment{cursor:pointer}button.patternmode-distribution-bar__segment:focus-visible{outline:2px solid var(--accent,#315c4b);outline-offset:-2px;z-index:2}.patternmode-distribution-bar__segment+.patternmode-distribution-bar__segment{box-shadow:inset 1px 0 #fff9}.patternmode-distribution-bar__segment[data-selected=true]{z-index:2;position:relative}.patternmode-distribution-bar__segment[data-selected=true]:after{border:2px solid var(--surface,#fff);content:"";border-radius:999px;width:.62rem;height:.62rem;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);box-shadow:0 1px 4px #11182747,inset 0 0 0 1px #1118271f}@media (prefers-reduced-motion:reduce){.patternmode-distribution-bar__segment{transition:none}}.patternmode-distribution-bar__segment--empty{background-color:var(--surface-soft,#f7f5f0);background-image:repeating-linear-gradient(45deg, transparent, transparent 3px, var(--border-soft,#1118271f) 3px, var(--border-soft,#1118271f) 4px)}.patternmode-distribution-bar__handle{cursor:ew-resize;z-index:1;background:0 0;border:0;border-radius:999px;justify-content:center;align-items:center;width:2.75rem;height:2.75rem;padding:0;display:inline-flex;position:absolute;top:calc(50% - 1.375rem)}.patternmode-distribution-bar__handle:before{background:var(--surface,#fff);content:"";border-radius:999px;width:.62rem;height:.62rem;transition:box-shadow .12s,transform .12s;box-shadow:0 1px 4px #1118272e,0 0 0 1px #11182733}.patternmode-distribution-bar__handle:focus-visible{outline:2px solid var(--accent,#315c4b);outline-offset:-4px}@media (hover:hover){.patternmode-distribution-bar__handle:hover:before{transform:scale(1.15);box-shadow:0 5px 14px #1118274d,0 0 0 1px #11182738}}.patternmode-distribution-bar__legend{flex-wrap:wrap;gap:8px 14px;display:flex}.patternmode-distribution-bar__legend>span{color:var(--muted,#595853);align-items:center;gap:6px;font-size:.68rem;font-weight:500;display:inline-flex}.patternmode-distribution-bar__swatch{background:var(--patternmode-distribution-segment-color);border-radius:999px;width:.55rem;height:.55rem;display:inline-flex}.patternmode-distribution-bar__swatch--empty{background-color:var(--surface-soft,#f7f5f0);background-image:repeating-linear-gradient(45deg, transparent, transparent 2px, var(--border-soft,#1118271f) 2px, var(--border-soft,#1118271f) 3px);box-shadow:inset 0 0 0 1px var(--border-soft,#1118271f)}@media (prefers-reduced-motion:reduce){.patternmode-distribution-bar__handle:before{transition:none}}}
|
package/dist/swatch.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export { DistributionBar, type DistributionBarProps, type DistributionBarSegment
|
|
|
2
2
|
export { getSwatchAtmosphereBackground, type SwatchAtmosphereOptions, } from "./Swatch/swatch-atmosphere";
|
|
3
3
|
export { getSwatchColorsBackground } from "./Swatch/swatch-colors";
|
|
4
4
|
export { Swatch } from "./Swatch/swatch-root";
|
|
5
|
-
export { getSwatchSizeVariableStyle, SWATCH_SHAPES, SWATCH_SIZE_VALUES, SWATCH_SIZES, SWATCH_TEXTURES, type SwatchColorStop, type SwatchProps, type SwatchShape, type SwatchSize, type SwatchTexture, } from "./Swatch/swatch-types";
|
|
5
|
+
export { getSwatchSizeVariableStyle, SWATCH_SHAPES, SWATCH_SIZE_VALUES, SWATCH_SIZES, SWATCH_TEXTURES, type SwatchAsChildProps, type SwatchColorStop, type SwatchDefaultProps, type SwatchProps, type SwatchShape, type SwatchSharedProps, type SwatchSize, type SwatchTexture, } from "./Swatch/swatch-types";
|
|
6
6
|
//# sourceMappingURL=swatch.d.ts.map
|
package/dist/swatch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swatch.d.ts","sourceRoot":"","sources":["../src/swatch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,8BAA8B,EAC9B,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,6BAA6B,EAC7B,KAAK,uBAAuB,GAC7B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EACL,0BAA0B,EAC1B,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,aAAa,GACnB,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"swatch.d.ts","sourceRoot":"","sources":["../src/swatch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,8BAA8B,EAC9B,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,6BAA6B,EAC7B,KAAK,uBAAuB,GAC7B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EACL,0BAA0B,EAC1B,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,aAAa,GACnB,MAAM,uBAAuB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternmode/swatch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Color, gradient, image, and palette swatch primitives for Patternmode interfaces.",
|
|
6
6
|
"keywords": [
|
|
@@ -41,26 +41,27 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"
|
|
44
|
+
"@radix-ui/react-slot": "^1.2.5",
|
|
45
|
+
"motion": "^12.40.0",
|
|
45
46
|
"@patternmode/system": "0.2.3"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@howells/lint": "^0.
|
|
49
|
-
"@howells/typescript-config": "^0.1.
|
|
49
|
+
"@howells/lint": "^0.5.0",
|
|
50
|
+
"@howells/typescript-config": "^0.1.6",
|
|
50
51
|
"@tailwindcss/cli": "^4.3.0",
|
|
51
52
|
"@testing-library/jest-dom": "^6.9.1",
|
|
52
53
|
"@testing-library/react": "^16.3.2",
|
|
53
54
|
"@testing-library/user-event": "^14.6.1",
|
|
54
|
-
"@types/react": "^19.2.
|
|
55
|
+
"@types/react": "^19.2.17",
|
|
55
56
|
"@types/react-dom": "^19.2.3",
|
|
56
57
|
"concurrently": "^9.2.1",
|
|
57
58
|
"jsdom": "^29.1.1",
|
|
58
|
-
"react": "^19.2.
|
|
59
|
-
"react-dom": "^19.2.
|
|
59
|
+
"react": "^19.2.7",
|
|
60
|
+
"react-dom": "^19.2.7",
|
|
60
61
|
"tailwindcss": "^4.3.0",
|
|
61
62
|
"tsdown": "^0.22.0",
|
|
62
63
|
"typescript": "^6.0.3",
|
|
63
|
-
"vitest": "^4.1.
|
|
64
|
+
"vitest": "^4.1.8"
|
|
64
65
|
},
|
|
65
66
|
"peerDependencies": {
|
|
66
67
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -77,8 +78,8 @@
|
|
|
77
78
|
"dev:js": "tsdown --watch",
|
|
78
79
|
"dev:styles": "tailwindcss -i ./src/styles.css -o ./dist/styles.css --watch",
|
|
79
80
|
"dev:types": "tsc --emitDeclarationOnly --declaration --declarationMap --outDir dist --noEmit false --watch --preserveWatchOutput",
|
|
80
|
-
"lint": "howells-
|
|
81
|
-
"lint:fix": "howells-
|
|
81
|
+
"lint": "howells-check .",
|
|
82
|
+
"lint:fix": "howells-fix .",
|
|
82
83
|
"test": "vitest run",
|
|
83
84
|
"typecheck": "tsc --noEmit"
|
|
84
85
|
}
|