@sps-woodland/action-bar 8.3.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/action-bar](https://github.com/SPSCommerce/woodland/tree/master/packages/@sps-woodland/action-bar#readme)
2
+
3
+ SPS Woodland Design System Action Bar component
@@ -0,0 +1,9 @@
1
+ declare const root: string;
2
+ declare const content: string;
3
+ declare const contentMainBar: string;
4
+ declare const itemsSelected: string;
5
+ declare const itemsSelectedTag: string;
6
+ declare const actionButtons: string;
7
+ declare const clearSelected: string;
8
+ declare const additionalContent: string;
9
+ export { root, content, contentMainBar, itemsSelected, itemsSelectedTag, actionButtons, clearSelected, additionalContent, };
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ import type { ComponentProps } from "@sps-woodland/core";
3
+ export declare function ActionBar({ className, children, clearSelected, itemsSelected, itemsSelectedLabel, ...rest }: ComponentProps<{
4
+ clearSelected: () => void;
5
+ itemsSelected: number | string;
6
+ itemsSelectedLabel?: string;
7
+ }>): React.ReactElement;
@@ -0,0 +1,2 @@
1
+ import type { ComponentManifestEntry } from "@sps-woodland/core";
2
+ export declare const ActionBarExamples: ComponentManifestEntry;
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ import type { ComponentProps, BoxProps } from "@sps-woodland/core";
3
+ export declare function ActionBarAdditionalContent({ className, children, ...rest }: ComponentProps<Record<string, unknown>> & BoxProps): React.ReactElement;
@@ -0,0 +1,119 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const B=require("react"),S=require("@sps-woodland/buttons"),a=require("@sps-woodland/core"),h=require("@sps-woodland/tags"),r=require("@spscommerce/utils");function A(t){if(t&&t.__esModule)return t;const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(o,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return o.default=t,Object.freeze(o)}const e=A(B);var f="_9yu2s95",b="_9yu2s97",w="_9yu2s96",g="_9yu2s91",v="_9yu2s92",x="_9yu2s93",C="_9yu2s94",y="_9yu2s90";function c({className:t,children:o,...n}){return e.createElement(a.Box,{className:a.cl(b,t),...n},o)}a.Metadata.set(c,{name:"ActionBarAdditionalContent",props:{}});function l({className:t,children:o,clearSelected:n,itemsSelected:s,itemsSelectedLabel:i,...m}){const{t:d}=e.useContext(a.I18nContext),[u,p]=a.selectChildren(o,[{type:c}]);return Number(s)>0?e.createElement("div",{className:a.cl(y,t),...m},e.createElement("div",{className:g},u,e.createElement("div",{className:v},e.createElement("div",{className:x},e.createElement(h.Tag,{kind:"info",className:C},s),i!=null?i:d("design-system:listActionBar.itemsSelected")),e.createElement("div",{className:f},p),e.createElement("div",{className:w},e.createElement(S.Button,{kind:"link",icon:"x",onPress:n},d("design-system:listActionBar.clearSelected")))))):e.createElement(e.Fragment,null)}a.Metadata.set(l,{name:"ActionBar",props:{clearSelected:{type:"() => void",required:!0},itemsSelected:{type:"number | string",required:!0},itemsSelectedLabel:{type:"string",required:!1}}});const E={components:[l,c],description:()=>e.createElement("p",null,"The Action Bar contains the action buttons relevant to selected items from a Table List, Row List, or Card List. The Action Bar is only visible when one or more list items have been selected and appears anchored to the bottom of the page above all other content."),examples:{general:{label:"General Usage",description:""},actionBar:{label:"Action Bar",description:"This example makes use of the Text Buttons + Icon Buttons + Basic Buttons Group.",examples:{basic:{react:r.code`
2
+ import { ActionBar } from "@sps-woodland/action-bar";
3
+ import { Button } from "@sps-woodland/buttons";
4
+ import { Vr } from "@sps-woodland/core";
5
+
6
+ function ActionBarExample() {
7
+ const [itemsSelected, setItemsSelected] = React.useState(0);
8
+
9
+ function handleClear() {
10
+ setItemsSelected(0);
11
+ }
12
+
13
+ function showExample() {
14
+ setItemsSelected(3);
15
+ }
16
+
17
+ return <>
18
+ <Button kind="link" onPress={showExample}>
19
+ Show Action Bar
20
+ </Button>
21
+ <ActionBar
22
+ itemsSelected={itemsSelected}
23
+ clearSelected={handleClear}
24
+ >
25
+ <Button kind="link" className={sp({ mr: "sm" })}>
26
+ Text Button
27
+ </Button>
28
+ <Vr/>
29
+ <Button kind="icon" icon="printer" aria-label="Print" />
30
+ <Button
31
+ kind="icon"
32
+ icon="download-cloud"
33
+ aria-label="Download"
34
+ />
35
+ <Vr/>
36
+ <Button className={sp({ mx: "sm" })}>Button</Button>
37
+ <Button
38
+ kind="key"
39
+ className={sp({ mr: "sm" })}
40
+ >
41
+ Button
42
+ </Button>
43
+ <Button kind="confirm">Button</Button>
44
+ </ActionBar>
45
+ </>
46
+ }
47
+ `}}},customLabel:{label:'Custom "Items Selected" Label',description:"If needed, the text that appears next to the Tag indicating the number of items that have been selected can be customized.",examples:{basic:{react:r.code`
48
+ import { ActionBar } from "@sps-woodland/action-bar";
49
+ import { Button } from "@sps-woodland/buttons";
50
+
51
+ function ActionBarExample() {
52
+ const [itemsSelected, setItemsSelected] = React.useState([]);
53
+
54
+ const [data, setData] = React.useState([
55
+ { id: 1, name: "Item 1", cost: 100 },
56
+ { id: 2, name: "Item 2", cost: 7.99 },
57
+ { id: 3, name: "Item 3", cost: 23.45 },
58
+ ]);
59
+
60
+ function handleClear() {
61
+ setItemsSelected([]);
62
+ }
63
+
64
+ function showExample() {
65
+ setItemsSelected([1, 2, 3]);
66
+ }
67
+
68
+ const costOfSelectedItems = itemsSelected.reduce((acc, id) => {
69
+ const item = data.find((d) => d.id === id);
70
+ return acc + item.cost;
71
+ }, 0);
72
+
73
+ return <>
74
+ <Button kind="link" onPress={showExample}>
75
+ Show Action Bar
76
+ </Button>
77
+ <ActionBar
78
+ itemsSelected={itemsSelected.length}
79
+ itemsSelectedLabel={\`\${itemsSelected.length} Items Selected - $\${costOfSelectedItems}\`}
80
+ clearSelected={handleClear}
81
+ >
82
+ <Button kind="confirm">Button</Button>
83
+ </ActionBar>
84
+ </>
85
+ }
86
+ `}}},addlContent:{label:"Additional Content",description:"An Action Bar may contain additional content that is not part of the action buttons group, which is displayed above the main content.",examples:{basic:{react:r.code`
87
+ import { ActionBar, ActionBarAdditionalContent } from "@sps-woodland/action-bar";
88
+ import { Button } from "@sps-woodland/buttons";
89
+ import { Card } from "@sps-woodland/cards";
90
+
91
+ function ActionBarExample() {
92
+ const [itemsSelected, setItemsSelected] = React.useState(0);
93
+
94
+ function handleClear() {
95
+ setItemsSelected(0);
96
+ }
97
+
98
+ function showExample() {
99
+ setItemsSelected(3);
100
+ }
101
+
102
+ return <>
103
+ <Button kind="link" onPress={showExample}>
104
+ Show Action Bar
105
+ </Button>
106
+ <ActionBar
107
+ itemsSelected={itemsSelected}
108
+ clearSelected={handleClear}
109
+ >
110
+ <ActionBarAdditionalContent textAlign="center">
111
+ <Card>
112
+ <p>hey what's goin on here</p>
113
+ </Card>
114
+ </ActionBarAdditionalContent>
115
+ <Button kind="confirm">Button</Button>
116
+ </ActionBar>
117
+ </>
118
+ }
119
+ `}}}}},I={"Action Bar":E};exports.ActionBar=l;exports.ActionBarAdditionalContent=c;exports.MANIFEST=I;
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./ActionBar";
2
+ export * from "./ActionBarAdditionalContent";
3
+ export * from "./manifest";
@@ -0,0 +1,223 @@
1
+ import * as t from "react";
2
+ import { Button as h } from "@sps-woodland/buttons";
3
+ import { Metadata as l, Box as S, cl as d, I18nContext as A, selectChildren as f } from "@sps-woodland/core";
4
+ import { Tag as b } from "@sps-woodland/tags";
5
+ import { code as s } from "@spscommerce/utils";
6
+ var x = "_9yu2s95", C = "_9yu2s97", w = "_9yu2s96", v = "_9yu2s91", E = "_9yu2s92", I = "_9yu2s93", k = "_9yu2s94", y = "_9yu2s90";
7
+ function i({
8
+ className: e,
9
+ children: n,
10
+ ...o
11
+ }) {
12
+ return /* @__PURE__ */ t.createElement(
13
+ S,
14
+ {
15
+ className: d(C, e),
16
+ ...o
17
+ },
18
+ n
19
+ );
20
+ }
21
+ l.set(i, {
22
+ name: "ActionBarAdditionalContent",
23
+ props: {}
24
+ });
25
+ function m({
26
+ className: e,
27
+ children: n,
28
+ clearSelected: o,
29
+ itemsSelected: c,
30
+ itemsSelectedLabel: a,
31
+ ...u
32
+ }) {
33
+ const { t: r } = t.useContext(A), [B, p] = f(n, [
34
+ { type: i }
35
+ ]);
36
+ return Number(c) > 0 ? /* @__PURE__ */ t.createElement(
37
+ "div",
38
+ {
39
+ className: d(y, e),
40
+ ...u
41
+ },
42
+ /* @__PURE__ */ t.createElement("div", { className: v }, B, /* @__PURE__ */ t.createElement("div", { className: E }, /* @__PURE__ */ t.createElement("div", { className: I }, /* @__PURE__ */ t.createElement(b, { kind: "info", className: k }, c), a != null ? a : r("design-system:listActionBar.itemsSelected")), /* @__PURE__ */ t.createElement("div", { className: x }, p), /* @__PURE__ */ t.createElement("div", { className: w }, /* @__PURE__ */ t.createElement(h, { kind: "link", icon: "x", onPress: o }, r("design-system:listActionBar.clearSelected")))))
43
+ ) : /* @__PURE__ */ t.createElement(t.Fragment, null);
44
+ }
45
+ l.set(m, {
46
+ name: "ActionBar",
47
+ props: {
48
+ clearSelected: {
49
+ type: "() => void",
50
+ required: !0
51
+ },
52
+ itemsSelected: {
53
+ type: "number | string",
54
+ required: !0
55
+ },
56
+ itemsSelectedLabel: {
57
+ type: "string",
58
+ required: !1
59
+ }
60
+ }
61
+ });
62
+ const g = {
63
+ components: [m, i],
64
+ description: () => /* @__PURE__ */ t.createElement("p", null, "The Action Bar contains the action buttons relevant to selected items from a Table List, Row List, or Card List. The Action Bar is only visible when one or more list items have been selected and appears anchored to the bottom of the page above all other content."),
65
+ examples: {
66
+ general: {
67
+ label: "General Usage",
68
+ description: ""
69
+ },
70
+ actionBar: {
71
+ label: "Action Bar",
72
+ description: "This example makes use of the Text Buttons + Icon Buttons + Basic Buttons Group.",
73
+ examples: {
74
+ basic: {
75
+ react: s`
76
+ import { ActionBar } from "@sps-woodland/action-bar";
77
+ import { Button } from "@sps-woodland/buttons";
78
+ import { Vr } from "@sps-woodland/core";
79
+
80
+ function ActionBarExample() {
81
+ const [itemsSelected, setItemsSelected] = React.useState(0);
82
+
83
+ function handleClear() {
84
+ setItemsSelected(0);
85
+ }
86
+
87
+ function showExample() {
88
+ setItemsSelected(3);
89
+ }
90
+
91
+ return <>
92
+ <Button kind="link" onPress={showExample}>
93
+ Show Action Bar
94
+ </Button>
95
+ <ActionBar
96
+ itemsSelected={itemsSelected}
97
+ clearSelected={handleClear}
98
+ >
99
+ <Button kind="link" className={sp({ mr: "sm" })}>
100
+ Text Button
101
+ </Button>
102
+ <Vr/>
103
+ <Button kind="icon" icon="printer" aria-label="Print" />
104
+ <Button
105
+ kind="icon"
106
+ icon="download-cloud"
107
+ aria-label="Download"
108
+ />
109
+ <Vr/>
110
+ <Button className={sp({ mx: "sm" })}>Button</Button>
111
+ <Button
112
+ kind="key"
113
+ className={sp({ mr: "sm" })}
114
+ >
115
+ Button
116
+ </Button>
117
+ <Button kind="confirm">Button</Button>
118
+ </ActionBar>
119
+ </>
120
+ }
121
+ `
122
+ }
123
+ }
124
+ },
125
+ customLabel: {
126
+ label: 'Custom "Items Selected" Label',
127
+ description: "If needed, the text that appears next to the Tag indicating the number of items that have been selected can be customized.",
128
+ examples: {
129
+ basic: {
130
+ react: s`
131
+ import { ActionBar } from "@sps-woodland/action-bar";
132
+ import { Button } from "@sps-woodland/buttons";
133
+
134
+ function ActionBarExample() {
135
+ const [itemsSelected, setItemsSelected] = React.useState([]);
136
+
137
+ const [data, setData] = React.useState([
138
+ { id: 1, name: "Item 1", cost: 100 },
139
+ { id: 2, name: "Item 2", cost: 7.99 },
140
+ { id: 3, name: "Item 3", cost: 23.45 },
141
+ ]);
142
+
143
+ function handleClear() {
144
+ setItemsSelected([]);
145
+ }
146
+
147
+ function showExample() {
148
+ setItemsSelected([1, 2, 3]);
149
+ }
150
+
151
+ const costOfSelectedItems = itemsSelected.reduce((acc, id) => {
152
+ const item = data.find((d) => d.id === id);
153
+ return acc + item.cost;
154
+ }, 0);
155
+
156
+ return <>
157
+ <Button kind="link" onPress={showExample}>
158
+ Show Action Bar
159
+ </Button>
160
+ <ActionBar
161
+ itemsSelected={itemsSelected.length}
162
+ itemsSelectedLabel={\`\${itemsSelected.length} Items Selected - $\${costOfSelectedItems}\`}
163
+ clearSelected={handleClear}
164
+ >
165
+ <Button kind="confirm">Button</Button>
166
+ </ActionBar>
167
+ </>
168
+ }
169
+ `
170
+ }
171
+ }
172
+ },
173
+ addlContent: {
174
+ label: "Additional Content",
175
+ description: "An Action Bar may contain additional content that is not part of the action buttons group, which is displayed above the main content.",
176
+ examples: {
177
+ basic: {
178
+ react: s`
179
+ import { ActionBar, ActionBarAdditionalContent } from "@sps-woodland/action-bar";
180
+ import { Button } from "@sps-woodland/buttons";
181
+ import { Card } from "@sps-woodland/cards";
182
+
183
+ function ActionBarExample() {
184
+ const [itemsSelected, setItemsSelected] = React.useState(0);
185
+
186
+ function handleClear() {
187
+ setItemsSelected(0);
188
+ }
189
+
190
+ function showExample() {
191
+ setItemsSelected(3);
192
+ }
193
+
194
+ return <>
195
+ <Button kind="link" onPress={showExample}>
196
+ Show Action Bar
197
+ </Button>
198
+ <ActionBar
199
+ itemsSelected={itemsSelected}
200
+ clearSelected={handleClear}
201
+ >
202
+ <ActionBarAdditionalContent textAlign="center">
203
+ <Card>
204
+ <p>hey what's goin on here</p>
205
+ </Card>
206
+ </ActionBarAdditionalContent>
207
+ <Button kind="confirm">Button</Button>
208
+ </ActionBar>
209
+ </>
210
+ }
211
+ `
212
+ }
213
+ }
214
+ }
215
+ }
216
+ }, P = {
217
+ "Action Bar": g
218
+ };
219
+ export {
220
+ m as ActionBar,
221
+ i as ActionBarAdditionalContent,
222
+ P as MANIFEST
223
+ };
@@ -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
+ ._9yu2s90{background-color:oklch(100% 0 0);display:flex;bottom:0;position:fixed;justify-content:center;left:0;right:0;padding:.5rem;box-shadow:0 0 .25rem .25rem oklch(26.99% .015 226.65 / .1);z-index:99}._9yu2s91{display:flex;flex-direction:column;max-width:77.5rem;width:100%}._9yu2s92{height:2rem;display:flex;align-items:center;width:100%}._9yu2s93{flex:1}._9yu2s94{margin-right:.25rem}._9yu2s95{display:flex;flex:2;align-items:center;justify-content:center}._9yu2s96{flex:1;text-align:right}._9yu2s97{margin-bottom:.5rem}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@sps-woodland/action-bar",
3
+ "description": "SPS Woodland Design System Action Bar component",
4
+ "version": "8.3.0",
5
+ "author": "SPS Commerce",
6
+ "license": "UNLICENSED",
7
+ "repository": "https://github.com/SPSCommerce/woodland/tree/main/packages/@sps-woodland/action-bar",
8
+ "homepage": "https://github.com/SPSCommerce/woodland/tree/master/packages/@sps-woodland/action-bar#readme",
9
+ "type": "module",
10
+ "module": "./lib/index.es.js",
11
+ "main": "./lib/index.cjs.js",
12
+ "types": "./lib/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "import": "./lib/index.es.js",
16
+ "require": "./lib/index.cjs.js",
17
+ "default": "./lib/index.cjs.js",
18
+ "types": "./lib/index.d.ts"
19
+ },
20
+ "./lib/style.css": {
21
+ "import": "./lib/style.css",
22
+ "require": "./lib/style.css"
23
+ }
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "peerDependencies": {
29
+ "@spscommerce/utils": "^6.12.1",
30
+ "react": "^16.14.0",
31
+ "react-dom": "^16.14.0",
32
+ "@sps-woodland/buttons": "8.3.0",
33
+ "@sps-woodland/core": "8.3.0",
34
+ "@sps-woodland/tags": "8.3.0",
35
+ "@sps-woodland/tokens": "8.3.0"
36
+ },
37
+ "devDependencies": {
38
+ "@spscommerce/utils": "^6.12.1",
39
+ "@vanilla-extract/css": "^1.9.3",
40
+ "@vanilla-extract/recipes": "^0.2.5",
41
+ "react": "^16.14.0",
42
+ "react-dom": "^16.14.0",
43
+ "@sps-woodland/buttons": "8.3.0",
44
+ "@sps-woodland/core": "8.3.0",
45
+ "@sps-woodland/tags": "8.3.0",
46
+ "@sps-woodland/tokens": "8.3.0"
47
+ },
48
+ "scripts": {
49
+ "build": "pnpm run build:js && pnpm run build:types",
50
+ "build:js": "vite build",
51
+ "build:types": "tsc --emitDeclarationOnly --declaration --declarationDir lib",
52
+ "watch": "vite build --watch",
53
+ "clean": "git clean -fdX",
54
+ "pub": "node ../../../scripts/publish-package.js"
55
+ }
56
+ }
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
+ });