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