@layers-app/shared 0.3.8 → 0.3.9
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/ColorPicker/ColorPicker.d.ts +14 -7
- package/dist/components/ColorPicker/ColorPicker.d.ts.map +1 -1
- package/dist/components/ColorPicker/ColorPicker.js +93 -79
- package/dist/components/ColorPicker/ColorPicker.module.css.js +31 -0
- package/dist/components/ColorPicker/ColorPickerList.d.ts +6 -0
- package/dist/components/ColorPicker/ColorPickerList.d.ts.map +1 -0
- package/dist/components/ColorPicker/ColorPickerList.js +134 -0
- package/dist/components/ColorPicker/ColorPickerToolbar.d.ts +13 -0
- package/dist/components/ColorPicker/ColorPickerToolbar.d.ts.map +1 -0
- package/dist/components/ColorPicker/ColorPickerToolbar.js +132 -0
- package/dist/components/ColorPicker/icons.d.ts +11 -0
- package/dist/components/ColorPicker/icons.d.ts.map +1 -0
- package/dist/components/ColorPicker/icons.js +71 -0
- package/dist/components/ColorPicker/types.d.ts +49 -0
- package/dist/components/ColorPicker/types.d.ts.map +1 -0
- package/dist/components/ColorPicker/types.js +10 -0
- package/dist/components/ColorPicker/useRecentColors.d.ts +13 -0
- package/dist/components/ColorPicker/useRecentColors.d.ts.map +1 -0
- package/dist/components/ColorPicker/useRecentColors.js +39 -0
- package/dist/components/EmojiPicker/EmojiPicker.d.ts +1 -0
- package/dist/components/EmojiPicker/EmojiPicker.d.ts.map +1 -1
- package/dist/components/OnboardingTour/OnboardingTourWrapper.d.ts.map +1 -1
- package/dist/components/TextColorIcon.d.ts +8 -0
- package/dist/components/TextColorIcon.d.ts.map +1 -0
- package/dist/components/TextColorIcon.js +60 -0
- package/dist/config/brand.js +8 -8
- package/dist/index.css +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +509 -496
- package/package.json +2 -2
|
@@ -1,29 +1,36 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ColorSwatchProps, FlexProps } from '@mantine/core';
|
|
3
|
-
|
|
3
|
+
import { ColorPickerList } from './ColorPickerList';
|
|
4
|
+
import { ColorItem } from './types';
|
|
5
|
+
export type ColorPickerProps = {
|
|
4
6
|
ref?: React.Ref<HTMLDivElement>;
|
|
5
7
|
value?: string | null;
|
|
6
8
|
onChange?: (v: string) => void;
|
|
7
9
|
allowCustomColor?: boolean;
|
|
8
|
-
colors?:
|
|
10
|
+
colors?: ColorItem[];
|
|
9
11
|
swatchShape?: 'circle' | 'square';
|
|
12
|
+
swatchVariant?: 'filled' | 'outline';
|
|
10
13
|
withTick?: boolean;
|
|
11
14
|
fullWidth?: boolean;
|
|
12
15
|
swatchSize?: number;
|
|
13
16
|
} & Omit<FlexProps, 'onChange'>;
|
|
14
|
-
interface ColorCircleProps extends Omit<ColorSwatchProps, 'color'>, Omit<React.ComponentPropsWithoutRef<'div'>, keyof Omit<ColorSwatchProps, 'color'>> {
|
|
17
|
+
export interface ColorCircleProps extends Omit<ColorSwatchProps, 'color'>, Omit<React.ComponentPropsWithoutRef<'div'>, keyof Omit<ColorSwatchProps, 'color'>> {
|
|
15
18
|
value?: string | null;
|
|
16
19
|
isActive?: boolean;
|
|
17
20
|
swatchShape?: 'circle' | 'square';
|
|
21
|
+
swatchVariant?: 'filled' | 'outline';
|
|
18
22
|
withTick?: boolean;
|
|
23
|
+
borderColor?: string;
|
|
24
|
+
bgColor?: string;
|
|
19
25
|
}
|
|
20
|
-
export declare const ColorCircle: ({ value, isActive, swatchShape, withTick, ref, ...props }: ColorCircleProps & {
|
|
26
|
+
export declare const ColorCircle: ({ value, isActive, swatchShape, swatchVariant, withTick, borderColor, bgColor, ref, ...props }: ColorCircleProps & {
|
|
21
27
|
ref?: React.Ref<HTMLDivElement>;
|
|
22
28
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
-
export declare const ColorPicker: (({ value, onChange, allowCustomColor, colors, swatchShape, withTick, fullWidth, swatchSize, ref, ...props }: ColorPickerProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
24
|
-
ColorCircle: ({ value, isActive, swatchShape, withTick, ref, ...props }: ColorCircleProps & {
|
|
29
|
+
export declare const ColorPicker: (({ value, onChange, allowCustomColor, colors, swatchShape, swatchVariant, withTick, fullWidth, swatchSize, ref, ...props }: ColorPickerProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
30
|
+
ColorCircle: ({ value, isActive, swatchShape, swatchVariant, withTick, borderColor, bgColor, ref, ...props }: ColorCircleProps & {
|
|
25
31
|
ref?: React.Ref<HTMLDivElement>;
|
|
26
32
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
List: typeof ColorPickerList;
|
|
34
|
+
Toolbar: React.ForwardRefExoticComponent<import("./ColorPickerToolbar").ColorPickerToolbarProps & React.RefAttributes<HTMLDivElement>>;
|
|
27
35
|
};
|
|
28
|
-
export {};
|
|
29
36
|
//# sourceMappingURL=ColorPicker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPicker.d.ts","sourceRoot":"","sources":["../../../src/components/ColorPicker/ColorPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAKxC,OAAO,EAIL,gBAAgB,EAEhB,SAAS,EAKV,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ColorPicker.d.ts","sourceRoot":"","sources":["../../../src/components/ColorPicker/ColorPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAKxC,OAAO,EAIL,gBAAgB,EAEhB,SAAS,EAKV,MAAM,eAAe,CAAC;AAKvB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAsB,MAAM,SAAS,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAClC,aAAa,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAkGhC,MAAM,WAAW,gBACf,SAAQ,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,EACrC,IAAI,CACF,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,EACrC,MAAM,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CACtC;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAClC,aAAa,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,WAAW,GAAI,gGAUzB,gBAAgB,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;CAAE,4CA4DxD,CAAC;AASF,eAAO,MAAM,WAAW,+HAlLrB,gBAAgB;kHA6GhB,gBAAgB,GAAG;QAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;KAAE;;;CAyEvD,CAAC"}
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { useTranslation as
|
|
4
|
-
import { Tick02Icon as
|
|
5
|
-
import { HugeiconsIcon as
|
|
6
|
-
import { useMantineTheme as
|
|
7
|
-
import { IconPalette as
|
|
8
|
-
import
|
|
9
|
-
import { DEFAULT_VALUES as
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { jsx as r, jsxs as b } from "react/jsx-runtime";
|
|
2
|
+
import { useState as k } from "react";
|
|
3
|
+
import { useTranslation as j } from "react-i18next";
|
|
4
|
+
import { Tick02Icon as A } from "@hugeicons/core-free-icons";
|
|
5
|
+
import { HugeiconsIcon as E } from "@hugeicons/react";
|
|
6
|
+
import { useMantineTheme as I, getThemeColor as y, Flex as x, Tooltip as R, ColorSwatch as U, parseThemeColor as V, ColorInput as D, ActionIcon as w } from "@mantine/core";
|
|
7
|
+
import { IconPalette as F, IconPencil as H } from "@tabler/icons-react";
|
|
8
|
+
import M from "styled-components";
|
|
9
|
+
import { DEFAULT_VALUES as C } from "../../constants.js";
|
|
10
|
+
import { ColorPickerList as q } from "./ColorPickerList.js";
|
|
11
|
+
import { ColorPickerToolbar as _ } from "./ColorPickerToolbar.js";
|
|
12
|
+
import { normalizeColorItem as B } from "./types.js";
|
|
13
|
+
const G = ({
|
|
14
|
+
value: o,
|
|
15
|
+
onChange: e,
|
|
16
|
+
allowCustomColor: n,
|
|
14
17
|
colors: s,
|
|
15
|
-
swatchShape:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
swatchShape: a = "circle",
|
|
19
|
+
swatchVariant: m = "filled",
|
|
20
|
+
withTick: p = !1,
|
|
21
|
+
fullWidth: d = !1,
|
|
22
|
+
swatchSize: u = 30,
|
|
23
|
+
ref: c,
|
|
24
|
+
...f
|
|
21
25
|
}) => {
|
|
22
|
-
const
|
|
23
|
-
color:
|
|
24
|
-
theme:
|
|
25
|
-
}), [
|
|
26
|
-
return
|
|
27
|
-
/* @__PURE__ */
|
|
28
|
-
|
|
26
|
+
const t = I(), i = V({
|
|
27
|
+
color: o || C.COLORS[0],
|
|
28
|
+
theme: t
|
|
29
|
+
}), [h, O] = k(i.value), [P, g] = k(!1);
|
|
30
|
+
return P ? /* @__PURE__ */ b(x, { align: "center", mih: 30, children: [
|
|
31
|
+
/* @__PURE__ */ r(
|
|
32
|
+
D,
|
|
29
33
|
{
|
|
30
34
|
w: "100%",
|
|
31
35
|
popoverProps: {
|
|
@@ -35,84 +39,92 @@ const D = ({
|
|
|
35
39
|
maxLength: 7,
|
|
36
40
|
withEyeDropper: !1,
|
|
37
41
|
size: "xs",
|
|
38
|
-
value:
|
|
39
|
-
onChange:
|
|
40
|
-
onChangeEnd:
|
|
42
|
+
value: h,
|
|
43
|
+
onChange: O,
|
|
44
|
+
onChangeEnd: e,
|
|
41
45
|
placeholder: "Select custom color"
|
|
42
46
|
}
|
|
43
47
|
),
|
|
44
|
-
/* @__PURE__ */
|
|
45
|
-
|
|
48
|
+
/* @__PURE__ */ r(
|
|
49
|
+
w,
|
|
46
50
|
{
|
|
47
51
|
radius: "xl",
|
|
48
52
|
variant: "default",
|
|
49
53
|
color: "gray",
|
|
50
|
-
onClick: () =>
|
|
51
|
-
children: /* @__PURE__ */
|
|
54
|
+
onClick: () => g(!1),
|
|
55
|
+
children: /* @__PURE__ */ r(F, { size: 16 })
|
|
52
56
|
}
|
|
53
57
|
)
|
|
54
|
-
] }, 1) : /* @__PURE__ */
|
|
55
|
-
|
|
58
|
+
] }, 1) : /* @__PURE__ */ b(
|
|
59
|
+
x,
|
|
56
60
|
{
|
|
57
|
-
ref:
|
|
58
|
-
...
|
|
59
|
-
justify:
|
|
61
|
+
ref: c,
|
|
62
|
+
...f,
|
|
63
|
+
justify: d ? "space-between" : "flex-start",
|
|
60
64
|
align: "center",
|
|
61
65
|
mih: 32,
|
|
62
66
|
children: [
|
|
63
|
-
(s ||
|
|
64
|
-
const
|
|
65
|
-
return /* @__PURE__ */
|
|
66
|
-
|
|
67
|
+
(s || C.COLORS).map((S, T) => {
|
|
68
|
+
const { value: l, border: $, bg: z } = B(S), v = l === o || !o && l === C.COLORS[0];
|
|
69
|
+
return /* @__PURE__ */ r(
|
|
70
|
+
J,
|
|
67
71
|
{
|
|
68
|
-
value:
|
|
69
|
-
isActive:
|
|
70
|
-
size:
|
|
71
|
-
swatchShape:
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
value: l,
|
|
73
|
+
isActive: v,
|
|
74
|
+
size: u - 4,
|
|
75
|
+
swatchShape: a,
|
|
76
|
+
swatchVariant: m,
|
|
77
|
+
withTick: p,
|
|
78
|
+
borderColor: $,
|
|
79
|
+
bgColor: z,
|
|
80
|
+
onClick: () => e?.(l)
|
|
74
81
|
},
|
|
75
|
-
|
|
82
|
+
l || T
|
|
76
83
|
);
|
|
77
84
|
}),
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
n && /* @__PURE__ */ r(
|
|
86
|
+
w,
|
|
80
87
|
{
|
|
81
88
|
radius: "xl",
|
|
82
89
|
variant: "default",
|
|
83
90
|
color: "gray",
|
|
84
|
-
onClick: () =>
|
|
85
|
-
children: /* @__PURE__ */
|
|
91
|
+
onClick: () => g(!0),
|
|
92
|
+
children: /* @__PURE__ */ r(H, { size: 16 })
|
|
86
93
|
}
|
|
87
94
|
)
|
|
88
95
|
]
|
|
89
96
|
},
|
|
90
97
|
2
|
|
91
98
|
);
|
|
92
|
-
},
|
|
93
|
-
value:
|
|
94
|
-
isActive:
|
|
95
|
-
swatchShape:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
}, L = ({
|
|
100
|
+
value: o,
|
|
101
|
+
isActive: e,
|
|
102
|
+
swatchShape: n,
|
|
103
|
+
swatchVariant: s = "filled",
|
|
104
|
+
withTick: a,
|
|
105
|
+
borderColor: m,
|
|
106
|
+
bgColor: p,
|
|
107
|
+
ref: d,
|
|
108
|
+
...u
|
|
99
109
|
}) => {
|
|
100
|
-
const
|
|
101
|
-
defaultValue:
|
|
110
|
+
const c = I(), { t: f } = j("ui"), t = s === "outline", i = o ? y(o, c) : "", h = o ? f(`colorPicker.colors.${o}`, {
|
|
111
|
+
defaultValue: o.charAt(0).toUpperCase() + o.slice(1)
|
|
102
112
|
}) : "";
|
|
103
|
-
return /* @__PURE__ */
|
|
104
|
-
|
|
113
|
+
return /* @__PURE__ */ r(x, { miw: 32, justify: "center", align: "center", children: /* @__PURE__ */ r(R, { label: h, withArrow: !0, children: /* @__PURE__ */ b(
|
|
114
|
+
U,
|
|
105
115
|
{
|
|
106
|
-
ref:
|
|
107
|
-
color:
|
|
108
|
-
radius:
|
|
116
|
+
ref: d,
|
|
117
|
+
color: t ? "transparent" : i,
|
|
118
|
+
radius: n === "circle" ? "xl" : "sm",
|
|
109
119
|
style: {
|
|
110
120
|
cursor: "pointer",
|
|
111
|
-
color: "var(--mantine-color-white)"
|
|
121
|
+
color: "var(--mantine-color-white)",
|
|
122
|
+
background: t ? p || `var(--mantine-color-${o}-light, ${i}20)` : void 0,
|
|
123
|
+
border: t ? `2px solid ${m || `var(--mantine-color-${o}-outline, ${i})`}` : void 0
|
|
112
124
|
},
|
|
113
|
-
...
|
|
125
|
+
...u,
|
|
114
126
|
children: [
|
|
115
|
-
|
|
127
|
+
e && /* @__PURE__ */ r(
|
|
116
128
|
"span",
|
|
117
129
|
{
|
|
118
130
|
style: {
|
|
@@ -121,25 +133,27 @@ const D = ({
|
|
|
121
133
|
left: -4,
|
|
122
134
|
right: -4,
|
|
123
135
|
bottom: -4,
|
|
124
|
-
border: `2px solid ${
|
|
125
|
-
borderRadius:
|
|
136
|
+
border: `2px solid ${o ? y(o, c) : ""}`,
|
|
137
|
+
borderRadius: n === "circle" ? "var(--mantine-radius-xl)" : "var(--mantine-radius-sm)",
|
|
126
138
|
pointerEvents: "none",
|
|
127
139
|
boxSizing: "border-box"
|
|
128
140
|
}
|
|
129
141
|
}
|
|
130
142
|
),
|
|
131
|
-
|
|
143
|
+
a && e && /* @__PURE__ */ r(E, { size: 20, icon: A })
|
|
132
144
|
]
|
|
133
145
|
}
|
|
134
146
|
) }) });
|
|
135
|
-
},
|
|
147
|
+
}, J = M(L)`
|
|
136
148
|
.mantine-ColorSwatch-colorOverlay {
|
|
137
|
-
border-radius: ${({ swatchShape:
|
|
149
|
+
border-radius: ${({ swatchShape: o }) => o === "square" ? "3px" : "50%"};
|
|
138
150
|
}
|
|
139
|
-
`,
|
|
140
|
-
ColorCircle:
|
|
151
|
+
`, lo = Object.assign(G, {
|
|
152
|
+
ColorCircle: L,
|
|
153
|
+
List: q,
|
|
154
|
+
Toolbar: _
|
|
141
155
|
});
|
|
142
156
|
export {
|
|
143
|
-
|
|
144
|
-
|
|
157
|
+
L as ColorCircle,
|
|
158
|
+
lo as ColorPicker
|
|
145
159
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const t = "_section_ux1w4_2", i = "_sectionLabel_ux1w4_15", n = "_listItem_ux1w4_46", e = "_listItemActive_ux1w4_72", c = "_listItemLabel_ux1w4_76", l = "_listItemSwatch_ux1w4_84", _ = "_grid_ux1w4_92", s = "_inlineSection_ux1w4_162", o = "_inlineSectionLabel_ux1w4_172", w = "_inlineRow_ux1w4_180", a = "_inlineSwatch_ux1w4_189", S = "_inlineSwatchActive_ux1w4_214", u = "_inlineSwatchRound_ux1w4_220", x = {
|
|
2
|
+
section: t,
|
|
3
|
+
sectionLabel: i,
|
|
4
|
+
listItem: n,
|
|
5
|
+
listItemActive: e,
|
|
6
|
+
listItemLabel: c,
|
|
7
|
+
listItemSwatch: l,
|
|
8
|
+
grid: _,
|
|
9
|
+
inlineSection: s,
|
|
10
|
+
inlineSectionLabel: o,
|
|
11
|
+
inlineRow: w,
|
|
12
|
+
inlineSwatch: a,
|
|
13
|
+
inlineSwatchActive: S,
|
|
14
|
+
inlineSwatchRound: u
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
x as default,
|
|
18
|
+
_ as grid,
|
|
19
|
+
w as inlineRow,
|
|
20
|
+
s as inlineSection,
|
|
21
|
+
o as inlineSectionLabel,
|
|
22
|
+
a as inlineSwatch,
|
|
23
|
+
S as inlineSwatchActive,
|
|
24
|
+
u as inlineSwatchRound,
|
|
25
|
+
n as listItem,
|
|
26
|
+
e as listItemActive,
|
|
27
|
+
c as listItemLabel,
|
|
28
|
+
l as listItemSwatch,
|
|
29
|
+
t as section,
|
|
30
|
+
i as sectionLabel
|
|
31
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ColorPickerListProps } from './types';
|
|
2
|
+
/** Vertical list or multi-column grid with sections.
|
|
3
|
+
* Use in drawers, mobile menus, slash-menu dropdowns.
|
|
4
|
+
* columns=1 (default) = vertical list, columns=2+ = grid layout. */
|
|
5
|
+
export declare function ColorPickerList({ sections, colors, value, onChange, columns, withRecentColors, }: ColorPickerListProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=ColorPickerList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorPickerList.d.ts","sourceRoot":"","sources":["../../../src/components/ColorPicker/ColorPickerList.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,oBAAoB,EAAgB,MAAM,SAAS,CAAC;AA8GlE;;oEAEoE;AACpE,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,MAAM,EACN,KAAK,EACL,QAAQ,EACR,OAAW,EACX,gBAAgB,GACjB,EAAE,oBAAoB,2CA4CtB"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { jsxs as y, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { Tick02Icon as C } from "@hugeicons/core-free-icons";
|
|
3
|
+
import { HugeiconsIcon as I } from "@hugeicons/react";
|
|
4
|
+
import { useMantineColorScheme as g, Box as k, useMantineTheme as x, getThemeColor as F, ColorSwatch as N } from "@mantine/core";
|
|
5
|
+
import { TextColorIcon as S } from "./icons.js";
|
|
6
|
+
import { isDefaultColor as b, normalizeColorItem as L } from "./types.js";
|
|
7
|
+
import { useRecentColors as T } from "./useRecentColors.js";
|
|
8
|
+
import i from "./ColorPicker.module.css.js";
|
|
9
|
+
function z({
|
|
10
|
+
type: e,
|
|
11
|
+
colorValue: l,
|
|
12
|
+
resolvedColor: a,
|
|
13
|
+
border: s,
|
|
14
|
+
bg: c
|
|
15
|
+
}) {
|
|
16
|
+
if (e === "text")
|
|
17
|
+
return /* @__PURE__ */ t(
|
|
18
|
+
S,
|
|
19
|
+
{
|
|
20
|
+
size: 16,
|
|
21
|
+
color: a,
|
|
22
|
+
showBorder: !0
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
const n = b(l);
|
|
26
|
+
return /* @__PURE__ */ t(
|
|
27
|
+
N,
|
|
28
|
+
{
|
|
29
|
+
color: n ? "var(--mantine-color-body)" : c || s || l,
|
|
30
|
+
size: 16,
|
|
31
|
+
radius: "xl",
|
|
32
|
+
className: i.listItemSwatch,
|
|
33
|
+
styles: {
|
|
34
|
+
root: {
|
|
35
|
+
border: `1.5px solid ${n ? "var(--mantine-color-default-border)" : s || a}`
|
|
36
|
+
},
|
|
37
|
+
alphaOverlay: { display: "none" },
|
|
38
|
+
shadowOverlay: { display: "none" }
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
function v({
|
|
44
|
+
section: e,
|
|
45
|
+
columns: l,
|
|
46
|
+
onChange: a,
|
|
47
|
+
isDark: s
|
|
48
|
+
}) {
|
|
49
|
+
const c = x(), n = l > 1;
|
|
50
|
+
return /* @__PURE__ */ y("div", { className: i.section, children: [
|
|
51
|
+
e.label && /* @__PURE__ */ t("div", { className: i.sectionLabel, children: e.label }),
|
|
52
|
+
/* @__PURE__ */ t(
|
|
53
|
+
"div",
|
|
54
|
+
{
|
|
55
|
+
className: n ? i.grid : void 0,
|
|
56
|
+
style: n ? { gridTemplateColumns: `repeat(${l}, minmax(0, 1fr))` } : void 0,
|
|
57
|
+
children: e.colors.map((p) => {
|
|
58
|
+
const { value: r, label: m, border: f, bg: d } = L(p), h = b(r), o = r === e.value, u = h ? s ? "#FFFFFF" : "#000000" : F(r, c);
|
|
59
|
+
return /* @__PURE__ */ y(
|
|
60
|
+
"button",
|
|
61
|
+
{
|
|
62
|
+
type: "button",
|
|
63
|
+
className: `${i.listItem} ${o ? i.listItemActive : ""}`,
|
|
64
|
+
onClick: () => a(r, e.key),
|
|
65
|
+
children: [
|
|
66
|
+
/* @__PURE__ */ t(
|
|
67
|
+
z,
|
|
68
|
+
{
|
|
69
|
+
type: e.type,
|
|
70
|
+
colorValue: r,
|
|
71
|
+
resolvedColor: u,
|
|
72
|
+
border: f,
|
|
73
|
+
bg: d
|
|
74
|
+
}
|
|
75
|
+
),
|
|
76
|
+
/* @__PURE__ */ t("span", { className: i.listItemLabel, children: m }),
|
|
77
|
+
o && /* @__PURE__ */ t(
|
|
78
|
+
I,
|
|
79
|
+
{
|
|
80
|
+
size: 16,
|
|
81
|
+
icon: C,
|
|
82
|
+
color: "var(--mantine-primary-color-filled)"
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
r
|
|
88
|
+
);
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
] });
|
|
93
|
+
}
|
|
94
|
+
function R({
|
|
95
|
+
sections: e,
|
|
96
|
+
colors: l,
|
|
97
|
+
value: a,
|
|
98
|
+
onChange: s,
|
|
99
|
+
columns: c = 1,
|
|
100
|
+
withRecentColors: n
|
|
101
|
+
}) {
|
|
102
|
+
const { colorScheme: p } = g(), r = p === "dark", { recentColors: m, addRecent: f } = T(), d = (o, u) => {
|
|
103
|
+
n && f(o, u), s?.(o, u);
|
|
104
|
+
}, h = e || (l ? [{ key: "default", label: "", colors: l, value: a }] : []);
|
|
105
|
+
return /* @__PURE__ */ y(k, { children: [
|
|
106
|
+
n && m.length > 0 && /* @__PURE__ */ t(
|
|
107
|
+
v,
|
|
108
|
+
{
|
|
109
|
+
section: {
|
|
110
|
+
key: "__recent",
|
|
111
|
+
label: "Recently used",
|
|
112
|
+
colors: m.map((o) => o.value),
|
|
113
|
+
value: a
|
|
114
|
+
},
|
|
115
|
+
columns: 1,
|
|
116
|
+
onChange: d,
|
|
117
|
+
isDark: r
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
h.map((o) => /* @__PURE__ */ t(
|
|
121
|
+
v,
|
|
122
|
+
{
|
|
123
|
+
section: o,
|
|
124
|
+
columns: c,
|
|
125
|
+
onChange: d,
|
|
126
|
+
isDark: r
|
|
127
|
+
},
|
|
128
|
+
o.key
|
|
129
|
+
))
|
|
130
|
+
] });
|
|
131
|
+
}
|
|
132
|
+
export {
|
|
133
|
+
R as ColorPickerList
|
|
134
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ColorPickerOnChange, ColorSection } from './types';
|
|
2
|
+
/** Toolbar dropdown with text colors (A icons) + highlights (circles) + recently used.
|
|
3
|
+
* Use inside Menu.Dropdown, Popover, or floating toolbar. */
|
|
4
|
+
export interface ColorPickerToolbarProps {
|
|
5
|
+
sections: ColorSection[];
|
|
6
|
+
onChange: ColorPickerOnChange;
|
|
7
|
+
withRecentColors?: boolean;
|
|
8
|
+
maxRecentColors?: number;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
recentColorsLabel?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const ColorPickerToolbar: import("react").ForwardRefExoticComponent<ColorPickerToolbarProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
13
|
+
//# sourceMappingURL=ColorPickerToolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorPickerToolbar.d.ts","sourceRoot":"","sources":["../../../src/components/ColorPicker/ColorPickerToolbar.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMjE;6DAC6D;AAC7D,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AA4BD,eAAO,MAAM,kBAAkB,oHAuJ7B,CAAC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { jsxs as C, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as D, useState as M, useCallback as w, useMemo as T } from "react";
|
|
3
|
+
import { useMantineColorScheme as z, Box as u, Flex as x, UnstyledButton as H } from "@mantine/core";
|
|
4
|
+
import { TextColorIcon as F, HighlightSwatch as N } from "./icons.js";
|
|
5
|
+
import { isDefaultColor as I, normalizeColorItem as L } from "./types.js";
|
|
6
|
+
import { useRecentColors as j } from "./useRecentColors.js";
|
|
7
|
+
import t from "./ColorPicker.module.css.js";
|
|
8
|
+
function k({
|
|
9
|
+
isActive: i,
|
|
10
|
+
round: m,
|
|
11
|
+
disabled: a,
|
|
12
|
+
onClick: h,
|
|
13
|
+
children: c
|
|
14
|
+
}) {
|
|
15
|
+
return /* @__PURE__ */ o(
|
|
16
|
+
H,
|
|
17
|
+
{
|
|
18
|
+
type: "button",
|
|
19
|
+
className: `${t.inlineSwatch}${m ? ` ${t.inlineSwatchRound}` : ""}${i ? ` ${t.inlineSwatchActive}` : ""}`,
|
|
20
|
+
onMouseDown: (p) => p.preventDefault(),
|
|
21
|
+
onClick: h,
|
|
22
|
+
disabled: a,
|
|
23
|
+
children: c
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
const Q = D(({ sections: i, onChange: m, withRecentColors: a, maxRecentColors: h = 9, disabled: c, recentColorsLabel: p = "Recently used" }, R) => {
|
|
28
|
+
const { colorScheme: y } = z(), S = y === "dark", { recentColors: B, addRecent: g } = j({ maxItems: h }), [v, K] = M(B), d = w(
|
|
29
|
+
(e, r, n) => {
|
|
30
|
+
a && (g(e, r, n), K((l) => {
|
|
31
|
+
const f = l.filter(
|
|
32
|
+
(s) => !(s.value === e && s.sectionKey === r)
|
|
33
|
+
);
|
|
34
|
+
return [{ value: e, sectionKey: r, border: n }, ...f].slice(0, h);
|
|
35
|
+
})), m(e, r);
|
|
36
|
+
},
|
|
37
|
+
[m, a, g]
|
|
38
|
+
), A = T(() => {
|
|
39
|
+
const e = {};
|
|
40
|
+
for (const r of i) e[r.key] = r;
|
|
41
|
+
return e;
|
|
42
|
+
}, [i]), b = w(
|
|
43
|
+
(e) => I(e) ? S ? "#FFFFFF" : "#000000" : e,
|
|
44
|
+
[S]
|
|
45
|
+
);
|
|
46
|
+
return /* @__PURE__ */ C(u, { ref: R, children: [
|
|
47
|
+
a && v.length > 0 && /* @__PURE__ */ C(u, { className: t.inlineSection, children: [
|
|
48
|
+
/* @__PURE__ */ o(u, { className: t.inlineSectionLabel, children: p }),
|
|
49
|
+
/* @__PURE__ */ o(x, { className: t.inlineRow, gap: 2, children: v.map((e, r) => {
|
|
50
|
+
const n = e.sectionKey ? A[e.sectionKey] : void 0;
|
|
51
|
+
return n?.key === "textColor" || n?.key === "color" || e.sectionKey === "color" ? /* @__PURE__ */ o(
|
|
52
|
+
k,
|
|
53
|
+
{
|
|
54
|
+
isActive: !1,
|
|
55
|
+
disabled: c,
|
|
56
|
+
onClick: () => d(e.value, e.sectionKey ?? ""),
|
|
57
|
+
children: /* @__PURE__ */ o(
|
|
58
|
+
F,
|
|
59
|
+
{
|
|
60
|
+
size: 20,
|
|
61
|
+
color: b(e.value),
|
|
62
|
+
showBorder: !0
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
},
|
|
66
|
+
`${e.sectionKey}-${e.value}-${r}`
|
|
67
|
+
) : /* @__PURE__ */ o(
|
|
68
|
+
k,
|
|
69
|
+
{
|
|
70
|
+
isActive: !1,
|
|
71
|
+
round: !0,
|
|
72
|
+
disabled: c,
|
|
73
|
+
onClick: () => d(e.value, e.sectionKey ?? ""),
|
|
74
|
+
children: /* @__PURE__ */ o(
|
|
75
|
+
N,
|
|
76
|
+
{
|
|
77
|
+
bgColor: e.value,
|
|
78
|
+
borderColor: e.border || "var(--mantine-color-default-border)"
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
},
|
|
82
|
+
`${e.sectionKey}-${e.value}-${r}`
|
|
83
|
+
);
|
|
84
|
+
}) })
|
|
85
|
+
] }),
|
|
86
|
+
i.map((e) => {
|
|
87
|
+
const r = e.key === "highlight" || e.key === "background" || e.key === "textHighlight";
|
|
88
|
+
return /* @__PURE__ */ C(u, { className: t.inlineSection, children: [
|
|
89
|
+
e.label && /* @__PURE__ */ o(u, { className: t.inlineSectionLabel, children: e.label }),
|
|
90
|
+
/* @__PURE__ */ o(x, { className: t.inlineRow, gap: 2, children: e.colors.map((n) => {
|
|
91
|
+
const { value: l, border: f } = L(n), s = l === e.value, $ = b(l);
|
|
92
|
+
return r ? /* @__PURE__ */ o(
|
|
93
|
+
k,
|
|
94
|
+
{
|
|
95
|
+
isActive: s,
|
|
96
|
+
round: !0,
|
|
97
|
+
disabled: c,
|
|
98
|
+
onClick: () => d(l, e.key, f),
|
|
99
|
+
children: /* @__PURE__ */ o(
|
|
100
|
+
N,
|
|
101
|
+
{
|
|
102
|
+
bgColor: l,
|
|
103
|
+
borderColor: f || $
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
},
|
|
107
|
+
l
|
|
108
|
+
) : /* @__PURE__ */ o(
|
|
109
|
+
k,
|
|
110
|
+
{
|
|
111
|
+
isActive: s,
|
|
112
|
+
disabled: c,
|
|
113
|
+
onClick: () => d(l, e.key),
|
|
114
|
+
children: /* @__PURE__ */ o(
|
|
115
|
+
F,
|
|
116
|
+
{
|
|
117
|
+
size: 20,
|
|
118
|
+
color: $,
|
|
119
|
+
showBorder: !0
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
},
|
|
123
|
+
l
|
|
124
|
+
);
|
|
125
|
+
}) })
|
|
126
|
+
] }, e.key);
|
|
127
|
+
})
|
|
128
|
+
] });
|
|
129
|
+
});
|
|
130
|
+
export {
|
|
131
|
+
Q as ColorPickerToolbar
|
|
132
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function TextColorIcon({ size, color, showBorder, }: {
|
|
2
|
+
size?: number;
|
|
3
|
+
color?: string;
|
|
4
|
+
showBorder?: boolean;
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function HighlightSwatch({ size, bgColor, borderColor, }: {
|
|
7
|
+
size?: number;
|
|
8
|
+
bgColor: string;
|
|
9
|
+
borderColor: string;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=icons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../../src/components/ColorPicker/icons.tsx"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,EAC5B,IAAS,EACT,KAAoC,EACpC,UAAU,GACX,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,2CAgCA;AAED,wBAAgB,eAAe,CAAC,EAC9B,IAAS,EACT,OAAO,EACP,WAAW,GACZ,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB,2CA4BA"}
|