dawn-ui-react 1.0.0-alpha.25 → 1.0.0-alpha.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/colour-picker/colour-picker-lightness-slider.d.ts +3 -0
- package/dist/components/colour-picker/colour-picker.d.ts +1 -1
- package/dist/components/colour-picker/colour-picker.types.d.ts +7 -0
- package/dist/dawn-ui-react.js +68 -58
- package/dist/dawn-ui-react.umd.cjs +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { ColourPickerProps, ColourPickerContextType } from './colour-picker.types';
|
|
3
|
-
export declare const ColourPicker: ({ variant, defaultColour, defaultPalette, paletteLimit, className, children, ref, ...props }: ColourPickerProps) => React.JSX.Element;
|
|
3
|
+
export declare const ColourPicker: ({ variant, value: controlledValue, defaultColour, defaultPalette, paletteLimit, onValueChange, className, children, ref, ...props }: ColourPickerProps) => React.JSX.Element;
|
|
4
4
|
export declare const useColourPicker: () => ColourPickerContextType;
|
|
@@ -15,6 +15,7 @@ export type ColourPickerContextType = {
|
|
|
15
15
|
setSaturation: (saturation: number) => void;
|
|
16
16
|
setValue: (value: number) => void;
|
|
17
17
|
setAlpha: (alpha: number) => void;
|
|
18
|
+
setLightness: (lightness: number) => void;
|
|
18
19
|
valueType: ValueType;
|
|
19
20
|
setValueType: (valueType: ValueType) => void;
|
|
20
21
|
palette: chroma.Color[];
|
|
@@ -45,6 +46,9 @@ export type ColourPickerAction = {
|
|
|
45
46
|
} | {
|
|
46
47
|
type: 'set_alpha';
|
|
47
48
|
alpha: number;
|
|
49
|
+
} | {
|
|
50
|
+
type: 'set_lightness';
|
|
51
|
+
lightness: number;
|
|
48
52
|
} | {
|
|
49
53
|
type: 'set_value_type';
|
|
50
54
|
valueType: ValueType;
|
|
@@ -56,9 +60,11 @@ export type ColourPickerAction = {
|
|
|
56
60
|
colour: chroma.Color;
|
|
57
61
|
};
|
|
58
62
|
export type ColourPickerProps = React.ComponentProps<'div'> & VariantProps<typeof colourPickerVariants> & {
|
|
63
|
+
value?: string | chroma.Color;
|
|
59
64
|
defaultColour?: string;
|
|
60
65
|
defaultPalette?: string[];
|
|
61
66
|
paletteLimit?: number;
|
|
67
|
+
onValueChange?: (colour: chroma.Color) => void;
|
|
62
68
|
};
|
|
63
69
|
export declare const colourPickerVariants: (props?: ({
|
|
64
70
|
variant?: "ghost" | "outline" | "elevated" | null | undefined;
|
|
@@ -76,6 +82,7 @@ export type ValueType = {
|
|
|
76
82
|
export type ColourPickerInputProps = React.ComponentProps<typeof InputGroup>;
|
|
77
83
|
export type ColourPickerAreaProps = React.ComponentProps<'div'>;
|
|
78
84
|
export type ColourPickerHueSliderProps = Partial<React.ComponentProps<typeof ColourChannelSlider>>;
|
|
85
|
+
export type ColourPickerLightnessSliderProps = Partial<React.ComponentProps<typeof ColourChannelSlider>>;
|
|
79
86
|
export type ColourPickerTransparencySliderProps = Partial<React.ComponentProps<typeof ColourChannelSlider>>;
|
|
80
87
|
export type ColourPickerValueTypeProps = React.ComponentProps<typeof SelectTrigger>;
|
|
81
88
|
export type ColourPickerRowProps = React.ComponentProps<'div'>;
|
package/dist/dawn-ui-react.js
CHANGED
|
@@ -34483,9 +34483,9 @@ var qH = ({ content: e, ...t }) => /* @__PURE__ */ b(KH, {
|
|
|
34483
34483
|
}, LU = mr("", {
|
|
34484
34484
|
variants: {
|
|
34485
34485
|
variant: {
|
|
34486
|
-
default: "space-y-
|
|
34487
|
-
ghost: "space-y-
|
|
34488
|
-
underline: "space-y-
|
|
34486
|
+
default: "space-y-xs [&_[role=presentation]]:top-1/2 [&_[role=tablist]]:bg-surface-low",
|
|
34487
|
+
ghost: "space-y-2xs [&_[role=presentation]]:top-1/2 [&_[role=presentation]]:rounded-full [&_[role=presentation]]:border [&_[role=tablist]]:rounded-full",
|
|
34488
|
+
underline: "space-y-xs [&_[role=tablist]]:border-border"
|
|
34489
34489
|
},
|
|
34490
34490
|
size: {
|
|
34491
34491
|
small: "",
|
|
@@ -34685,7 +34685,7 @@ var qH = ({ content: e, ...t }) => /* @__PURE__ */ b(KH, {
|
|
|
34685
34685
|
className: X("relative z-0 flex", e),
|
|
34686
34686
|
...t
|
|
34687
34687
|
}), VU = ({ className: e, ...t }) => /* @__PURE__ */ b(Hx, {
|
|
34688
|
-
className: X("relative flex grow items-center justify-start
|
|
34688
|
+
className: X("relative flex grow flex-col items-center justify-start gap-md", e),
|
|
34689
34689
|
...t
|
|
34690
34690
|
}), HU = ({ className: e, ...t }) => /* @__PURE__ */ b(zx, {
|
|
34691
34691
|
className: X("inline-flex items-center justify-center gap-xs text-center break-keep whitespace-nowrap text-on-surface transition-colors duration-300 outline-none select-none hover:cursor-pointer focus-visible:relative focus-visible:before:absolute focus-visible:before:outline", e),
|
|
@@ -37006,6 +37006,10 @@ var _q = _W, vq = mr("flex flex-col space-y-sm", {
|
|
|
37006
37006
|
...e,
|
|
37007
37007
|
alpha: t.alpha
|
|
37008
37008
|
};
|
|
37009
|
+
case "set_lightness": return {
|
|
37010
|
+
...e,
|
|
37011
|
+
value: t.lightness
|
|
37012
|
+
};
|
|
37009
37013
|
case "set_value_type": return {
|
|
37010
37014
|
...e,
|
|
37011
37015
|
valueType: t.valueType
|
|
@@ -37020,10 +37024,10 @@ var _q = _W, vq = mr("flex flex-col space-y-sm", {
|
|
|
37020
37024
|
};
|
|
37021
37025
|
default: return e;
|
|
37022
37026
|
}
|
|
37023
|
-
}, Cq = ({ variant: e,
|
|
37024
|
-
let [
|
|
37025
|
-
defaultColour:
|
|
37026
|
-
defaultPalette:
|
|
37027
|
+
}, Cq = ({ variant: e, value: n, defaultColour: r, defaultPalette: i, paletteLimit: a, onValueChange: o, className: s, children: c, ref: l, ...u }) => {
|
|
37028
|
+
let [d, f] = t.useReducer(Sq, {
|
|
37029
|
+
defaultColour: r,
|
|
37030
|
+
defaultPalette: i
|
|
37027
37031
|
}, ({ defaultColour: e, defaultPalette: t }) => {
|
|
37028
37032
|
let n = _q(e ?? "#ffffff"), [r, i, a] = n.hsv();
|
|
37029
37033
|
return {
|
|
@@ -37034,62 +37038,68 @@ var _q = _W, vq = mr("flex flex-col space-y-sm", {
|
|
|
37034
37038
|
valueType: bq[0],
|
|
37035
37039
|
palette: (t ?? []).map((e) => _q(e))
|
|
37036
37040
|
};
|
|
37037
|
-
}), { hue:
|
|
37038
|
-
d,
|
|
37039
|
-
f,
|
|
37041
|
+
}), { hue: p, saturation: m, value: h, alpha: g, valueType: _, palette: v } = d, y = t.useMemo(() => _q.hsv(p, m, h).alpha(g), [
|
|
37040
37042
|
p,
|
|
37041
|
-
m
|
|
37042
|
-
|
|
37043
|
-
|
|
37044
|
-
|
|
37045
|
-
|
|
37046
|
-
|
|
37047
|
-
|
|
37048
|
-
|
|
37049
|
-
|
|
37050
|
-
|
|
37051
|
-
|
|
37052
|
-
|
|
37053
|
-
|
|
37054
|
-
|
|
37055
|
-
|
|
37056
|
-
|
|
37057
|
-
|
|
37043
|
+
m,
|
|
37044
|
+
h,
|
|
37045
|
+
g
|
|
37046
|
+
]), x = t.useMemo(() => n === void 0 ? y : _q(n), [n, y]), [S, C, w] = x.hsv(), T = S == null || Number.isNaN(S) ? p : S, E = C == null || Number.isNaN(C) ? m : C, D = w, O = x.alpha(), k = t.useCallback((e) => {
|
|
37047
|
+
n === void 0 && f({
|
|
37048
|
+
type: "set_colour",
|
|
37049
|
+
colour: e
|
|
37050
|
+
}), o?.(e);
|
|
37051
|
+
}, [n, o]), A = t.useCallback((e) => k(_q.hsv(e, E, D).alpha(O)), [
|
|
37052
|
+
O,
|
|
37053
|
+
E,
|
|
37054
|
+
k,
|
|
37055
|
+
D
|
|
37056
|
+
]), j = t.useCallback((e) => k(_q.hsv(T, e, D).alpha(O)), [
|
|
37057
|
+
O,
|
|
37058
|
+
T,
|
|
37059
|
+
k,
|
|
37060
|
+
D
|
|
37061
|
+
]), M = t.useCallback((e) => k(_q.hsv(T, E, e).alpha(O)), [
|
|
37062
|
+
O,
|
|
37063
|
+
T,
|
|
37064
|
+
E,
|
|
37065
|
+
k
|
|
37066
|
+
]), N = t.useCallback((e) => k(x.alpha(e)), [x, k]), P = t.useCallback((e) => k(x.set("hsl.l", e)), [x, k]), F = t.useCallback((e) => f({
|
|
37058
37067
|
type: "set_value_type",
|
|
37059
37068
|
valueType: e
|
|
37060
|
-
}), []),
|
|
37069
|
+
}), []), I = t.useCallback((e) => f({
|
|
37061
37070
|
type: "set_palette",
|
|
37062
37071
|
palette: e
|
|
37063
|
-
}), []),
|
|
37064
|
-
if (!(
|
|
37072
|
+
}), []), L = t.useCallback((e) => {
|
|
37073
|
+
if (!(a && v.length >= a)) return f({
|
|
37065
37074
|
type: "add_palette_colour",
|
|
37066
37075
|
colour: e
|
|
37067
37076
|
});
|
|
37068
|
-
}, [
|
|
37077
|
+
}, [v, a]);
|
|
37069
37078
|
return /* @__PURE__ */ b(xq.Provider, {
|
|
37070
37079
|
value: {
|
|
37071
|
-
colour:
|
|
37072
|
-
setColour:
|
|
37073
|
-
hue:
|
|
37074
|
-
saturation:
|
|
37075
|
-
value:
|
|
37076
|
-
alpha:
|
|
37077
|
-
setHue:
|
|
37078
|
-
setSaturation:
|
|
37079
|
-
setValue:
|
|
37080
|
-
setAlpha:
|
|
37081
|
-
|
|
37082
|
-
|
|
37083
|
-
|
|
37084
|
-
|
|
37085
|
-
|
|
37086
|
-
|
|
37080
|
+
colour: x,
|
|
37081
|
+
setColour: k,
|
|
37082
|
+
hue: T,
|
|
37083
|
+
saturation: E,
|
|
37084
|
+
value: D,
|
|
37085
|
+
alpha: O,
|
|
37086
|
+
setHue: A,
|
|
37087
|
+
setSaturation: j,
|
|
37088
|
+
setValue: M,
|
|
37089
|
+
setAlpha: N,
|
|
37090
|
+
setLightness: P,
|
|
37091
|
+
valueType: _,
|
|
37092
|
+
setValueType: F,
|
|
37093
|
+
palette: v,
|
|
37094
|
+
setPalette: I,
|
|
37095
|
+
addPaletteColour: L,
|
|
37096
|
+
paletteLimit: a
|
|
37087
37097
|
},
|
|
37088
37098
|
children: /* @__PURE__ */ b("div", {
|
|
37089
|
-
className: X(vq({ variant: e }),
|
|
37090
|
-
ref:
|
|
37091
|
-
...
|
|
37092
|
-
children:
|
|
37099
|
+
className: X(vq({ variant: e }), s),
|
|
37100
|
+
ref: l,
|
|
37101
|
+
...u,
|
|
37102
|
+
children: c
|
|
37093
37103
|
})
|
|
37094
37104
|
});
|
|
37095
37105
|
}, wq = () => {
|
|
@@ -37097,9 +37107,9 @@ var _q = _W, vq = mr("flex flex-col space-y-sm", {
|
|
|
37097
37107
|
if (!e) throw Error("useColourPicker must be used within a ColourPicker");
|
|
37098
37108
|
return e;
|
|
37099
37109
|
}, Tq = ({ className: e, ref: t, ...n }) => {
|
|
37100
|
-
let { colour: r, hue: i, saturation: a, value: o,
|
|
37110
|
+
let { colour: r, hue: i, saturation: a, value: o, alpha: s, setColour: c } = wq(), l = _q.hsv(i, 1, 1).hex(), u = (e) => {
|
|
37101
37111
|
let t = e.currentTarget.getBoundingClientRect(), n = Math.min(Math.max((e.clientX - t.left) / t.width, 0), 1), r = Math.min(Math.max(1 - (e.clientY - t.top) / t.height, 0), 1);
|
|
37102
|
-
|
|
37112
|
+
c(_q.hsv(i, n, r).alpha(s));
|
|
37103
37113
|
}, d = (e) => {
|
|
37104
37114
|
e.currentTarget.setPointerCapture(e.pointerId), u(e);
|
|
37105
37115
|
};
|
|
@@ -46757,12 +46767,12 @@ var u5 = ({ row: e, className: t, children: n, ref: r, ...i }) => /* @__PURE__ *
|
|
|
46757
46767
|
ref: i,
|
|
46758
46768
|
...a,
|
|
46759
46769
|
children: r
|
|
46760
|
-
}), Zue = mr("flex flex-col gap-3xs data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 [&_[role=\"group\"]]:outline [&_[role=\"group\"]]:outline-transparent [&_[role=\"group\"]]:transition-all aria-invalid:[&_[role=\"group\"]]:bg-error-container aria-invalid:[&_[role=\"group\"]]:outline-error-border aria-invalid:[&_[role=\"group\"]]:focus-within:outline-error-border-strong aria-invalid:[&_[role=\"group\"]]:not-focus-within:hover:outline-error-border data-[disabled]:[&_[role=\"group\"]]:cursor-not-allowed data-[invalid]:[&_[role=\"group\"]]:bg-error-container data-[invalid]:[&_[role=\"group\"]]:outline-error-border data-[invalid]:[&_[role=\"group\"]]:focus-within:outline-error-border-strong data-[invalid]:[&_[role=\"group\"]]:not-focus-within:hover:outline-error-border aria-invalid:[&_input]:text-error-on-container aria-invalid:[&_input]:caret-error-border-strong data-[invalid]:[&_input]:text-error-on-container data-[invalid]:[&_input]:caret-error-border-strong", {
|
|
46770
|
+
}), Zue = mr("flex flex-col gap-3xs data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 [&_[role=\"group\"]]:rounded-full [&_[role=\"group\"]]:outline [&_[role=\"group\"]]:outline-transparent [&_[role=\"group\"]]:transition-all aria-invalid:[&_[role=\"group\"]]:bg-error-container aria-invalid:[&_[role=\"group\"]]:outline-error-border aria-invalid:[&_[role=\"group\"]]:focus-within:outline-error-border-strong aria-invalid:[&_[role=\"group\"]]:not-focus-within:hover:outline-error-border data-[disabled]:[&_[role=\"group\"]]:cursor-not-allowed data-[invalid]:[&_[role=\"group\"]]:bg-error-container data-[invalid]:[&_[role=\"group\"]]:outline-error-border data-[invalid]:[&_[role=\"group\"]]:focus-within:outline-error-border-strong data-[invalid]:[&_[role=\"group\"]]:not-focus-within:hover:outline-error-border aria-invalid:[&_input]:text-error-on-container aria-invalid:[&_input]:caret-error-border-strong data-[invalid]:[&_input]:text-error-on-container data-[invalid]:[&_input]:caret-error-border-strong", {
|
|
46761
46771
|
variants: {
|
|
46762
46772
|
size: {
|
|
46763
|
-
small: "[&_[role=\"group\"]]:h-lg [&
|
|
46764
|
-
medium: "[&_[role=\"group\"]]:h-xl [&
|
|
46765
|
-
large: "[&_[role=\"group\"]]:h-2xl [&
|
|
46773
|
+
small: "[&_[role=\"group\"]]:h-lg [&_input]:style-text-default--1",
|
|
46774
|
+
medium: "[&_[role=\"group\"]]:h-xl [&_input]:style-text-default-0",
|
|
46775
|
+
large: "[&_[role=\"group\"]]:h-2xl [&_input]:style-text-default-1"
|
|
46766
46776
|
},
|
|
46767
46777
|
variant: {
|
|
46768
46778
|
primary: "[&_[role=\"group\"]]:bg-surface [&_[role=\"group\"]]:shadow-2xs",
|