@wrdagency/blockout 1.0.6 → 1.0.7
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.
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Tag, Taggable } from './props';
|
|
3
|
-
interface TagControlProps {
|
|
4
|
-
value?: Taggable[];
|
|
5
|
-
onChangeValue?: (value: Tag[]) => void;
|
|
6
|
-
options?: Taggable[];
|
|
7
|
-
|
|
1
|
+
import { ControlProps } from '../base-control/props';
|
|
2
|
+
import { Tag, Taggable, UnnormalizedCreateTagRules } from './props';
|
|
3
|
+
interface TagControlProps<T extends number | string = string> {
|
|
4
|
+
value?: Taggable<T>[];
|
|
5
|
+
onChangeValue?: (value: Tag<T>[]) => void;
|
|
6
|
+
options?: Taggable<T>[];
|
|
7
|
+
create?: UnnormalizedCreateTagRules<T>;
|
|
8
8
|
}
|
|
9
|
-
export declare
|
|
9
|
+
export declare function TagControl<T extends number | string = string>(props: ControlProps<TagControlProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export type { Tag, Taggable } from './props';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
-
import { Colourway as
|
|
3
|
-
import { noop as
|
|
4
|
-
import { useState as
|
|
2
|
+
import { Colourway as u } from "../../../primitives/colourway/index.js";
|
|
3
|
+
import { noop as S } from "../../../utils/noop.js";
|
|
4
|
+
import { useState as V, useMemo as y } from "react";
|
|
5
5
|
import '../../../assets/style18.css';import '../../../assets/styles.css';import '../../../assets/style7.css';import '../../../assets/style6.css';import '../../../assets/style5.css';import '../../../assets/style4.css';import '../../../assets/style3.css';import '../../../assets/style2.css';import '../../../assets/style.css';/* empty css */
|
|
6
6
|
/* empty css */
|
|
7
7
|
/* empty css */
|
|
@@ -13,70 +13,73 @@ import "../../../primitives/symbol/index.js";
|
|
|
13
13
|
/* empty css */
|
|
14
14
|
/* empty css */
|
|
15
15
|
/* empty css */
|
|
16
|
-
import { o as
|
|
17
|
-
import { e as
|
|
18
|
-
import { e as
|
|
19
|
-
import { m as
|
|
20
|
-
import { BaseControl as
|
|
21
|
-
import { useBaseControlProps as
|
|
22
|
-
import { T as
|
|
23
|
-
import { normalizeTag as
|
|
16
|
+
import { o as z } from "../../../Check.es-CMkTf2It.js";
|
|
17
|
+
import { e as R } from "../../../Plus.es-DJ5SuqNv.js";
|
|
18
|
+
import { e as k } from "../../../X.es-TbGOnXOO.js";
|
|
19
|
+
import { m as B } from "../../../match-sorter.esm-MNVE8H_6.js";
|
|
20
|
+
import { BaseControl as I } from "../base-control/index.js";
|
|
21
|
+
import { useBaseControlProps as j } from "../base-control/props.js";
|
|
22
|
+
import { T as L, a as M, b as O, c as A, d as K, C as U, e as $ } from "../../../tag-remove-BVa8oSsq.js";
|
|
23
|
+
import { normalizeTag as _, normalizeCreateTagRules as q } from "./props.js";
|
|
24
24
|
/* empty css */
|
|
25
|
-
import { C as
|
|
26
|
-
|
|
27
|
-
const { baseProps:
|
|
25
|
+
import { C as D, a as E, c as g } from "../../../MAXQOH4L-DBaf8WKp.js";
|
|
26
|
+
function vo(d) {
|
|
27
|
+
const { baseProps: h, controlProps: v } = j(d, {
|
|
28
28
|
className: "component-tag-control"
|
|
29
|
-
}), [a,
|
|
30
|
-
value:
|
|
31
|
-
onChangeValue:
|
|
32
|
-
options:
|
|
33
|
-
|
|
34
|
-
} =
|
|
35
|
-
baseSort: (o,
|
|
29
|
+
}), [a, b] = V(""), {
|
|
30
|
+
value: f = [],
|
|
31
|
+
onChangeValue: C = S,
|
|
32
|
+
options: N = [],
|
|
33
|
+
create: w = !1
|
|
34
|
+
} = v, m = N.map(_), c = f.map(_), r = q(w), n = y(() => B(m, a, {
|
|
35
|
+
baseSort: (o, l) => o.index < l.index ? -1 : 1,
|
|
36
36
|
keys: ["label", "value"]
|
|
37
|
-
}), [a]),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
}), [a]), p = !n.length && r.allow(a), x = n.length > 0 || p, T = (o) => {
|
|
38
|
+
const l = o.map((s) => {
|
|
39
|
+
const i = m.find((P) => P.value == s);
|
|
40
|
+
if (i)
|
|
41
|
+
return i;
|
|
42
|
+
if (r.allow(s))
|
|
43
|
+
return r.create(s);
|
|
44
|
+
}).filter(Boolean);
|
|
45
|
+
C(l);
|
|
43
46
|
};
|
|
44
47
|
return /* @__PURE__ */ e(
|
|
45
|
-
|
|
48
|
+
L,
|
|
46
49
|
{
|
|
47
|
-
values: c.map((o) => o.value),
|
|
48
|
-
setValues:
|
|
50
|
+
values: c.map((o) => String(o.value)),
|
|
51
|
+
setValues: T,
|
|
49
52
|
value: a,
|
|
50
|
-
setValue:
|
|
51
|
-
children: /* @__PURE__ */ e(
|
|
53
|
+
setValue: b,
|
|
54
|
+
children: /* @__PURE__ */ e(I, { ...h, children: /* @__PURE__ */ t(M, { className: "component-tag-control__box", children: [
|
|
52
55
|
c.map((o) => /* @__PURE__ */ t(
|
|
53
|
-
|
|
56
|
+
u,
|
|
54
57
|
{
|
|
55
|
-
value: o.value,
|
|
56
|
-
as:
|
|
58
|
+
value: String(o.value),
|
|
59
|
+
as: O,
|
|
57
60
|
theme: o.colourway,
|
|
58
61
|
className: "component-tag-control__tag",
|
|
59
62
|
children: [
|
|
60
63
|
/* @__PURE__ */ e("span", { className: "component-tag-control__tag__label", children: o.label }),
|
|
61
|
-
/* @__PURE__ */ e(
|
|
64
|
+
/* @__PURE__ */ e(A, { className: "component-tag-control__tag__remove", children: /* @__PURE__ */ e(k, {}) })
|
|
62
65
|
]
|
|
63
66
|
},
|
|
64
67
|
o.value
|
|
65
68
|
)),
|
|
66
|
-
/* @__PURE__ */ t(
|
|
69
|
+
/* @__PURE__ */ t(D, { children: [
|
|
67
70
|
/* @__PURE__ */ e(
|
|
68
|
-
|
|
71
|
+
E,
|
|
69
72
|
{
|
|
70
73
|
autoSelect: !0,
|
|
71
74
|
showMinLength: 1,
|
|
72
75
|
showOnKeyPress: !0,
|
|
73
76
|
autoComplete: "both",
|
|
74
|
-
render: /* @__PURE__ */ e(
|
|
77
|
+
render: /* @__PURE__ */ e(K, {}),
|
|
75
78
|
className: "component-tag-control__input"
|
|
76
79
|
}
|
|
77
80
|
),
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
x && /* @__PURE__ */ t(
|
|
82
|
+
U,
|
|
80
83
|
{
|
|
81
84
|
className: "component-tag-control__popover",
|
|
82
85
|
"data-colour-scheme": "invert",
|
|
@@ -88,31 +91,31 @@ const io = (_) => {
|
|
|
88
91
|
overflowPadding: 4,
|
|
89
92
|
children: [
|
|
90
93
|
n.map((o) => /* @__PURE__ */ t(
|
|
91
|
-
|
|
94
|
+
g,
|
|
92
95
|
{
|
|
93
|
-
value: o.value,
|
|
96
|
+
value: String(o.value),
|
|
94
97
|
className: "component-tag-control__option",
|
|
95
98
|
children: [
|
|
96
99
|
/* @__PURE__ */ e(
|
|
97
|
-
|
|
100
|
+
u,
|
|
98
101
|
{
|
|
99
102
|
className: "component-tag-control__option__chip",
|
|
100
103
|
theme: o.colourway
|
|
101
104
|
}
|
|
102
105
|
),
|
|
103
106
|
/* @__PURE__ */ e("span", { className: "component-tag-control__option__label", children: o.label }),
|
|
104
|
-
/* @__PURE__ */ e(
|
|
107
|
+
/* @__PURE__ */ e($, { className: "component-tag-control__option__check", children: /* @__PURE__ */ e(z, {}) })
|
|
105
108
|
]
|
|
106
109
|
},
|
|
107
110
|
o.value
|
|
108
111
|
)),
|
|
109
|
-
|
|
110
|
-
|
|
112
|
+
p && /* @__PURE__ */ t(
|
|
113
|
+
g,
|
|
111
114
|
{
|
|
112
|
-
value: a
|
|
115
|
+
value: a,
|
|
113
116
|
className: "component-tag-control__option component-tag-control__option--create",
|
|
114
117
|
children: [
|
|
115
|
-
/* @__PURE__ */ e(
|
|
118
|
+
/* @__PURE__ */ e(R, { className: "component-tag-control__option--add" }),
|
|
116
119
|
/* @__PURE__ */ t("span", { className: "component-tag-control__option__label", children: [
|
|
117
120
|
'Add "',
|
|
118
121
|
a.toUpperCase(),
|
|
@@ -128,7 +131,7 @@ const io = (_) => {
|
|
|
128
131
|
] }) })
|
|
129
132
|
}
|
|
130
133
|
);
|
|
131
|
-
}
|
|
134
|
+
}
|
|
132
135
|
export {
|
|
133
|
-
|
|
136
|
+
vo as TagControl
|
|
134
137
|
};
|
|
@@ -8,4 +8,13 @@ export type PartialTag<T extends string | number = string> = Partial<Tag<T>> & {
|
|
|
8
8
|
value: T;
|
|
9
9
|
};
|
|
10
10
|
export type Taggable<T extends string | number = string> = Tag<T> | PartialTag<T> | T;
|
|
11
|
+
export type CreateTagRules<T extends number | string = string> = {
|
|
12
|
+
create: (input: string) => Tag<T>;
|
|
13
|
+
allow: (input: string) => boolean;
|
|
14
|
+
};
|
|
15
|
+
export type UnnormalizedCreateTagRules<T extends number | string = string> = boolean | {
|
|
16
|
+
create?: ((input: string) => PartialTag<T>) | "slugify" | "uuid";
|
|
17
|
+
allow?: (input: string) => boolean;
|
|
18
|
+
};
|
|
11
19
|
export declare function normalizeTag<T extends string | number = string>(opt: Taggable<T>): Tag<T>;
|
|
20
|
+
export declare function normalizeCreateTagRules<T extends string | number = string>(rules: UnnormalizedCreateTagRules<T>): CreateTagRules<T>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import '../../../assets/styles.css';import '../../../assets/style7.css';import '../../../assets/style6.css';import '../../../assets/style5.css';import '../../../assets/style4.css';import '../../../assets/style3.css';import '../../../assets/style2.css';import '../../../assets/style.css';import '../../../assets/style10.css';/* empty css */
|
|
3
|
-
import { getRandomTheme as
|
|
3
|
+
import { getRandomTheme as t } from "../../../primitives/colourway/util.js";
|
|
4
4
|
import "react";
|
|
5
5
|
/* empty css */
|
|
6
6
|
/* empty css */
|
|
@@ -13,17 +13,45 @@ import "../../../primitives/symbol/index.js";
|
|
|
13
13
|
/* empty css */
|
|
14
14
|
/* empty css */
|
|
15
15
|
/* empty css */
|
|
16
|
-
|
|
16
|
+
import { slugify as a } from "../../../utils/string.js";
|
|
17
|
+
function U(r) {
|
|
17
18
|
return typeof r == "string" || typeof r == "number" ? {
|
|
18
19
|
value: r,
|
|
19
20
|
label: String(r),
|
|
20
|
-
colourway:
|
|
21
|
+
colourway: t(r)
|
|
21
22
|
} : {
|
|
22
23
|
label: r.label || String(r.value),
|
|
23
|
-
colourway:
|
|
24
|
+
colourway: t(r.value),
|
|
24
25
|
...r
|
|
25
26
|
};
|
|
26
27
|
}
|
|
28
|
+
function h(r) {
|
|
29
|
+
const e = (o) => {
|
|
30
|
+
var i = o;
|
|
31
|
+
if (typeof r == "boolean" || typeof r.create > "u" || r.create === "slugify")
|
|
32
|
+
i = a(o);
|
|
33
|
+
else if (r.create === "uuid")
|
|
34
|
+
i = crypto.randomUUID();
|
|
35
|
+
else
|
|
36
|
+
return {
|
|
37
|
+
label: o,
|
|
38
|
+
colourway: t(o),
|
|
39
|
+
...r.create(o)
|
|
40
|
+
};
|
|
41
|
+
return { label: o, colourway: t(o), value: i };
|
|
42
|
+
};
|
|
43
|
+
return r === !0 ? {
|
|
44
|
+
create: e,
|
|
45
|
+
allow: () => !0
|
|
46
|
+
} : r === !1 ? {
|
|
47
|
+
create: e,
|
|
48
|
+
allow: () => !1
|
|
49
|
+
} : {
|
|
50
|
+
create: e,
|
|
51
|
+
allow: r.allow ? r.allow : () => !0
|
|
52
|
+
};
|
|
53
|
+
}
|
|
27
54
|
export {
|
|
28
|
-
|
|
55
|
+
h as normalizeCreateTagRules,
|
|
56
|
+
U as normalizeTag
|
|
29
57
|
};
|