@pathscale/ui 2.8.0 → 2.9.0

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.
@@ -0,0 +1,6 @@
1
+ .color-wheel {
2
+ min-width: 0;
3
+ margin: 0;
4
+ padding: 0;
5
+ border: 0;
6
+ }
@@ -0,0 +1,27 @@
1
+ import type { JSX } from "@solidjs/web";
2
+ import { type ColorWheelFlowerMode } from "../color-wheel-flower";
3
+ interface ColorWheelBaseProps {
4
+ /** The literal selected colour. */
5
+ value: string;
6
+ /** Receives the normalized literal hex displayed by the selected petal. */
7
+ onChange: (value: string) => void;
8
+ /** Explicit mode. Omit to follow the root `data-theme`. */
9
+ mode?: ColorWheelFlowerMode;
10
+ /** Exactly 31 literal colours: outer ring, middle ring, inner ring, centre. */
11
+ palette?: readonly string[];
12
+ isDisabled?: boolean;
13
+ class?: string;
14
+ wheelClass?: string;
15
+ "aria-label"?: string;
16
+ }
17
+ export type ColorWheelProps = ColorWheelBaseProps & Omit<JSX.FieldsetHTMLAttributes<HTMLFieldSetElement>, keyof ColorWheelBaseProps | "onChange">;
18
+ /**
19
+ * A controlled literal colour wheel.
20
+ *
21
+ * `ColorWheelFlower` remains the low-level context consumer. This is the
22
+ * ordinary application surface: value in, normalized value out, no private
23
+ * picker context for every consumer to recreate.
24
+ */
25
+ export declare function ColorWheel(props: ColorWheelProps): JSX.Element;
26
+ import "./ColorWheel.css";
27
+ export {};
@@ -0,0 +1,53 @@
1
+ import { createComponent, insert, mergeProps, spread, template } from "@solidjs/web";
2
+ import { createMemo, omit } from "solid-js";
3
+ import { twMerge } from "../../lib/twMerge.js";
4
+ import { ColorPickerContext, ColorWheelFlower } from "../color-wheel-flower/index.js";
5
+ import { parseColor } from "../color-wheel-flower/ColorUtils.js";
6
+ import "./ColorWheel.css";
7
+ var _tmpl$ = /*#__PURE__*/ template("<fieldset>");
8
+ const FALLBACK = parseColor("#ffffff");
9
+ function ColorWheel(props) {
10
+ const local = props;
11
+ const others = omit(props, "value", "onChange", "mode", "palette", "isDisabled", "class", "wheelClass", "aria-label");
12
+ const color = createMemo(()=>parseColor(local.value) ?? FALLBACK);
13
+ const context = ()=>({
14
+ color,
15
+ format: ()=>"hex",
16
+ disabled: ()=>Boolean(local.isDisabled),
17
+ onChange: (next)=>local.onChange(next.hex),
18
+ onFormatChange: ()=>{}
19
+ });
20
+ var _el$ = _tmpl$();
21
+ spread(_el$, mergeProps(others, {
22
+ get ["class"] () {
23
+ return twMerge("color-wheel", local.class);
24
+ },
25
+ get ["aria-label"] () {
26
+ return local["aria-label"] ?? "Colour";
27
+ },
28
+ "data-slot": "color-wheel",
29
+ get ["data-disabled"] () {
30
+ return local.isDisabled ? "" : void 0;
31
+ }
32
+ }), true);
33
+ insert(_el$, createComponent(ColorPickerContext, {
34
+ get value () {
35
+ return context();
36
+ },
37
+ get children () {
38
+ return createComponent(ColorWheelFlower, {
39
+ get ["class"] () {
40
+ return local.wheelClass;
41
+ },
42
+ get mode () {
43
+ return local.mode;
44
+ },
45
+ get palette () {
46
+ return local.palette;
47
+ }
48
+ });
49
+ }
50
+ }));
51
+ return _el$;
52
+ }
53
+ export { ColorWheel };
@@ -0,0 +1,97 @@
1
+ .complex-color-wheel {
2
+ display: flex;
3
+ align-items: flex-start;
4
+ gap: 1rem;
5
+ padding: 0.875rem;
6
+ }
7
+
8
+ .complex-color-wheel__adjustments {
9
+ display: flex;
10
+ min-width: 0;
11
+ flex: 1;
12
+ flex-direction: column;
13
+ gap: 0.875rem;
14
+ }
15
+
16
+ .complex-color-wheel__action {
17
+ display: flex;
18
+ justify-content: flex-end;
19
+ }
20
+
21
+ .complex-color-wheel__axis {
22
+ display: flex;
23
+ min-width: 0;
24
+ flex-direction: column;
25
+ gap: 0.25rem;
26
+ }
27
+
28
+ .complex-color-wheel__axis-heading {
29
+ display: flex;
30
+ align-items: baseline;
31
+ justify-content: space-between;
32
+ gap: 0.75rem;
33
+ color: var(--color-base-content);
34
+ font-size: 0.75rem;
35
+ }
36
+
37
+ .complex-color-wheel__axis-control {
38
+ display: grid;
39
+ grid-template-columns: auto minmax(0, 1fr);
40
+ align-items: center;
41
+ gap: 0.5rem;
42
+ }
43
+
44
+ .complex-color-wheel__stops {
45
+ display: flex;
46
+ grid-column: 1 / -1;
47
+ align-items: center;
48
+ gap: 0.5rem;
49
+ }
50
+
51
+ .complex-color-wheel__stop {
52
+ width: 1.75rem;
53
+ min-width: 1.75rem;
54
+ height: 1.75rem;
55
+ min-height: 1.75rem;
56
+ padding: 0;
57
+ overflow: hidden;
58
+ border-radius: 9999px;
59
+ }
60
+
61
+ .complex-color-wheel__stop[aria-pressed="true"] {
62
+ outline: 2px solid var(--color-primary);
63
+ outline-offset: 2px;
64
+ }
65
+
66
+ .complex-color-wheel__stop-preview {
67
+ display: flex;
68
+ width: 100%;
69
+ height: 100%;
70
+ align-items: center;
71
+ justify-content: center;
72
+ border-radius: inherit;
73
+ font-size: 0.75rem;
74
+ font-weight: 600;
75
+ line-height: 1;
76
+ }
77
+
78
+ .complex-color-wheel__preview {
79
+ width: 1.5rem;
80
+ height: 1.5rem;
81
+ border: 1px solid color-mix(in srgb, var(--color-base-content) 16%, transparent);
82
+ border-radius: 9999px;
83
+ box-shadow: inset 0 1px 0 rgb(255 255 255 / 12%);
84
+ }
85
+
86
+ .complex-color-wheel__hint {
87
+ color: color-mix(in srgb, var(--color-base-content) 62%, transparent);
88
+ font-size: 0.6875rem;
89
+ line-height: 1.35;
90
+ }
91
+
92
+ @media (max-width: 40rem) {
93
+ .complex-color-wheel {
94
+ align-items: stretch;
95
+ flex-direction: column;
96
+ }
97
+ }
@@ -0,0 +1,42 @@
1
+ import "./ComplexColorWheel.css";
2
+ import type { JSX } from "@solidjs/web";
3
+ import { type CardMaterial } from "../card";
4
+ import { type ColorWheelProps } from "./ColorWheel";
5
+ export interface ColorWheelAdjustment {
6
+ id: string;
7
+ label: string;
8
+ hint?: string;
9
+ value: number;
10
+ min?: number;
11
+ max?: number;
12
+ step?: number;
13
+ /** Curated values rendered as semantic choices instead of a continuous slider. */
14
+ stops?: readonly number[];
15
+ onChange: (value: number) => void;
16
+ onChangeEnd?: (value: number) => void;
17
+ formatValue?: (value: number) => string;
18
+ /** Optional literal preview produced by this adjustment at a value. */
19
+ preview?: (value: number, color: string) => string;
20
+ /** Optional foreground preview, such as a text-brightness sample. */
21
+ ink?: (value: number, color: string) => string;
22
+ }
23
+ export interface ComplexColorWheelProps extends ColorWheelProps {
24
+ /**
25
+ * Strength, softness and glass axes, in the order the application wants.
26
+ * The composition owns their standard slider markup; colour mathematics
27
+ * remain explicit consumer policy through `preview` and `onChange`.
28
+ */
29
+ adjustments: readonly ColorWheelAdjustment[];
30
+ material?: CardMaterial;
31
+ action?: JSX.Element;
32
+ adjustmentsClass?: string;
33
+ }
34
+ /**
35
+ * A colour wheel with standard value axes beside it.
36
+ *
37
+ * This is deliberately a composition instead of a theme engine. Applications
38
+ * agree on the interaction and accessible structure while retaining control
39
+ * of what "strength", "softness", blur, refraction or depth mean for their
40
+ * own tokens.
41
+ */
42
+ export declare function ComplexColorWheel(props: ComplexColorWheelProps): JSX.Element;
@@ -0,0 +1,182 @@
1
+ import { className, createComponent, effect, insert, memo, setAttribute, setStyleProperty, template } from "@solidjs/web";
2
+ import "./ComplexColorWheel.css";
3
+ import { For, Show } from "solid-js";
4
+ import button_0 from "../button/index.js";
5
+ import card from "../card/index.js";
6
+ import slider from "../slider/index.js";
7
+ import { ColorWheel } from "./ColorWheel.js";
8
+ var _tmpl$ = /*#__PURE__*/ template("<div class=complex-color-wheel__action data-slot=complex-color-wheel-action>"), _tmpl$2 = /*#__PURE__*/ template("<div data-slot=complex-color-wheel-adjustments><!><!>"), _tmpl$3 = /*#__PURE__*/ template("<span class=complex-color-wheel__hint>"), _tmpl$4 = /*#__PURE__*/ template("<div class=complex-color-wheel__axis data-slot=complex-color-wheel-axis><div class=complex-color-wheel__axis-heading><span></span><span></span></div><div class=complex-color-wheel__axis-control>"), _tmpl$5 = /*#__PURE__*/ template("<span class=complex-color-wheel__preview aria-hidden=true>"), _tmpl$6 = /*#__PURE__*/ template("<div class=complex-color-wheel__stops>"), _tmpl$7 = /*#__PURE__*/ template("<span aria-hidden=true class=complex-color-wheel__stop-preview>");
9
+ function ComplexColorWheel(props) {
10
+ return createComponent(card, {
11
+ get material () {
12
+ return props.material ?? "glass";
13
+ },
14
+ class: "complex-color-wheel",
15
+ "data-slot": "complex-color-wheel",
16
+ get children () {
17
+ return [
18
+ createComponent(ColorWheel, {
19
+ get value () {
20
+ return props.value;
21
+ },
22
+ get onChange () {
23
+ return props.onChange;
24
+ },
25
+ get mode () {
26
+ return props.mode;
27
+ },
28
+ get palette () {
29
+ return props.palette;
30
+ },
31
+ get isDisabled () {
32
+ return props.isDisabled;
33
+ },
34
+ get ["class"] () {
35
+ return props.class;
36
+ },
37
+ get wheelClass () {
38
+ return props.wheelClass;
39
+ },
40
+ get ["aria-label"] () {
41
+ return props["aria-label"];
42
+ }
43
+ }),
44
+ (()=>{
45
+ var _el$ = _tmpl$2(), _el$3 = _el$.firstChild, _el$4 = _el$3.nextSibling;
46
+ insert(_el$, createComponent(Show, {
47
+ get when () {
48
+ return props.action;
49
+ },
50
+ get children () {
51
+ var _el$2 = _tmpl$();
52
+ insert(_el$2, ()=>props.action);
53
+ return _el$2;
54
+ }
55
+ }), _el$3);
56
+ insert(_el$, createComponent(For, {
57
+ get each () {
58
+ return props.adjustments;
59
+ },
60
+ children: (adjustment)=>(()=>{
61
+ var _el$5 = _tmpl$4(), _el$6 = _el$5.firstChild, _el$7 = _el$6.firstChild, _el$8 = _el$7.nextSibling, _el$9 = _el$6.nextSibling;
62
+ insert(_el$7, ()=>adjustment.label);
63
+ insert(_el$8, ()=>adjustment.formatValue?.(adjustment.value) ?? adjustment.value);
64
+ insert(_el$9, createComponent(Show, {
65
+ get when () {
66
+ return memo(()=>!!adjustment.stops?.length)() ? adjustment.stops : void 0;
67
+ },
68
+ get fallback () {
69
+ return [
70
+ createComponent(Show, {
71
+ get when () {
72
+ return adjustment.preview;
73
+ },
74
+ get children () {
75
+ var _el$1 = _tmpl$5();
76
+ effect(()=>adjustment.preview?.(adjustment.value, props.value), (_v$)=>{
77
+ setStyleProperty(_el$1, "background-color", _v$);
78
+ });
79
+ return _el$1;
80
+ }
81
+ }),
82
+ createComponent(slider, {
83
+ get label () {
84
+ return adjustment.label;
85
+ },
86
+ get value () {
87
+ return adjustment.value;
88
+ },
89
+ get min () {
90
+ return adjustment.min ?? 0;
91
+ },
92
+ get max () {
93
+ return adjustment.max ?? 100;
94
+ },
95
+ get step () {
96
+ return adjustment.step;
97
+ },
98
+ get disabled () {
99
+ return props.isDisabled;
100
+ },
101
+ get onChange () {
102
+ return adjustment.onChange;
103
+ },
104
+ get onChangeEnd () {
105
+ return adjustment.onChangeEnd;
106
+ },
107
+ get formatValue () {
108
+ return adjustment.formatValue;
109
+ },
110
+ size: "sm"
111
+ })
112
+ ];
113
+ },
114
+ children: (stops)=>(()=>{
115
+ var _el$10 = _tmpl$6();
116
+ insert(_el$10, createComponent(For, {
117
+ get each () {
118
+ return stops();
119
+ },
120
+ children: (stop)=>createComponent(button_0, {
121
+ type: "button",
122
+ size: "sm",
123
+ variant: "ghost",
124
+ get ["aria-label"] () {
125
+ return `${adjustment.label} ${adjustment.formatValue?.(stop) ?? stop}`;
126
+ },
127
+ get ["aria-pressed"] () {
128
+ return Math.abs(adjustment.value - stop) < 0.001 ? "true" : "false";
129
+ },
130
+ get disabled () {
131
+ return props.isDisabled;
132
+ },
133
+ onClick: ()=>adjustment.onChange(stop),
134
+ class: "complex-color-wheel__stop",
135
+ get children () {
136
+ var _el$11 = _tmpl$7();
137
+ insert(_el$11, createComponent(Show, {
138
+ get when () {
139
+ return adjustment.ink;
140
+ },
141
+ children: "A"
142
+ }));
143
+ effect(()=>({
144
+ e: adjustment.preview?.(stop, props.value),
145
+ t: adjustment.ink?.(stop, props.value)
146
+ }), ({ e, t }, _p$)=>{
147
+ e !== _p$?.e && setStyleProperty(_el$11, "background-color", e);
148
+ t !== _p$?.t && setStyleProperty(_el$11, "color", t);
149
+ });
150
+ return _el$11;
151
+ }
152
+ })
153
+ }));
154
+ return _el$10;
155
+ })()
156
+ }));
157
+ insert(_el$5, createComponent(Show, {
158
+ get when () {
159
+ return adjustment.hint;
160
+ },
161
+ get children () {
162
+ var _el$0 = _tmpl$3();
163
+ insert(_el$0, ()=>adjustment.hint);
164
+ return _el$0;
165
+ }
166
+ }), null);
167
+ effect(()=>adjustment.id, (_v$)=>{
168
+ setAttribute(_el$5, "data-axis", _v$);
169
+ });
170
+ return _el$5;
171
+ })()
172
+ }), _el$4);
173
+ effect(()=>`complex-color-wheel__adjustments ${props.adjustmentsClass ?? ""}`.trim(), (_v$, _$p)=>{
174
+ className(_el$, _v$, _$p);
175
+ });
176
+ return _el$;
177
+ })()
178
+ ];
179
+ }
180
+ });
181
+ }
182
+ export { ComplexColorWheel };
@@ -0,0 +1,4 @@
1
+ export { ColorWheel } from "./ColorWheel";
2
+ export type { ColorWheelProps } from "./ColorWheel";
3
+ export { ComplexColorWheel } from "./ComplexColorWheel";
4
+ export type { ColorWheelAdjustment, ComplexColorWheelProps, } from "./ComplexColorWheel";
@@ -0,0 +1,2 @@
1
+ export { ColorWheel } from "./ColorWheel.js";
2
+ export { ComplexColorWheel } from "./ComplexColorWheel.js";
@@ -219,6 +219,9 @@ const __solidLayoutSlider = (_stable, p)=>{
219
219
  get ["aria-valuetext"] () {
220
220
  return formattedValue();
221
221
  },
222
+ get ["aria-label"] () {
223
+ return p["aria-label"] ?? p.label;
224
+ },
222
225
  get ["aria-labelledby"] () {
223
226
  return p.label ? labelId : void 0;
224
227
  },
package/dist/index.d.ts CHANGED
@@ -29,6 +29,7 @@ export type { CollapsibleBodyProps, CollapsibleContentProps, CollapsibleHeadingP
29
29
  export { default as Collapsible } from "./components/collapsible";
30
30
  export type { ColorSwatchProps, ColorSwatchShape, ColorSwatchSize, } from "./components/color-swatch";
31
31
  export { default as ColorSwatch } from "./components/color-swatch";
32
+ export { ColorWheel, ComplexColorWheel, type ColorWheelAdjustment, type ColorWheelProps, type ComplexColorWheelProps, } from "./components/color-wheel";
32
33
  export type { ComposerProps } from "./components/composer";
33
34
  export { autosize, boundsFromRows, default as Composer, isSubmittable, shouldSubmit, } from "./components/composer";
34
35
  export type { CreateDataGridOptions, DataGridBorders, DataGridCellContext, DataGridColumn, DataGridColumnOptions, DataGridDataType, DataGridModel, DataGridProps, DataGridRow, DataGridSelectionMode, DataGridSort, DataGridSortDirection, DataGridSticky, DataGridStriping, } from "./components/data-grid";
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ export { default as Checkbox } from "./components/checkbox/index.js";
20
20
  export { default as Chip } from "./components/chip/index.js";
21
21
  export { default as Collapsible } from "./components/collapsible/index.js";
22
22
  export { default as ColorSwatch } from "./components/color-swatch/index.js";
23
+ export { ColorWheel, ComplexColorWheel } from "./components/color-wheel/index.js";
23
24
  export { autosize, boundsFromRows, default as Composer, isSubmittable, shouldSubmit } from "./components/composer/index.js";
24
25
  export { createDataGrid, default as DataGrid } from "./components/data-grid/index.js";
25
26
  export { DialogBackdrop, DialogBody, DialogCloseTrigger, DialogContent, DialogFooter, DialogHeader, DialogHeading, DialogIcon, DialogTrigger, default as Dialog } from "./components/dialog/index.js";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "format": "solid-layouts-library-v2",
3
3
  "package": "@pathscale/ui",
4
- "version": "2.8.0",
4
+ "version": "2.9.0",
5
5
  "components": {
6
6
  "Accordion": {
7
7
  "kind": "embedded"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pathscale/ui",
3
- "version": "2.8.0",
3
+ "version": "2.9.0",
4
4
  "author": "pathscale",
5
5
  "repository": {
6
6
  "type": "git",