@quidgest/ui 0.16.33 → 0.16.35
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/json/api.json +1 -1
- package/dist/ui.esm.js +3049 -2945
- package/dist/ui.js +19 -19
- package/dist/ui.min.js +1074 -1061
- package/dist/ui.scss +1 -1
- package/esm/components/QColorPicker/QColorPicker.vue.js +1 -1
- package/esm/components/QToast/QToast.vue.js +44 -42
- package/esm/composables/useColor/index.js +23 -20
- package/esm/index.d.ts +2 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +8 -6
- package/esm/templates/theme.d.ts.map +1 -1
- package/esm/templates/theme.js +44 -10
- package/esm/utils/color/contrast.d.ts +18 -0
- package/esm/utils/color/contrast.d.ts.map +1 -0
- package/esm/utils/color/contrast.js +13 -0
- package/esm/utils/color/conversion.d.ts +41 -0
- package/esm/utils/color/conversion.d.ts.map +1 -0
- package/esm/utils/color/conversion.js +59 -0
- package/esm/utils/color/index.d.ts +7 -0
- package/esm/utils/color/index.d.ts.map +1 -0
- package/esm/utils/color/manipulate.d.ts +18 -0
- package/esm/utils/color/manipulate.d.ts.map +1 -0
- package/esm/utils/color/manipulate.js +21 -0
- package/esm/utils/color/merge.d.ts +19 -0
- package/esm/utils/color/merge.d.ts.map +1 -0
- package/esm/utils/color/merge.js +49 -0
- package/esm/utils/color/parse.d.ts +24 -0
- package/esm/utils/color/parse.d.ts.map +1 -0
- package/esm/utils/color/parse.js +26 -0
- package/esm/utils/color/types.d.ts +51 -0
- package/esm/utils/color/types.d.ts.map +1 -0
- package/esm/utils/index.d.ts +2 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/index.js +20 -0
- package/esm/utils/theme.js +1 -1
- package/package.json +3 -1
- package/esm/utils/color.d.ts +0 -123
- package/esm/utils/color.d.ts.map +0 -1
- package/esm/utils/color.js +0 -97
package/dist/ui.scss
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as h, mergeModels as C, useModel as k, ref as p, computed as V, watch as m, createBlock as $, openBlock as g, unref as q, normalizeClass as B, createSlots as T, withCtx as t, renderSlot as r, withDirectives as x, createElementVNode as z, mergeProps as M, withModifiers as S, vModelText as w } from "vue";
|
|
2
2
|
import { DEFAULT_TEXTS as D } from "./types.js";
|
|
3
3
|
import { QTextField as E } from "../QTextField/index.js";
|
|
4
|
-
import { isValidHex as F } from "../../utils/color.js";
|
|
4
|
+
import { isValidHex as F } from "../../utils/color/parse.js";
|
|
5
5
|
const P = ["readonly", "disabled", "aria-label"], I = /* @__PURE__ */ h({
|
|
6
6
|
inheritAttrs: !1,
|
|
7
7
|
__name: "QColorPicker",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as U, toRef as j, computed as d, onMounted as A, onUnmounted as D, createBlock as
|
|
1
|
+
import { defineComponent as U, toRef as j, computed as d, onMounted as A, onUnmounted as D, createBlock as b, openBlock as h, unref as e, normalizeStyle as E, normalizeClass as H, createSlots as M, withCtx as l, createVNode as i, createCommentVNode as p, renderSlot as r, createElementVNode as v, toDisplayString as y, normalizeProps as k, guardReactiveProps as q } from "vue";
|
|
2
2
|
import { DEFAULT_ICONS as P } from "./types.js";
|
|
3
3
|
import { QButton as w } from "../QButton/index.js";
|
|
4
4
|
import { QCard as F } from "../QCard/index.js";
|
|
@@ -6,8 +6,10 @@ import { QContainer as T, QRow as $, QCol as c } from "../QGrid/index.js";
|
|
|
6
6
|
import { QIcon as g } from "../QIcon/index.js";
|
|
7
7
|
import { useTheme as L } from "../../composables/theme.js";
|
|
8
8
|
import { useColor as O } from "../../composables/useColor/index.js";
|
|
9
|
-
import {
|
|
10
|
-
|
|
9
|
+
import { lighten as x } from "../../utils/color/manipulate.js";
|
|
10
|
+
import { parseColor as G } from "../../utils/color/parse.js";
|
|
11
|
+
import { rgbToHex as J } from "../../utils/color/conversion.js";
|
|
12
|
+
const K = { class: "q-toast__title" }, at = /* @__PURE__ */ U({
|
|
11
13
|
__name: "QToast",
|
|
12
14
|
props: {
|
|
13
15
|
id: {},
|
|
@@ -23,50 +25,50 @@ const K = { class: "q-toast__title" }, nt = /* @__PURE__ */ U({
|
|
|
23
25
|
},
|
|
24
26
|
emits: ["dismiss"],
|
|
25
27
|
setup(Q, { emit: V }) {
|
|
26
|
-
const t = Q, S = V, B = L(), { isUtilityColor:
|
|
27
|
-
const o =
|
|
28
|
+
const t = Q, S = V, B = L(), { isUtilityColor: m, style: u } = O(j(t, "color")), N = d(() => {
|
|
29
|
+
const o = m.value ? `q-toast--${t.color}` : void 0, s = t.block ? "q-toast--block" : void 0, n = t.title ? "q-toast--vertical" : void 0;
|
|
28
30
|
return [
|
|
29
31
|
"q-toast",
|
|
30
32
|
`q-toast--${t.variant}`,
|
|
31
33
|
o,
|
|
34
|
+
s,
|
|
32
35
|
n,
|
|
33
|
-
i,
|
|
34
36
|
t.class
|
|
35
37
|
];
|
|
36
38
|
}), C = d(() => {
|
|
37
|
-
var
|
|
38
|
-
const o =
|
|
39
|
+
var n;
|
|
40
|
+
const o = m.value ? R(t.color) : (n = u.value) == null ? void 0 : n.mainColor;
|
|
39
41
|
if (!o) return;
|
|
40
|
-
const
|
|
41
|
-
return
|
|
42
|
+
const s = G(o);
|
|
43
|
+
return J(x(s, 88));
|
|
42
44
|
}), z = d(() => {
|
|
43
|
-
var o,
|
|
44
|
-
return
|
|
45
|
+
var o, s, n;
|
|
46
|
+
return m.value ? {
|
|
45
47
|
"--q-toast-tonal-color": C.value
|
|
46
48
|
} : {
|
|
47
49
|
"--q-toast-main-color": (o = u.value) == null ? void 0 : o.mainColor,
|
|
48
|
-
"--q-toast-on-main-color": (
|
|
49
|
-
"--q-toast-hover-color": (
|
|
50
|
+
"--q-toast-on-main-color": (s = u.value) == null ? void 0 : s.onMainColor,
|
|
51
|
+
"--q-toast-hover-color": (n = u.value) == null ? void 0 : n.hoverColor,
|
|
50
52
|
"--q-toast-tonal-color": C.value
|
|
51
53
|
};
|
|
52
54
|
}), _ = d(() => t.variant === "bold" ? "bold" : "ghost");
|
|
53
55
|
let a;
|
|
54
|
-
function
|
|
56
|
+
function f() {
|
|
55
57
|
a !== void 0 && window.clearTimeout(a), S("dismiss");
|
|
56
58
|
}
|
|
57
59
|
function I() {
|
|
58
|
-
a = window.setTimeout(
|
|
60
|
+
a = window.setTimeout(f, t.timeout);
|
|
59
61
|
}
|
|
60
62
|
function R(o) {
|
|
61
|
-
const
|
|
62
|
-
if (o in
|
|
63
|
-
return
|
|
63
|
+
const s = B.current.value.scheme;
|
|
64
|
+
if (o in s)
|
|
65
|
+
return s[o];
|
|
64
66
|
}
|
|
65
67
|
return A(() => {
|
|
66
68
|
t.timeout > 0 && I();
|
|
67
69
|
}), D(() => {
|
|
68
70
|
a !== void 0 && window.clearTimeout(a);
|
|
69
|
-
}), (o,
|
|
71
|
+
}), (o, s) => (h(), b(e(F), {
|
|
70
72
|
id: t.id,
|
|
71
73
|
elevation: t.elevation,
|
|
72
74
|
width: t.block ? "block" : void 0,
|
|
@@ -74,23 +76,23 @@ const K = { class: "q-toast__title" }, nt = /* @__PURE__ */ U({
|
|
|
74
76
|
style: E(z.value)
|
|
75
77
|
}, M({
|
|
76
78
|
default: l(() => [
|
|
77
|
-
|
|
79
|
+
i(e(T), {
|
|
78
80
|
fluid: "",
|
|
79
81
|
class: "q-toast__body"
|
|
80
82
|
}, {
|
|
81
83
|
default: l(() => [
|
|
82
|
-
|
|
84
|
+
i(e($), {
|
|
83
85
|
align: "center",
|
|
84
86
|
justify: "between"
|
|
85
87
|
}, {
|
|
86
88
|
default: l(() => [
|
|
87
|
-
|
|
89
|
+
i(e(c), null, {
|
|
88
90
|
default: l(() => [
|
|
89
91
|
r(o.$slots, "default", {}, () => [
|
|
90
|
-
|
|
92
|
+
v(
|
|
91
93
|
"span",
|
|
92
94
|
null,
|
|
93
|
-
|
|
95
|
+
y(t.text),
|
|
94
96
|
1
|
|
95
97
|
/* TEXT */
|
|
96
98
|
)
|
|
@@ -99,20 +101,20 @@ const K = { class: "q-toast__title" }, nt = /* @__PURE__ */ U({
|
|
|
99
101
|
_: 3
|
|
100
102
|
/* FORWARDED */
|
|
101
103
|
}),
|
|
102
|
-
t.title ?
|
|
104
|
+
t.title ? p("v-if", !0) : (h(), b(e(c), {
|
|
103
105
|
key: 0,
|
|
104
106
|
cols: "auto"
|
|
105
107
|
}, {
|
|
106
108
|
default: l(() => [
|
|
107
109
|
r(o.$slots, "dismiss", {}, () => [
|
|
108
|
-
|
|
110
|
+
i(e(w), {
|
|
109
111
|
class: "q-toast__dismiss",
|
|
110
112
|
variant: _.value,
|
|
111
113
|
color: t.color,
|
|
112
|
-
onClick:
|
|
114
|
+
onClick: f
|
|
113
115
|
}, {
|
|
114
116
|
default: l(() => [
|
|
115
|
-
|
|
117
|
+
i(
|
|
116
118
|
e(g),
|
|
117
119
|
k(q(t.icons.close)),
|
|
118
120
|
null,
|
|
@@ -143,41 +145,41 @@ const K = { class: "q-toast__title" }, nt = /* @__PURE__ */ U({
|
|
|
143
145
|
t.title ? {
|
|
144
146
|
name: "header",
|
|
145
147
|
fn: l(() => [
|
|
146
|
-
|
|
148
|
+
i(e(T), { fluid: "" }, {
|
|
147
149
|
default: l(() => [
|
|
148
|
-
|
|
150
|
+
i(e($), {
|
|
149
151
|
align: "center",
|
|
150
152
|
justify: "between"
|
|
151
153
|
}, {
|
|
152
154
|
default: l(() => [
|
|
153
|
-
|
|
155
|
+
i(e(c), null, {
|
|
154
156
|
default: l(() => [
|
|
155
|
-
|
|
156
|
-
o.$slots["title.prepend"] ? r(o.$slots, "title.prepend", { key: 0 }) :
|
|
157
|
-
|
|
157
|
+
v("div", K, [
|
|
158
|
+
o.$slots["title.prepend"] ? r(o.$slots, "title.prepend", { key: 0 }) : p("v-if", !0),
|
|
159
|
+
v(
|
|
158
160
|
"h4",
|
|
159
161
|
null,
|
|
160
|
-
|
|
162
|
+
y(t.title),
|
|
161
163
|
1
|
|
162
164
|
/* TEXT */
|
|
163
165
|
),
|
|
164
|
-
o.$slots["title.append"] ? r(o.$slots, "title.append", { key: 1 }) :
|
|
166
|
+
o.$slots["title.append"] ? r(o.$slots, "title.append", { key: 1 }) : p("v-if", !0)
|
|
165
167
|
])
|
|
166
168
|
]),
|
|
167
169
|
_: 3
|
|
168
170
|
/* FORWARDED */
|
|
169
171
|
}),
|
|
170
|
-
|
|
172
|
+
i(e(c), { cols: "auto" }, {
|
|
171
173
|
default: l(() => [
|
|
172
174
|
r(o.$slots, "dismiss", {}, () => [
|
|
173
|
-
|
|
175
|
+
i(e(w), {
|
|
174
176
|
class: "q-toast__dismiss",
|
|
175
177
|
variant: _.value,
|
|
176
178
|
color: t.color,
|
|
177
|
-
onClick:
|
|
179
|
+
onClick: f
|
|
178
180
|
}, {
|
|
179
181
|
default: l(() => [
|
|
180
|
-
|
|
182
|
+
i(
|
|
181
183
|
e(g),
|
|
182
184
|
k(q(t.icons.close)),
|
|
183
185
|
null,
|
|
@@ -208,5 +210,5 @@ const K = { class: "q-toast__title" }, nt = /* @__PURE__ */ U({
|
|
|
208
210
|
}
|
|
209
211
|
});
|
|
210
212
|
export {
|
|
211
|
-
|
|
213
|
+
at as default
|
|
212
214
|
};
|
|
@@ -1,41 +1,44 @@
|
|
|
1
|
-
import { computed as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
1
|
+
import { computed as l, unref as g } from "vue";
|
|
2
|
+
import { useTheme as v } from "../theme.js";
|
|
3
|
+
import { rgbToHsl as p, rgbToHex as b, rgbToVariableString as c } from "../../utils/color/conversion.js";
|
|
4
|
+
import { getContrastingColor as d } from "../../utils/color/contrast.js";
|
|
5
|
+
import { darken as y } from "../../utils/color/manipulate.js";
|
|
6
|
+
import { parseColor as T } from "../../utils/color/parse.js";
|
|
7
|
+
function K(o) {
|
|
8
|
+
const e = l(() => g(o)), i = l(
|
|
9
|
+
() => e.value ? !H(e.value) : !1
|
|
10
|
+
), m = l(() => {
|
|
11
|
+
const t = e.value;
|
|
12
|
+
if (!t) return;
|
|
13
|
+
let n = t;
|
|
14
|
+
const C = v();
|
|
12
15
|
if (i.value) {
|
|
13
|
-
const
|
|
14
|
-
n =
|
|
16
|
+
const s = t;
|
|
17
|
+
n = C.current.value.scheme[s] ?? t;
|
|
15
18
|
}
|
|
16
19
|
let r;
|
|
17
20
|
try {
|
|
18
|
-
if (r =
|
|
19
|
-
} catch (
|
|
20
|
-
console.error("Failed to parse color:",
|
|
21
|
+
if (r = T(n), !r) return;
|
|
22
|
+
} catch (s) {
|
|
23
|
+
console.error("Failed to parse color:", s);
|
|
21
24
|
return;
|
|
22
25
|
}
|
|
23
|
-
const
|
|
26
|
+
const f = p(r), a = d(f.l), u = y(r, 25), h = b(u);
|
|
24
27
|
return {
|
|
25
28
|
mainColor: n,
|
|
26
29
|
mainColorRgb: c(r),
|
|
27
30
|
onMainColor: a,
|
|
28
|
-
hoverColor:
|
|
31
|
+
hoverColor: h,
|
|
29
32
|
hoverColorRgb: c(u),
|
|
30
33
|
onHoverColor: a
|
|
31
34
|
};
|
|
32
35
|
});
|
|
33
|
-
return { isUtilityColor: i, style:
|
|
36
|
+
return { isUtilityColor: i, style: m };
|
|
34
37
|
}
|
|
35
38
|
function H(o) {
|
|
36
39
|
return o.startsWith("#") || o.startsWith("rgb") || o.startsWith("hsl");
|
|
37
40
|
}
|
|
38
41
|
export {
|
|
39
42
|
H as isCssColor,
|
|
40
|
-
|
|
43
|
+
K as useColor
|
|
41
44
|
};
|
package/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { FrameworkConfig } from './framework';
|
|
2
2
|
import * as templates from './templates';
|
|
3
3
|
import * as components from './components';
|
|
4
|
+
import * as utils from './utils';
|
|
4
5
|
export declare const createFramework: (options?: FrameworkConfig) => import('vue').Plugin;
|
|
5
|
-
export { templates, components };
|
|
6
|
+
export { templates, components, utils };
|
|
6
7
|
export * from './composables';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
8
9
|
declare module '@vue/runtime-core' {
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,UAAU,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,KAAK,MAAM,SAAS,CAAA;AAIhC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,eAAO,MAAM,eAAe,aAAa,eAAe,yBAEvD,CAAA;AAED,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,CAAA;AACvC,cAAc,eAAe,CAAA"}
|
package/esm/index.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import * as t from "./templates/index.js";
|
|
2
2
|
import * as r from "./components/index.js";
|
|
3
|
+
import * as m from "./utils/index.js";
|
|
3
4
|
import { createFramework as o } from "./framework.js";
|
|
4
|
-
import { provideTheme as n, useTheme as
|
|
5
|
+
import { provideTheme as n, useTheme as x } from "./composables/theme.js";
|
|
5
6
|
import { useDialog as c } from "./composables/useDialog/index.js";
|
|
6
|
-
import { useToast as
|
|
7
|
-
const
|
|
7
|
+
import { useToast as d } from "./composables/useToast/index.js";
|
|
8
|
+
const s = (e = {}) => o({ components: r, ...e });
|
|
8
9
|
export {
|
|
9
10
|
r as components,
|
|
10
|
-
|
|
11
|
+
s as createFramework,
|
|
11
12
|
n as provideTheme,
|
|
12
13
|
t as templates,
|
|
13
14
|
c as useDialog,
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
x as useTheme,
|
|
16
|
+
d as useToast,
|
|
17
|
+
m as utils
|
|
16
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/templates/theme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEjD,eAAO,MAAM,uBAAuB,EAAE,
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/templates/theme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEjD,eAAO,MAAM,uBAAuB,EAAE,WAsDrC,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,WAsDpC,CAAA"}
|
package/esm/templates/theme.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const n = {
|
|
2
2
|
primary: "#008ad2",
|
|
3
3
|
primaryLight: "#cde5ff",
|
|
4
4
|
primaryDark: "#006398",
|
|
@@ -25,16 +25,33 @@ const a = {
|
|
|
25
25
|
neutral: "#7c858d",
|
|
26
26
|
neutralLight: "#c4c5ca",
|
|
27
27
|
neutralDark: "#40474f",
|
|
28
|
-
onBackground: "#202428",
|
|
29
28
|
onPrimary: "#fff",
|
|
29
|
+
onPrimaryLight: "#202428",
|
|
30
|
+
onPrimaryDark: "#fff",
|
|
30
31
|
onSecondary: "#fff",
|
|
32
|
+
onSecondaryLight: "#202428",
|
|
33
|
+
onSecondaryDark: "#fff",
|
|
31
34
|
onHighlight: "#fff",
|
|
35
|
+
onHighlightLight: "#202428",
|
|
36
|
+
onHighlightDark: "#fff",
|
|
37
|
+
onInfo: "#fff",
|
|
38
|
+
onInfoLight: "#202428",
|
|
39
|
+
onInfoDark: "#fff",
|
|
32
40
|
onSuccess: "#fff",
|
|
41
|
+
onSuccessLight: "#202428",
|
|
42
|
+
onSuccessDark: "#fff",
|
|
33
43
|
onWarning: "#fff",
|
|
44
|
+
onWarningLight: "#202428",
|
|
45
|
+
onWarningDark: "#fff",
|
|
34
46
|
onDanger: "#fff",
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
onDangerLight: "#202428",
|
|
48
|
+
onDangerDark: "#fff",
|
|
49
|
+
onBackground: "#202428",
|
|
50
|
+
onContainer: "#202428",
|
|
51
|
+
onNeutral: "#fff",
|
|
52
|
+
onNeutralLight: "#202428",
|
|
53
|
+
onNeutralDark: "#fff"
|
|
54
|
+
}, a = {
|
|
38
55
|
primary: "#4da6e0",
|
|
39
56
|
primaryLight: "#1a2832",
|
|
40
57
|
primaryDark: "#87c5f0",
|
|
@@ -61,17 +78,34 @@ const a = {
|
|
|
61
78
|
neutral: "#9ca3ab",
|
|
62
79
|
neutralLight: "#2a2d31",
|
|
63
80
|
neutralDark: "#c8ced6",
|
|
64
|
-
onBackground: "#e0e0e0",
|
|
65
81
|
onPrimary: "#000",
|
|
82
|
+
onPrimaryLight: "#e0e0e0",
|
|
83
|
+
onPrimaryDark: "#000",
|
|
66
84
|
onSecondary: "#000",
|
|
85
|
+
onSecondaryLight: "#e0e0e0",
|
|
86
|
+
onSecondaryDark: "#000",
|
|
67
87
|
onHighlight: "#000",
|
|
88
|
+
onHighlightLight: "#e0e0e0",
|
|
89
|
+
onHighlightDark: "#000",
|
|
90
|
+
onInfo: "#000",
|
|
91
|
+
onInfoLight: "#e0e0e0",
|
|
92
|
+
onInfoDark: "#000",
|
|
68
93
|
onSuccess: "#000",
|
|
94
|
+
onSuccessLight: "#e0e0e0",
|
|
95
|
+
onSuccessDark: "#000",
|
|
69
96
|
onWarning: "#000",
|
|
97
|
+
onWarningLight: "#e0e0e0",
|
|
98
|
+
onWarningDark: "#000",
|
|
70
99
|
onDanger: "#000",
|
|
71
|
-
|
|
72
|
-
|
|
100
|
+
onDangerLight: "#e0e0e0",
|
|
101
|
+
onDangerDark: "#000",
|
|
102
|
+
onBackground: "#e0e0e0",
|
|
103
|
+
onContainer: "#e0e0e0",
|
|
104
|
+
onNeutral: "#000",
|
|
105
|
+
onNeutralLight: "#e0e0e0",
|
|
106
|
+
onNeutralDark: "#000"
|
|
73
107
|
};
|
|
74
108
|
export {
|
|
75
|
-
|
|
76
|
-
|
|
109
|
+
a as defaultDarkColorScheme,
|
|
110
|
+
n as defaultLightColorScheme
|
|
77
111
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines a contrasting color (black or white) based on the given luminance.
|
|
3
|
+
* Useful for ensuring text readability against a background color with the given luminance.
|
|
4
|
+
*
|
|
5
|
+
* @param luminance - The luminance value (between 0 and 100) of the background color.
|
|
6
|
+
* @returns A hex string representing either black ('#000') or white ('#fff').
|
|
7
|
+
*/
|
|
8
|
+
export declare function getContrastingColor(luminance: number): '#000' | '#fff';
|
|
9
|
+
/**
|
|
10
|
+
* Calculates the complementary color for a given color string.
|
|
11
|
+
* The complementary color is the color directly opposite on the color wheel,
|
|
12
|
+
* often used for strong visual contrast.
|
|
13
|
+
*
|
|
14
|
+
* @param color - The color string to convert. Can be in various formats (e.g., hex, rgb, rgba, hsl, hsla).
|
|
15
|
+
* @returns A hex string representing the complementary color.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getComplementaryColor(color: string): string;
|
|
18
|
+
//# sourceMappingURL=contrast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contrast.d.ts","sourceRoot":"","sources":["../../../src/utils/color/contrast.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAMtE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAW3D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { rgbToHex as t } from "./conversion.js";
|
|
2
|
+
import { parseColor as e } from "./parse.js";
|
|
3
|
+
function g(o) {
|
|
4
|
+
return o > 50 ? "#000" : "#fff";
|
|
5
|
+
}
|
|
6
|
+
function l(o) {
|
|
7
|
+
const r = e(o);
|
|
8
|
+
return r.r = 255 - r.r, r.g = 255 - r.g, r.b = 255 - r.b, t(r);
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
l as getComplementaryColor,
|
|
12
|
+
g as getContrastingColor
|
|
13
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { RGB, HSL } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a color from RGB to HSL space.
|
|
4
|
+
*
|
|
5
|
+
* @param color The color to convert.
|
|
6
|
+
* @returns An object representing the color in HSL space.
|
|
7
|
+
*/
|
|
8
|
+
export declare function rgbToHsl(rgb: RGB): HSL;
|
|
9
|
+
/**
|
|
10
|
+
* Converts a color from HSL to RGB space.
|
|
11
|
+
*
|
|
12
|
+
* @param h The hue component of the color, in the range [0, 1].
|
|
13
|
+
* @param s The saturation component of the color, in the range [0, 1].
|
|
14
|
+
* @param l The lightness component of the color, in the range [0, 1].
|
|
15
|
+
* @returns A `RGB` object representing the color in RGB space.
|
|
16
|
+
*/
|
|
17
|
+
export declare function hslToRgb(hsl: HSL): RGB;
|
|
18
|
+
/**
|
|
19
|
+
* Converts a hue value to a corresponding RGB value.
|
|
20
|
+
*
|
|
21
|
+
* @param p The first RGB component.
|
|
22
|
+
* @param q The second RGB component.
|
|
23
|
+
* @param t The hue value.
|
|
24
|
+
* @returns The corresponding RGB value.
|
|
25
|
+
*/
|
|
26
|
+
export declare function hueToRgb(p: number, q: number, t: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* Converts a RGB value to a hex string.
|
|
29
|
+
*
|
|
30
|
+
* @param rgb The color to convert.
|
|
31
|
+
* @returns A hex string representing the color.
|
|
32
|
+
*/
|
|
33
|
+
export declare function rgbToHex(rgb: RGB): string;
|
|
34
|
+
/**
|
|
35
|
+
* Converts an RGB object to a string in the format 'r g b'.
|
|
36
|
+
*
|
|
37
|
+
* @param rgb The RGB object to convert.
|
|
38
|
+
* @returns A string representing the color in 'r g b' format.
|
|
39
|
+
*/
|
|
40
|
+
export declare function rgbToVariableString(rgb: RGB): string;
|
|
41
|
+
//# sourceMappingURL=conversion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversion.d.ts","sourceRoot":"","sources":["../../../src/utils/color/conversion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAEvC;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAqCtC;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAuBtC;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAOhE;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAMzC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAEpD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
function f(t) {
|
|
2
|
+
const r = t.r / 255, n = t.g / 255, o = t.b / 255, s = Math.max(r, n, o), c = Math.min(r, n, o);
|
|
3
|
+
let a = 0, e;
|
|
4
|
+
const i = (s + c) / 2;
|
|
5
|
+
if (s === c)
|
|
6
|
+
a = e = 0;
|
|
7
|
+
else {
|
|
8
|
+
const u = s - c;
|
|
9
|
+
switch (e = i > 0.5 ? u / (2 - s - c) : u / (s + c), s) {
|
|
10
|
+
case r:
|
|
11
|
+
a = (n - o) / u + (n < o ? 6 : 0);
|
|
12
|
+
break;
|
|
13
|
+
case n:
|
|
14
|
+
a = (o - r) / u + 2;
|
|
15
|
+
break;
|
|
16
|
+
case o:
|
|
17
|
+
a = (r - n) / u + 4;
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
a /= 6;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
h: Math.round(a * 360),
|
|
24
|
+
s: Math.round(e * 100),
|
|
25
|
+
l: Math.round(i * 100)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function b(t) {
|
|
29
|
+
const r = t.h / 360, n = t.s / 100, o = t.l / 100;
|
|
30
|
+
let s, c, a;
|
|
31
|
+
if (n === 0)
|
|
32
|
+
s = c = a = o;
|
|
33
|
+
else {
|
|
34
|
+
const e = o < 0.5 ? o * (1 + n) : o + n - o * n, i = 2 * o - e;
|
|
35
|
+
s = h(i, e, r + 1 / 3), c = h(i, e, r), a = h(i, e, r - 1 / 3);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
r: Math.round(s * 255),
|
|
39
|
+
g: Math.round(c * 255),
|
|
40
|
+
b: Math.round(a * 255)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function h(t, r, n) {
|
|
44
|
+
return n < 0 && (n += 1), n > 1 && (n -= 1), n < 1 / 6 ? t + (r - t) * 6 * n : n < 1 / 2 ? r : n < 2 / 3 ? t + (r - t) * (2 / 3 - n) * 6 : t;
|
|
45
|
+
}
|
|
46
|
+
function d(t) {
|
|
47
|
+
const r = t.r.toString(16).padStart(2, "0"), n = t.g.toString(16).padStart(2, "0"), o = t.b.toString(16).padStart(2, "0");
|
|
48
|
+
return `#${r}${n}${o}`;
|
|
49
|
+
}
|
|
50
|
+
function g(t) {
|
|
51
|
+
return `${t.r} ${t.g} ${t.b}`;
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
b as hslToRgb,
|
|
55
|
+
h as hueToRgb,
|
|
56
|
+
d as rgbToHex,
|
|
57
|
+
f as rgbToHsl,
|
|
58
|
+
g as rgbToVariableString
|
|
59
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/color/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RGB } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Lightens a color by a specified amount.
|
|
4
|
+
*
|
|
5
|
+
* @param rgb The color to lighten.
|
|
6
|
+
* @param amount The amount to lighten the color by, in the range [0, 100].
|
|
7
|
+
* @returns The lightened color.
|
|
8
|
+
*/
|
|
9
|
+
export declare function lighten(rgb: RGB, amount: number): RGB;
|
|
10
|
+
/**
|
|
11
|
+
* Darkens a color by a specified amount.
|
|
12
|
+
*
|
|
13
|
+
* @param rgb The color to darken.
|
|
14
|
+
* @param amount The amount to darken the color by, in the range [0, 100].
|
|
15
|
+
* @returns The darkened color.
|
|
16
|
+
*/
|
|
17
|
+
export declare function darken(rgb: RGB, amount: number): RGB;
|
|
18
|
+
//# sourceMappingURL=manipulate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manipulate.d.ts","sourceRoot":"","sources":["../../../src/utils/color/manipulate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAKlC;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,CAYrD;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,CAYpD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { rgbToHsl as l, hslToRgb as o } from "./conversion.js";
|
|
2
|
+
function i(t, r) {
|
|
3
|
+
if (r < 0 || r > 100)
|
|
4
|
+
throw new Error("Amount must be in the range [0, 100]");
|
|
5
|
+
if (r === 0)
|
|
6
|
+
return t;
|
|
7
|
+
const e = l(t), n = r / 100;
|
|
8
|
+
return e.l = e.l + n * (100 - e.l), o(e);
|
|
9
|
+
}
|
|
10
|
+
function f(t, r) {
|
|
11
|
+
if (r < 0 || r > 100)
|
|
12
|
+
throw new Error("Amount must be in the range [0, 100]");
|
|
13
|
+
if (r === 0)
|
|
14
|
+
return t;
|
|
15
|
+
const e = l(t), n = r / 100;
|
|
16
|
+
return e.l = e.l - n * e.l, o(e);
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
f as darken,
|
|
20
|
+
i as lighten
|
|
21
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ColorScheme } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Merges two color schemes, generating color variants and contrasting text colors as needed.
|
|
4
|
+
*
|
|
5
|
+
* This function takes a base color scheme (`a`) and a partial override (`b`), and returns a new
|
|
6
|
+
* color scheme with overrides applied. For each color group (e.g., `primary`, `secondary`, etc.),
|
|
7
|
+
* if a base color is provided in `b`, its light and dark variants are auto-computed, along with
|
|
8
|
+
* appropriate contrasting text colors (`on*`). Individual variant and 'on' color overrides are also
|
|
9
|
+
* respected. Special keys like `background` and `container` are handled separately.
|
|
10
|
+
*
|
|
11
|
+
* @param a - The base color scheme to merge into.
|
|
12
|
+
* @param b - A partial color scheme containing overrides.
|
|
13
|
+
* @returns The merged color scheme with computed variants and contrasting colors.
|
|
14
|
+
*
|
|
15
|
+
* @see ColorScheme
|
|
16
|
+
* @see Partial
|
|
17
|
+
*/
|
|
18
|
+
export declare function mergeColorSchemes(a: ColorScheme, b: Partial<ColorScheme>): ColorScheme;
|
|
19
|
+
//# sourceMappingURL=merge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/utils/color/merge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,WAAW,EAAE,MAAM,SAAS,CAAA;AAQ3D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,CAkGtF"}
|