@sps-woodland/tags 7.0.0

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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ ## [@sps-woodland/tags](https://github.com/SPSCommerce/woodland/tree/master/packages/@sps-woodland/tags#readme)
2
+
3
+ SPS Woodland Design System tag components
@@ -0,0 +1,15 @@
1
+ import { Tokens } from "@sps-woodland/tokens";
2
+ import type { VariantDefinitions, RecipeVariant, BooleanRecipeVariant } from "@sps-woodland/core";
3
+ export declare type ClickableTagKind = keyof typeof Tokens.component["clickable-tag"]["kind"];
4
+ interface ClickableTagVariantDefinitions extends VariantDefinitions {
5
+ kind: RecipeVariant<ClickableTagKind>;
6
+ disabled: BooleanRecipeVariant;
7
+ link: BooleanRecipeVariant;
8
+ addOrRemove: BooleanRecipeVariant;
9
+ }
10
+ export declare const clickableTag: import("@vanilla-extract/recipes/dist/declarations/src/types").RuntimeFn<Pick<ClickableTagVariantDefinitions, "kind" | "disabled">>;
11
+ export declare const clickableTagLabel: import("@vanilla-extract/recipes/dist/declarations/src/types").RuntimeFn<Omit<ClickableTagVariantDefinitions, "kind">>;
12
+ export declare const clickableTagIconWrapper: string;
13
+ export declare const clickableTagIcon: string;
14
+ export declare const clickableTagLink: string;
15
+ export {};
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ import type { ComponentProps } from "@sps-woodland/core";
3
+ import type { ClickableTagKind } from "./ClickableTag.css";
4
+ export declare function ClickableTag({ children, className, onClick, disabled, href, kind, onAdd, onRemove, ...rest }: ComponentProps<{
5
+ disabled?: boolean;
6
+ href?: string;
7
+ kind?: ClickableTagKind;
8
+ onAdd?: () => void;
9
+ onRemove?: () => void;
10
+ }, HTMLDivElement>): React.ReactElement;
@@ -0,0 +1,2 @@
1
+ import type { ComponentManifestEntry } from "@sps-woodland/core";
2
+ export declare const ClickableTagExamples: ComponentManifestEntry;
@@ -0,0 +1,136 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const N=require("react"),c=require("@sps-woodland/core"),i=require("@spscommerce/utils");function _(e){if(e&&e.__esModule)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const l=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(r,a,l.get?l:{enumerable:!0,get:()=>e[a]})}}return r.default=e,Object.freeze(r)}const s=_(N);function K(e,r,a){return r in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function y(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);r&&(l=l.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),a.push.apply(a,l)}return a}function v(e){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?y(Object(a),!0).forEach(function(l){K(e,l,a[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):y(Object(a)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(a,l))})}return e}var V=(e,r,a)=>{for(var l of Object.keys(e)){var n;if(e[l]!==((n=r[l])!==null&&n!==void 0?n:a[l]))return!1}return!0},d=e=>r=>{var a=e.defaultClassName,l=v(v({},e.defaultVariants),r);for(var n in l){var m,o=(m=l[n])!==null&&m!==void 0?m:e.defaultVariants[n];if(o!=null){var t=o;typeof t=="boolean"&&(t=t===!0?"true":"false");var f=e.variantClassNames[n][t];f&&(a+=" "+f)}}for(var[p,b]of e.compoundVariants)V(p,l,e.defaultVariants)&&(a+=" "+b);return a},O=d({defaultClassName:"_160drw10",variantClassNames:{kind:{blue:"_160drw11",gray:"_160drw12"},disabled:{true:"_160drw13",false:"_160drw14"}},defaultVariants:{kind:"blue",disabled:!1},compoundVariants:[]}),E="_160drw1e",h="_160drw1d",P=d({defaultClassName:"_160drw15",variantClassNames:{link:{true:"_160drw16",false:"_160drw17"},disabled:{true:"_160drw18",false:"_160drw19"},addOrRemove:{true:"_160drw1a",false:"_160drw1b"}},defaultVariants:{link:!1,disabled:!1,addOrRemove:!1},compoundVariants:[[{disabled:!1,addOrRemove:!0},"_160drw1c"]]}),j="_160drw1f";function T({children:e,className:r,onClick:a,disabled:l,href:n,kind:m,onAdd:o,onRemove:t,...f}){const p=s.Children.toArray(e).filter(g=>typeof g=="string").join("");s.useEffect(()=>{if(t&&o)throw new Error("Clickable tag should have onRemove or onAdd, not both")},[o,t]);function b(g){o?o():t&&t(),g.stopPropagation()}function w(g){g.stopPropagation(),a&&a(g)}return s.createElement("div",{className:c.cl(O({kind:m,disabled:l}),r),...f},s.createElement("span",{className:c.cl(P({link:n||a,disabled:l,addOrRemove:o||t})),onClick:w,title:p},n?s.createElement("a",{className:j,href:n},e):e),(o||t)&&!l&&s.createElement("div",{className:h,onClick:l?void 0:b,tabIndex:-1,"aria-label":o?"Add":"Remove"},s.createElement(c.Icon,{className:E,"aria-hidden":"true",icon:o?"plus-sign":"x"})))}c.Metadata.set(T,{name:"Clickable Tag",props:{disabled:{type:"boolean",default:"false"},href:{type:"string"},kind:{type:"ClickableTagKind",default:"blue"},onAdd:{type:"() => void"},onRemove:{type:"() => void"}}});var x=d({defaultClassName:"_5f3efi0",variantClassNames:{kind:{default:"_5f3efi1",key:"_5f3efi2",warning:"_5f3efi3",error:"_5f3efi4",pending:"_5f3efi5",success:"_5f3efi6",info:"_5f3efi7"}},defaultVariants:{kind:"default"},compoundVariants:[]}),F=d({defaultClassName:"_5f3efi8",variantClassNames:{kind:{default:"_5f3efi9",key:"_5f3efia",warning:"_5f3efib",error:"_5f3efic",pending:"_5f3efid",success:"_5f3efie",info:"_5f3efif"}},defaultVariants:{kind:"default"},compoundVariants:[]});const C=Object.freeze({default:"info-circle",key:"info-circle",warning:"status-warning",error:"status-error",pending:"status-in-process",success:"status-ok",info:"info-circle"});function u({children:e,className:r,kind:a="default",icon:l,...n}){return s.createElement("span",{className:c.cl(x({kind:a}),r),...n},l&&s.createElement(c.Icon,{className:c.cl(F({kind:a})),icon:C[a]}),e)}c.Metadata.set(u,{name:"Tag",props:{kind:{type:"TagKind",default:"default"},icon:{type:"boolean",default:"false"}}});var I="c357iq0",q="c357iq1",S="c357iq5",M=d({defaultClassName:"c357iq2",variantClassNames:{href:{true:"c357iq3",false:"c357iq4"}},defaultVariants:{href:!1},compoundVariants:[]});function k({children:e,className:r,color:a="key",href:l,icon:n,tagKey:m,value:o,...t}){return s.createElement("span",{className:c.cl(I,r),...t},s.createElement(u,{className:c.cl(q),icon:n,kind:a},m),s.createElement(u,{className:c.cl(M({href:!!l}))},l?s.createElement("a",{className:S,href:l},o):o))}c.Metadata.set(k,{name:"Key Value Tag",props:{color:{type:"TagKind",default:"key"},href:{type:"string"},icon:{type:"boolean",default:"false"},tagKey:{type:"string",required:!0},value:{type:"string",required:!0}}});const R={components:[T],examples:{basic:{label:"Basic Tag",examples:{basic:{react:i.code`
2
+ import { ClickableTag } from "@sps-woodland/tags";
3
+
4
+ function Component() {
5
+ return (
6
+ <>
7
+ <ClickableTag className="mr-1">Blue</ClickableTag>
8
+ <ClickableTag className="mr-1" kind="gray">Gray</ClickableTag>
9
+ </>
10
+ );
11
+ }
12
+ `},disabled:{react:i.code`
13
+ import { ClickableTag } from "@sps-woodland/tags";
14
+
15
+ function Component() {
16
+ return (
17
+ <>
18
+ <ClickableTag disabled>Disabled</ClickableTag>
19
+ </>
20
+ );
21
+ }
22
+ `}}},button:{label:"Button",examples:{remove:{react:i.code`
23
+ import { ClickableTag } from "@sps-woodland/tags";
24
+
25
+ function Component() {
26
+ return (
27
+ <>
28
+ <ClickableTag className="mr-1" onRemove={() => console.log("removed")}>One</ClickableTag>
29
+ <ClickableTag className="mr-1" onRemove={() => console.log("removed")} kind="gray">Two</ClickableTag>
30
+ </>
31
+ );
32
+ }
33
+ `},add:{react:i.code`
34
+ import { ClickableTag } from "@sps-woodland/tags";
35
+
36
+ function Component() {
37
+ return (
38
+ <>
39
+ <ClickableTag className="mr-1" onAdd={() => console.log("added")}>One</ClickableTag>
40
+ <ClickableTag className="mr-1" onAdd={() => console.log("added")} kind="gray">Two</ClickableTag>
41
+ </>
42
+ );
43
+ }
44
+ `}}},link:{label:"Link",examples:{basic:{react:i.code`
45
+ import { ClickableTag } from "@sps-woodland/tags";
46
+
47
+ function Component() {
48
+ return (
49
+ <>
50
+ <ClickableTag className="mr-1" href="https://google.com">Link</ClickableTag>
51
+ <ClickableTag className="mr-1" onClick={() => window.alert("hi")} kind="gray">Link</ClickableTag>
52
+ </>
53
+ );
54
+ }
55
+ `},button:{react:i.code`
56
+ import { ClickableTag } from "@sps-woodland/tags";
57
+
58
+ function Component() {
59
+ return (
60
+ <>
61
+ <ClickableTag className="mr-1" href="https://google.com" onRemove={() => console.log("removed")}>Remove</ClickableTag>
62
+ <ClickableTag className="mr-1" onClick={() => window.alert("hi")} onAdd={() => console.log("added")} kind="gray">Add</ClickableTag>
63
+ </>
64
+ );
65
+ }
66
+ `}}}}},D={components:[u],examples:{basic:{label:"Basic Tag",examples:{basic:{react:i.code`
67
+ import { Tag } from "@sps-woodland/tag";
68
+
69
+ function Component() {
70
+ return (
71
+ <>
72
+ <Tag className="mr-1 mb-1">Default</Tag>
73
+ <Tag className="mr-1 mb-1" kind="key">Key</Tag>
74
+ <Tag className="mr-1 mb-1" kind="warning">Warning</Tag>
75
+ <Tag className="mr-1 mb-1" kind="error">Error</Tag>
76
+ <Tag className="mr-1 mb-1" kind="pending">Pending</Tag>
77
+ <Tag className="mr-1 mb-1" kind="success">Success</Tag>
78
+ <Tag className="mr-1 mb-1" kind="info">Info</Tag>
79
+ </>
80
+ )
81
+ }
82
+ `}}},withIcon:{label:"Tag with icon",examples:{basic:{react:i.code`
83
+ import { Tag } from "@sps-woodland/tag";
84
+
85
+ function Component() {
86
+ return (
87
+ <>
88
+ <Tag className="mr-1 mb-1" icon>Default</Tag>
89
+ <Tag className="mr-1 mb-1" kind="key" icon>Key</Tag>
90
+ <Tag className="mr-1 mb-1" kind="warning" icon>Warning</Tag>
91
+ <Tag className="mr-1 mb-1" kind="error" icon>Error</Tag>
92
+ <Tag className="mr-1 mb-1" kind="pending" icon>Pending</Tag>
93
+ <Tag className="mr-1 mb-1" kind="success" icon>Success</Tag>
94
+ <Tag className="mr-1 mb-1" kind="info" icon>Info</Tag>
95
+ </>
96
+ )
97
+ }
98
+ `}}}}},L={components:[k],examples:{basic:{label:"Basic",examples:{basic:{react:i.code`
99
+ import { KeyValueTag } from "@sps-woodland/tag";
100
+
101
+ function Component() {
102
+ return (
103
+ <>
104
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="key" />
105
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="warning" />
106
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="error" />
107
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="pending" />
108
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="success" />
109
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="info" />
110
+ </>
111
+ );
112
+ }
113
+ `}}},icon:{label:"Icon",examples:{basic:{react:i.code`
114
+ import { KeyValueTag } from "@sps-woodland/tag";
115
+
116
+ function Component() {
117
+ return (
118
+ <>
119
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="key" icon />
120
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="warning" icon />
121
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="error" icon />
122
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="pending" icon />
123
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="success" icon />
124
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="info" icon />
125
+ </>
126
+ );
127
+ }
128
+ `}}},link:{label:"Link",examples:{basic:{react:i.code`
129
+ import { KeyValueTag } from "@sps-woodland/tag";
130
+
131
+ function Component() {
132
+ return (
133
+ <KeyValueTag tagKey="Foo" value="1234" icon href="https://www.google.com" />
134
+ );
135
+ }
136
+ `}}}}},B={"Clickable Tags":R,Tags:D,"Key Value Tags":L};exports.ClickableTag=T;exports.KeyValueTag=k;exports.MANIFEST=B;exports.Tag=u;exports.TagIcons=C;
package/lib/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./clickable-tag/ClickableTag";
2
+ export * from "./key-value-tag/KeyValueTag";
3
+ export * from "./tag/Tag";
4
+ export * from "./manifest";
@@ -0,0 +1,412 @@
1
+ import * as t from "react";
2
+ import { Metadata as b, cl as m, Icon as v } from "@sps-woodland/core";
3
+ import { code as i } from "@spscommerce/utils";
4
+ function K(a, r, e) {
5
+ return r in a ? Object.defineProperty(a, r, {
6
+ value: e,
7
+ enumerable: !0,
8
+ configurable: !0,
9
+ writable: !0
10
+ }) : a[r] = e, a;
11
+ }
12
+ function k(a, r) {
13
+ var e = Object.keys(a);
14
+ if (Object.getOwnPropertySymbols) {
15
+ var l = Object.getOwnPropertySymbols(a);
16
+ r && (l = l.filter(function(n) {
17
+ return Object.getOwnPropertyDescriptor(a, n).enumerable;
18
+ })), e.push.apply(e, l);
19
+ }
20
+ return e;
21
+ }
22
+ function y(a) {
23
+ for (var r = 1; r < arguments.length; r++) {
24
+ var e = arguments[r] != null ? arguments[r] : {};
25
+ r % 2 ? k(Object(e), !0).forEach(function(l) {
26
+ K(a, l, e[l]);
27
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(a, Object.getOwnPropertyDescriptors(e)) : k(Object(e)).forEach(function(l) {
28
+ Object.defineProperty(a, l, Object.getOwnPropertyDescriptor(e, l));
29
+ });
30
+ }
31
+ return a;
32
+ }
33
+ var V = (a, r, e) => {
34
+ for (var l of Object.keys(a)) {
35
+ var n;
36
+ if (a[l] !== ((n = r[l]) !== null && n !== void 0 ? n : e[l]))
37
+ return !1;
38
+ }
39
+ return !0;
40
+ }, u = (a) => (r) => {
41
+ var e = a.defaultClassName, l = y(y({}, a.defaultVariants), r);
42
+ for (var n in l) {
43
+ var c, s = (c = l[n]) !== null && c !== void 0 ? c : a.defaultVariants[n];
44
+ if (s != null) {
45
+ var o = s;
46
+ typeof o == "boolean" && (o = o === !0 ? "true" : "false");
47
+ var d = a.variantClassNames[n][o];
48
+ d && (e += " " + d);
49
+ }
50
+ }
51
+ for (var [p, T] of a.compoundVariants)
52
+ V(p, l, a.defaultVariants) && (e += " " + T);
53
+ return e;
54
+ }, _ = u({ defaultClassName: "_160drw10", variantClassNames: { kind: { blue: "_160drw11", gray: "_160drw12" }, disabled: { true: "_160drw13", false: "_160drw14" } }, defaultVariants: { kind: "blue", disabled: !1 }, compoundVariants: [] }), O = "_160drw1e", E = "_160drw1d", h = u({ defaultClassName: "_160drw15", variantClassNames: { link: { true: "_160drw16", false: "_160drw17" }, disabled: { true: "_160drw18", false: "_160drw19" }, addOrRemove: { true: "_160drw1a", false: "_160drw1b" } }, defaultVariants: { link: !1, disabled: !1, addOrRemove: !1 }, compoundVariants: [[{ disabled: !1, addOrRemove: !0 }, "_160drw1c"]] }), x = "_160drw1f";
55
+ function C({
56
+ children: a,
57
+ className: r,
58
+ onClick: e,
59
+ disabled: l,
60
+ href: n,
61
+ kind: c,
62
+ onAdd: s,
63
+ onRemove: o,
64
+ ...d
65
+ }) {
66
+ const p = t.Children.toArray(a).filter((g) => typeof g == "string").join("");
67
+ t.useEffect(() => {
68
+ if (o && s)
69
+ throw new Error("Clickable tag should have onRemove or onAdd, not both");
70
+ }, [s, o]);
71
+ function T(g) {
72
+ s ? s() : o && o(), g.stopPropagation();
73
+ }
74
+ function N(g) {
75
+ g.stopPropagation(), e && e(g);
76
+ }
77
+ return /* @__PURE__ */ t.createElement("div", {
78
+ className: m(_({ kind: c, disabled: l }), r),
79
+ ...d
80
+ }, /* @__PURE__ */ t.createElement("span", {
81
+ className: m(
82
+ h({
83
+ link: n || e,
84
+ disabled: l,
85
+ addOrRemove: s || o
86
+ })
87
+ ),
88
+ onClick: N,
89
+ title: p
90
+ }, n ? /* @__PURE__ */ t.createElement("a", {
91
+ className: x,
92
+ href: n
93
+ }, a) : a), (s || o) && !l && /* @__PURE__ */ t.createElement("div", {
94
+ className: E,
95
+ onClick: l ? void 0 : T,
96
+ tabIndex: -1,
97
+ "aria-label": s ? "Add" : "Remove"
98
+ }, /* @__PURE__ */ t.createElement(v, {
99
+ className: O,
100
+ "aria-hidden": "true",
101
+ icon: s ? "plus-sign" : "x"
102
+ })));
103
+ }
104
+ b.set(C, {
105
+ name: "Clickable Tag",
106
+ props: {
107
+ disabled: { type: "boolean", default: "false" },
108
+ href: { type: "string" },
109
+ kind: { type: "ClickableTagKind", default: "blue" },
110
+ onAdd: { type: "() => void" },
111
+ onRemove: { type: "() => void" }
112
+ }
113
+ });
114
+ var F = u({ defaultClassName: "_5f3efi0", variantClassNames: { kind: { default: "_5f3efi1", key: "_5f3efi2", warning: "_5f3efi3", error: "_5f3efi4", pending: "_5f3efi5", success: "_5f3efi6", info: "_5f3efi7" } }, defaultVariants: { kind: "default" }, compoundVariants: [] }), P = u({ defaultClassName: "_5f3efi8", variantClassNames: { kind: { default: "_5f3efi9", key: "_5f3efia", warning: "_5f3efib", error: "_5f3efic", pending: "_5f3efid", success: "_5f3efie", info: "_5f3efif" } }, defaultVariants: { kind: "default" }, compoundVariants: [] });
115
+ const j = Object.freeze({
116
+ default: "info-circle",
117
+ key: "info-circle",
118
+ warning: "status-warning",
119
+ error: "status-error",
120
+ pending: "status-in-process",
121
+ success: "status-ok",
122
+ info: "info-circle"
123
+ });
124
+ function f({
125
+ children: a,
126
+ className: r,
127
+ kind: e = "default",
128
+ icon: l,
129
+ ...n
130
+ }) {
131
+ return /* @__PURE__ */ t.createElement("span", {
132
+ className: m(F({ kind: e }), r),
133
+ ...n
134
+ }, l && /* @__PURE__ */ t.createElement(v, {
135
+ className: m(P({ kind: e })),
136
+ icon: j[e]
137
+ }), a);
138
+ }
139
+ b.set(f, {
140
+ name: "Tag",
141
+ props: {
142
+ kind: { type: "TagKind", default: "default" },
143
+ icon: { type: "boolean", default: "false" }
144
+ }
145
+ });
146
+ var I = "c357iq0", q = "c357iq1", R = "c357iq5", D = u({ defaultClassName: "c357iq2", variantClassNames: { href: { true: "c357iq3", false: "c357iq4" } }, defaultVariants: { href: !1 }, compoundVariants: [] });
147
+ function w({
148
+ children: a,
149
+ className: r,
150
+ color: e = "key",
151
+ href: l,
152
+ icon: n,
153
+ tagKey: c,
154
+ value: s,
155
+ ...o
156
+ }) {
157
+ return /* @__PURE__ */ t.createElement("span", {
158
+ className: m(I, r),
159
+ ...o
160
+ }, /* @__PURE__ */ t.createElement(f, {
161
+ className: m(q),
162
+ icon: n,
163
+ kind: e
164
+ }, c), /* @__PURE__ */ t.createElement(f, {
165
+ className: m(D({ href: !!l }))
166
+ }, l ? /* @__PURE__ */ t.createElement("a", {
167
+ className: R,
168
+ href: l
169
+ }, s) : s));
170
+ }
171
+ b.set(w, {
172
+ name: "Key Value Tag",
173
+ props: {
174
+ color: { type: "TagKind", default: "key" },
175
+ href: { type: "string" },
176
+ icon: { type: "boolean", default: "false" },
177
+ tagKey: { type: "string", required: !0 },
178
+ value: { type: "string", required: !0 }
179
+ }
180
+ });
181
+ const L = {
182
+ components: [C],
183
+ examples: {
184
+ basic: {
185
+ label: "Basic Tag",
186
+ examples: {
187
+ basic: {
188
+ react: i`
189
+ import { ClickableTag } from "@sps-woodland/tags";
190
+
191
+ function Component() {
192
+ return (
193
+ <>
194
+ <ClickableTag className="mr-1">Blue</ClickableTag>
195
+ <ClickableTag className="mr-1" kind="gray">Gray</ClickableTag>
196
+ </>
197
+ );
198
+ }
199
+ `
200
+ },
201
+ disabled: {
202
+ react: i`
203
+ import { ClickableTag } from "@sps-woodland/tags";
204
+
205
+ function Component() {
206
+ return (
207
+ <>
208
+ <ClickableTag disabled>Disabled</ClickableTag>
209
+ </>
210
+ );
211
+ }
212
+ `
213
+ }
214
+ }
215
+ },
216
+ button: {
217
+ label: "Button",
218
+ examples: {
219
+ remove: {
220
+ react: i`
221
+ import { ClickableTag } from "@sps-woodland/tags";
222
+
223
+ function Component() {
224
+ return (
225
+ <>
226
+ <ClickableTag className="mr-1" onRemove={() => console.log("removed")}>One</ClickableTag>
227
+ <ClickableTag className="mr-1" onRemove={() => console.log("removed")} kind="gray">Two</ClickableTag>
228
+ </>
229
+ );
230
+ }
231
+ `
232
+ },
233
+ add: {
234
+ react: i`
235
+ import { ClickableTag } from "@sps-woodland/tags";
236
+
237
+ function Component() {
238
+ return (
239
+ <>
240
+ <ClickableTag className="mr-1" onAdd={() => console.log("added")}>One</ClickableTag>
241
+ <ClickableTag className="mr-1" onAdd={() => console.log("added")} kind="gray">Two</ClickableTag>
242
+ </>
243
+ );
244
+ }
245
+ `
246
+ }
247
+ }
248
+ },
249
+ link: {
250
+ label: "Link",
251
+ examples: {
252
+ basic: {
253
+ react: i`
254
+ import { ClickableTag } from "@sps-woodland/tags";
255
+
256
+ function Component() {
257
+ return (
258
+ <>
259
+ <ClickableTag className="mr-1" href="https://google.com">Link</ClickableTag>
260
+ <ClickableTag className="mr-1" onClick={() => window.alert("hi")} kind="gray">Link</ClickableTag>
261
+ </>
262
+ );
263
+ }
264
+ `
265
+ },
266
+ button: {
267
+ react: i`
268
+ import { ClickableTag } from "@sps-woodland/tags";
269
+
270
+ function Component() {
271
+ return (
272
+ <>
273
+ <ClickableTag className="mr-1" href="https://google.com" onRemove={() => console.log("removed")}>Remove</ClickableTag>
274
+ <ClickableTag className="mr-1" onClick={() => window.alert("hi")} onAdd={() => console.log("added")} kind="gray">Add</ClickableTag>
275
+ </>
276
+ );
277
+ }
278
+ `
279
+ }
280
+ }
281
+ }
282
+ }
283
+ }, B = {
284
+ components: [f],
285
+ examples: {
286
+ basic: {
287
+ label: "Basic Tag",
288
+ examples: {
289
+ basic: {
290
+ react: i`
291
+ import { Tag } from "@sps-woodland/tag";
292
+
293
+ function Component() {
294
+ return (
295
+ <>
296
+ <Tag className="mr-1 mb-1">Default</Tag>
297
+ <Tag className="mr-1 mb-1" kind="key">Key</Tag>
298
+ <Tag className="mr-1 mb-1" kind="warning">Warning</Tag>
299
+ <Tag className="mr-1 mb-1" kind="error">Error</Tag>
300
+ <Tag className="mr-1 mb-1" kind="pending">Pending</Tag>
301
+ <Tag className="mr-1 mb-1" kind="success">Success</Tag>
302
+ <Tag className="mr-1 mb-1" kind="info">Info</Tag>
303
+ </>
304
+ )
305
+ }
306
+ `
307
+ }
308
+ }
309
+ },
310
+ withIcon: {
311
+ label: "Tag with icon",
312
+ examples: {
313
+ basic: {
314
+ react: i`
315
+ import { Tag } from "@sps-woodland/tag";
316
+
317
+ function Component() {
318
+ return (
319
+ <>
320
+ <Tag className="mr-1 mb-1" icon>Default</Tag>
321
+ <Tag className="mr-1 mb-1" kind="key" icon>Key</Tag>
322
+ <Tag className="mr-1 mb-1" kind="warning" icon>Warning</Tag>
323
+ <Tag className="mr-1 mb-1" kind="error" icon>Error</Tag>
324
+ <Tag className="mr-1 mb-1" kind="pending" icon>Pending</Tag>
325
+ <Tag className="mr-1 mb-1" kind="success" icon>Success</Tag>
326
+ <Tag className="mr-1 mb-1" kind="info" icon>Info</Tag>
327
+ </>
328
+ )
329
+ }
330
+ `
331
+ }
332
+ }
333
+ }
334
+ }
335
+ }, S = {
336
+ components: [w],
337
+ examples: {
338
+ basic: {
339
+ label: "Basic",
340
+ examples: {
341
+ basic: {
342
+ react: i`
343
+ import { KeyValueTag } from "@sps-woodland/tag";
344
+
345
+ function Component() {
346
+ return (
347
+ <>
348
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="key" />
349
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="warning" />
350
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="error" />
351
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="pending" />
352
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="success" />
353
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="info" />
354
+ </>
355
+ );
356
+ }
357
+ `
358
+ }
359
+ }
360
+ },
361
+ icon: {
362
+ label: "Icon",
363
+ examples: {
364
+ basic: {
365
+ react: i`
366
+ import { KeyValueTag } from "@sps-woodland/tag";
367
+
368
+ function Component() {
369
+ return (
370
+ <>
371
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="key" icon />
372
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="warning" icon />
373
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="error" icon />
374
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="pending" icon />
375
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="success" icon />
376
+ <KeyValueTag className="mr-1" tagKey="Foo" value="1234" color="info" icon />
377
+ </>
378
+ );
379
+ }
380
+ `
381
+ }
382
+ }
383
+ },
384
+ link: {
385
+ label: "Link",
386
+ examples: {
387
+ basic: {
388
+ react: i`
389
+ import { KeyValueTag } from "@sps-woodland/tag";
390
+
391
+ function Component() {
392
+ return (
393
+ <KeyValueTag tagKey="Foo" value="1234" icon href="https://www.google.com" />
394
+ );
395
+ }
396
+ `
397
+ }
398
+ }
399
+ }
400
+ }
401
+ }, M = {
402
+ "Clickable Tags": L,
403
+ Tags: B,
404
+ "Key Value Tags": S
405
+ };
406
+ export {
407
+ C as ClickableTag,
408
+ w as KeyValueTag,
409
+ M as MANIFEST,
410
+ f as Tag,
411
+ j as TagIcons
412
+ };
@@ -0,0 +1,13 @@
1
+ export declare const keyValueTag: string;
2
+ export declare const keyValueTagKey: string;
3
+ export declare const keyValueTagValue: import("@vanilla-extract/recipes/dist/declarations/src/types").RuntimeFn<{
4
+ href: {
5
+ true: {
6
+ cursor: "pointer";
7
+ textDecoration: "underline";
8
+ color: string;
9
+ };
10
+ false: {};
11
+ };
12
+ }>;
13
+ export declare const keyValueTagLink: string;
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ import type { ComponentProps } from "@sps-woodland/core";
3
+ import type { TagKind } from "../tag/Tag";
4
+ export declare function KeyValueTag({ children, className, color, href, icon, tagKey, value, ...rest }: ComponentProps<{
5
+ color: TagKind;
6
+ href?: string;
7
+ icon?: boolean;
8
+ tagKey: string;
9
+ value: string;
10
+ }, HTMLDivElement>): React.ReactElement;
@@ -0,0 +1,2 @@
1
+ import type { ComponentManifestEntry } from "@sps-woodland/core";
2
+ export declare const KeyValueTagExamples: ComponentManifestEntry;
@@ -0,0 +1,2 @@
1
+ import type { ComponentManifest } from "@sps-woodland/core";
2
+ export declare const MANIFEST: ComponentManifest;
package/lib/style.css ADDED
@@ -0,0 +1 @@
1
+ ._160drw10{border-radius:.125rem;display:inline-flex;color:#09638d;font-size:.75rem;font-weight:600;height:1.125rem;line-height:.75rem;max-width:100%}._160drw11{background-color:#e6f2f8}._160drw12{background-color:#e9e9ea}._160drw13{background-color:#fff;border-width:.0625rem;border-style:solid;border-color:#d2d4d4;color:#717779;cursor:not-allowed}._160drw15{border-radius:.125rem;flex-grow:1;flex-shrink:1;height:1.125rem;padding:.125rem .25rem;text-overflow:ellipsis;white-space:nowrap}._160drw16{cursor:pointer;text-decoration:underline}._160drw16:hover{background-color:#09638d;color:#e6f2f8}._160drw1c{border-top-left-radius:.125rem;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:.125rem}._160drw1d{border-top-left-radius:0;border-top-right-radius:.125rem;border-bottom-right-radius:.125rem;border-bottom-left-radius:0;color:#09638d;height:1.125rem;line-height:.75rem;padding:.125rem .25rem}._160drw1d:focus,._160drw1d:hover{background-color:#09638d;color:#e6f2f8;cursor:pointer}._160drw1e{cursor:pointer;font-size:.625rem;position:relative;text-decoration:none;top:-.0625rem;vertical-align:middle}span>._160drw1f{color:#09638d}span:hover>._160drw1f{color:#e6f2f8}._5f3efi0{border-radius:.125rem;display:inline-block;font-size:.75rem;font-weight:600;line-height:.75rem;overflow:hidden;padding:.125rem .25rem;text-align:left;text-overflow:ellipsis;vertical-align:middle;white-space:nowrap}._5f3efi1{background:#e9e9ea;color:#4b5356}._5f3efi2{background:#4b5356;color:#fff}._5f3efi3{background:#e7760b;color:#fff}._5f3efi4{background:#de002e;color:#fff}._5f3efi5{background:#91467f;color:#fff}._5f3efi6{background:#0b8940;color:#fff}._5f3efi7{background:#007db8;color:#fff}._5f3efi8{font-size:.75rem;line-height:.625rem;margin-right:.25rem}._5f3efi8:before{vertical-align:text-bottom}._5f3efi9{display:none}.c357iq0{display:inline-block}.c357iq1{border-top-left-radius:.125rem;border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:.125rem}.c357iq2{background:#ffffff;border-top-left-radius:0;border-top-right-radius:.125rem;border-bottom-right-radius:.125rem;border-bottom-left-radius:0;padding:.125rem .25rem;box-shadow:.0625rem 0 #4b5356 inset,-.0625rem 0 #4b5356 inset,0 .0625rem #4b5356 inset,0 -.0625rem #4b5356 inset}.c357iq3{cursor:pointer;text-decoration:underline;color:#4b5356}.c357iq5,.c357iq5:hover{color:#4b5356}
@@ -0,0 +1,45 @@
1
+ export declare const tag: import("@vanilla-extract/recipes/dist/declarations/src/types").RuntimeFn<{
2
+ kind: {
3
+ default: {
4
+ background: string;
5
+ color: string;
6
+ };
7
+ key: {
8
+ background: string;
9
+ color: string;
10
+ };
11
+ warning: {
12
+ background: string;
13
+ color: string;
14
+ };
15
+ error: {
16
+ background: string;
17
+ color: string;
18
+ };
19
+ pending: {
20
+ background: string;
21
+ color: string;
22
+ };
23
+ success: {
24
+ background: string;
25
+ color: string;
26
+ };
27
+ info: {
28
+ background: string;
29
+ color: string;
30
+ };
31
+ };
32
+ }>;
33
+ export declare const tagIcon: import("@vanilla-extract/recipes/dist/declarations/src/types").RuntimeFn<{
34
+ kind: {
35
+ default: {
36
+ display: "none";
37
+ };
38
+ key: {};
39
+ warning: {};
40
+ error: {};
41
+ pending: {};
42
+ success: {};
43
+ info: {};
44
+ };
45
+ }>;
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ import type { ComponentProps } from "@sps-woodland/core";
3
+ import type { IconName } from "@sps-woodland/tokens";
4
+ import type { RecipeVariants } from "@vanilla-extract/recipes";
5
+ import { tag } from "./Tag.css";
6
+ export declare type TagKind = Required<NonNullable<RecipeVariants<typeof tag>>>["kind"];
7
+ export declare const TagIcons: Record<TagKind, IconName>;
8
+ export declare function Tag({ children, className, kind, icon, ...rest }: ComponentProps<{
9
+ kind?: TagKind;
10
+ icon?: boolean;
11
+ }, HTMLDivElement>): React.ReactElement;
@@ -0,0 +1,2 @@
1
+ import type { ComponentManifestEntry } from "@sps-woodland/core";
2
+ export declare const TagExamples: ComponentManifestEntry;
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@sps-woodland/tags",
3
+ "description": "SPS Woodland Design System tag components",
4
+ "version": "7.0.0",
5
+ "author": "SPS Commerce",
6
+ "license": "UNLICENSED",
7
+ "repository": "https://github.com/SPSCommerce/woodland/tree/main/packages/@sps-woodland/cards",
8
+ "homepage": "https://github.com/SPSCommerce/woodland/tree/master/packages/@sps-woodland/cards#readme",
9
+ "main": "./lib/index.es.js",
10
+ "module": "./lib/index.es.js",
11
+ "types": "./lib/index.d.ts",
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "peerDependencies": {
16
+ "@sps-woodland/core": "7.0.0",
17
+ "@sps-woodland/tokens": "7.0.0",
18
+ "@spscommerce/utils": "^6.12.1",
19
+ "react": "^16.9.0",
20
+ "react-dom": "^16.9.0"
21
+ },
22
+ "devDependencies": {
23
+ "@sps-woodland/core": "7.0.0",
24
+ "@sps-woodland/tabs": "7.0.0",
25
+ "@sps-woodland/tokens": "7.0.0",
26
+ "@spscommerce/utils": "^6.12.1",
27
+ "@vanilla-extract/css": "^1.9.1",
28
+ "@vanilla-extract/recipes": "^0.2.5",
29
+ "react": "^16.9.0",
30
+ "react-dom": "^16.9.0"
31
+ },
32
+ "scripts": {
33
+ "build": "pnpm run build:js && pnpm run build:types",
34
+ "build:js": "vite build",
35
+ "build:types": "tsc --emitDeclarationOnly --declaration --declarationDir lib",
36
+ "watch": "vite build --watch",
37
+ "clean": "git clean -fdX",
38
+ "pub": "node ../../../scripts/publish-package.js"
39
+ }
40
+ }
package/vite.config.js ADDED
@@ -0,0 +1,21 @@
1
+ import path from "path";
2
+ import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
3
+ import { defineConfig } from "vite";
4
+
5
+ import pkg from "./package.json";
6
+
7
+ export default defineConfig({
8
+ plugins: [vanillaExtractPlugin()],
9
+ build: {
10
+ lib: {
11
+ entry: path.resolve(__dirname, "src/index.ts"),
12
+ formats: ["es", "cjs"],
13
+ fileName: (format) => `index.${format}.js`,
14
+ },
15
+ outDir: path.resolve(__dirname, "./lib"),
16
+ emptyOutDir: false,
17
+ rollupOptions: {
18
+ external: pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : [],
19
+ },
20
+ },
21
+ });