@sps-woodland/content-row 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 +3 -0
- package/lib/ContentRowExamples.d.ts +2 -0
- package/lib/content-row/ContentRow.css.d.ts +44 -0
- package/lib/content-row/ContentRow.d.ts +15 -0
- package/lib/content-row-col/ContentRowCol.css.d.ts +21 -0
- package/lib/content-row-col/ContentRowCol.d.ts +8 -0
- package/lib/content-row-expansion/ContentRowExpansion.d.ts +3 -0
- package/lib/index.cjs.js +397 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.es.js +623 -0
- package/lib/manifest.d.ts +2 -0
- package/lib/style.css +1 -0
- package/package.json +47 -0
- package/vite.config.js +21 -0
package/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
export declare const expandedVar: any;
|
2
|
+
export declare const contentRow: import("@vanilla-extract/recipes/dist/declarations/src/types").RuntimeFn<{
|
3
|
+
expanded: {
|
4
|
+
true: {
|
5
|
+
vars: {
|
6
|
+
[x: number]: string;
|
7
|
+
};
|
8
|
+
};
|
9
|
+
false: {
|
10
|
+
vars: {
|
11
|
+
[x: number]: string;
|
12
|
+
};
|
13
|
+
};
|
14
|
+
};
|
15
|
+
}>;
|
16
|
+
export declare const contentRowColGroup: import("@vanilla-extract/recipes/dist/declarations/src/types").RuntimeFn<{
|
17
|
+
expanded: {
|
18
|
+
true: {
|
19
|
+
borderTopLeftRadius: string;
|
20
|
+
borderTopRightRadius: string;
|
21
|
+
borderBottomRightRadius: string;
|
22
|
+
borderBottomLeftRadius: string;
|
23
|
+
};
|
24
|
+
false: {};
|
25
|
+
};
|
26
|
+
selected: {
|
27
|
+
true: {
|
28
|
+
background: string;
|
29
|
+
borderColor: string;
|
30
|
+
};
|
31
|
+
false: {};
|
32
|
+
};
|
33
|
+
cardSpacing: {
|
34
|
+
true: {
|
35
|
+
borderRadius: string;
|
36
|
+
marginTop: string;
|
37
|
+
};
|
38
|
+
false: {};
|
39
|
+
};
|
40
|
+
}>;
|
41
|
+
export declare const expandButton: string;
|
42
|
+
export declare const expandIcon: string;
|
43
|
+
export declare const contentRowExpansion: string;
|
44
|
+
export declare const section: string;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import { ComponentProps } from "@sps-woodland/core";
|
3
|
+
export declare function ContentRow({ children, className, alternateLayout, initiallyExpanded, cardSpacing, expanded, onBeforeCollapsed, onBeforeExpanded, onSelectionChange, onCollapsed, onExpanded, selectable, selected, ...rest }: ComponentProps<{
|
4
|
+
alternateLayout: boolean;
|
5
|
+
initiallyExpanded: boolean;
|
6
|
+
cardSpacing: boolean;
|
7
|
+
expanded: boolean;
|
8
|
+
onBeforeCollapsed: () => boolean;
|
9
|
+
onBeforeExpanded: () => boolean;
|
10
|
+
onSelectionChange: React.ChangeEventHandler<HTMLInputElement>;
|
11
|
+
onCollapsed: () => void;
|
12
|
+
onExpanded: () => void;
|
13
|
+
selectable: boolean;
|
14
|
+
selected: boolean;
|
15
|
+
}, HTMLDivElement>): React.ReactElement;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
export declare const contentRowCol: import("@vanilla-extract/recipes/dist/declarations/src/types").RuntimeFn<{
|
2
|
+
lean: {
|
3
|
+
true: {
|
4
|
+
paddingTop: string;
|
5
|
+
paddingRight: string;
|
6
|
+
paddingBottom: string;
|
7
|
+
paddingLeft: string;
|
8
|
+
};
|
9
|
+
false: {};
|
10
|
+
};
|
11
|
+
borderless: {
|
12
|
+
true: {};
|
13
|
+
false: {
|
14
|
+
selectors: {
|
15
|
+
"&:not(:first-child)": {
|
16
|
+
borderLeft: `${string} ${string} ${string}`;
|
17
|
+
};
|
18
|
+
};
|
19
|
+
};
|
20
|
+
};
|
21
|
+
}>;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import { ComponentProps } from "@sps-woodland/core";
|
3
|
+
export declare function ContentRowCol({ children, className, borderless, lean, widthPx, widthRem, style, ...rest }: ComponentProps<{
|
4
|
+
borderless?: boolean;
|
5
|
+
lean?: boolean;
|
6
|
+
widthPx?: number;
|
7
|
+
widthRem?: number;
|
8
|
+
}, HTMLDivElement>): React.ReactElement;
|
package/lib/index.cjs.js
ADDED
@@ -0,0 +1,397 @@
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const z=require("react"),a=require("@sps-woodland/core"),F=require("@spscommerce/ds-react"),i=require("@spscommerce/utils");function O(e){if(e&&e.__esModule)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const s=O(z);function A(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function v(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),o.push.apply(o,n)}return o}function N(e){for(var t=1;t<arguments.length;t++){var o=arguments[t]!=null?arguments[t]:{};t%2?v(Object(o),!0).forEach(function(n){A(e,n,o[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):v(Object(o)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))})}return e}var D=(e,t,o)=>{for(var n of Object.keys(e)){var r;if(e[n]!==((r=t[n])!==null&&r!==void 0?r:o[n]))return!1}return!0},y=e=>t=>{var o=e.defaultClassName,n=N(N({},e.defaultVariants),t);for(var r in n){var l,d=(l=n[r])!==null&&l!==void 0?l:e.defaultVariants[r];if(d!=null){var c=d;typeof c=="boolean"&&(c=c===!0?"true":"false");var m=e.variantClassNames[r][c];m&&(o+=" "+m)}}for(var[C,u]of e.compoundVariants)D(C,n,e.defaultVariants)&&(o+=" "+u);return o},H=y({defaultClassName:"_1mxrufv0",variantClassNames:{lean:{true:"_1mxrufv1",false:"_1mxrufv2"},borderless:{true:"_1mxrufv3",false:"_1mxrufv4"}},defaultVariants:{lean:!1,borderless:!1},compoundVariants:[]});function p({children:e,className:t,borderless:o,lean:n,widthPx:r,widthRem:l,style:d,...c}){const m=r?r/16:l,C=m?{...d,width:`${m}rem`}:d;return s.createElement("div",{className:a.cl(H({lean:n,borderless:o}),t),...c,style:C},e)}a.Metadata.set(p,{name:"Content Row Col",props:{borderless:{type:"boolean"},lean:{type:"boolean"},widthPx:{type:"number"},widthRem:{type:"number"}}});var T=y({defaultClassName:"_11ztjee1",variantClassNames:{expanded:{true:"_11ztjee2",false:"_11ztjee3"}},defaultVariants:{expanded:!1},compoundVariants:[]}),q=y({defaultClassName:"_11ztjee4",variantClassNames:{expanded:{true:"_11ztjee5",false:"_11ztjee6"},selected:{true:"_11ztjee7",false:"_11ztjee8"},cardSpacing:{true:"_11ztjee9",false:"_11ztjeea"}},defaultVariants:{expanded:!1,selected:!1,cardSpacing:!1},compoundVariants:[[{expanded:!0,cardSpacing:!0},"_11ztjeeb"]]}),G="_11ztjeee",K="_11ztjeec",W="_11ztjeed",M="_11ztjeef";function f({children:e,className:t,...o}){return s.createElement("div",{className:a.cl(G,t),...o},e)}a.Metadata.set(f,{name:"Content Row Expansion"});function x({children:e,className:t,alternateLayout:o=!1,initiallyExpanded:n=!1,cardSpacing:r=!1,expanded:l,onBeforeCollapsed:d,onBeforeExpanded:c,onSelectionChange:m,onCollapsed:C,onExpanded:u,selectable:h=!1,selected:g,...P}){const[I,[R]]=a.selectChildren(e,[{type:p},{type:f}]),{t:V}=s.useContext(a.I18nContext),[b,E]=s.useState(n),w=typeof l=="boolean"?l:b;function _(j){j.stopPropagation(),w&&(!d||d())?(E(!1),C&&C()):!w&&(!c||c())&&(E(!0),u&&u())}const S=()=>s.createElement(F.SpsCheckbox,{checked:g,onChange:m}),k=()=>s.createElement("button",{type:"button",className:a.cl(K),onClick:_,"aria-label":V(`design-system:contentRow.${w?"collapse":"expand"}`)},s.createElement(a.Icon,{className:a.cl(W),icon:w?"minus-circle":"plus-circle"}));return s.createElement("div",{className:a.cl(T({expanded:l||b}),t),...P},s.createElement("div",{className:a.cl(q({expanded:l||b,selected:g,cardSpacing:r}))},h&&!o&&s.createElement(p,{widthPx:46},s.createElement(S,null)),R&&!o&&s.createElement(p,{widthPx:44},s.createElement(k,null)),R&&h&&o&&s.createElement(p,{widthPx:46},s.createElement("section",{className:M},s.createElement(S,null)),s.createElement("section",{className:M},s.createElement(k,null))),I),R)}a.Metadata.set(x,{name:"Content Row",props:{alternateLayout:{type:"boolean",default:"false"},initiallyExpanded:{type:"boolean",default:"false"},cardSpacing:{type:"boolean",default:"false"},expanded:{type:"boolean"},onBeforeCollapsed:{type:"() => boolean"},onBeforeExpanded:{type:"() => boolean"},onSelectionChange:{type:"ChangeEventHandler"},onCollapsed:{type:"() => void"},onExpanded:{type:"() => void"},selectable:{type:"boolean",default:"false"},selected:{type:"boolean"}}});const B={components:[x,p,f],examples:{basic:{label:"Content Rows",examples:{basic:{react:i.code`
|
2
|
+
import { ContentRow, ContentRowCol } from "@sps-woodland/content-rows";
|
3
|
+
import { Icon } from "@sps-woodland/core";
|
4
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
5
|
+
|
6
|
+
function Component() {
|
7
|
+
return (
|
8
|
+
<ContentRow>
|
9
|
+
<ContentRowCol>
|
10
|
+
<Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />
|
11
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>3532379</a>
|
12
|
+
</ContentRowCol>
|
13
|
+
<ContentRowCol widthPx={160}>
|
14
|
+
May 23, 2018 @ 4:38 PM
|
15
|
+
</ContentRowCol>
|
16
|
+
</ContentRow>
|
17
|
+
)
|
18
|
+
}
|
19
|
+
`},withCheckbox:{react:i.code`
|
20
|
+
import { ContentRow, ContentRowCol } from "@sps-woodland/content-rows";
|
21
|
+
import { Icon } from "@sps-woodland/core";
|
22
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
23
|
+
|
24
|
+
function Component() {
|
25
|
+
const { formValue, formMeta, updateForm } = useSpsForm({
|
26
|
+
selected: false
|
27
|
+
});
|
28
|
+
|
29
|
+
function selectRow() {
|
30
|
+
updateForm({ selected: !formValue.selected })
|
31
|
+
}
|
32
|
+
|
33
|
+
return (
|
34
|
+
<ContentRow
|
35
|
+
selectable
|
36
|
+
selected={formValue.selected}
|
37
|
+
onSelectionChange={selectRow}
|
38
|
+
>
|
39
|
+
<ContentRowCol>
|
40
|
+
<Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />
|
41
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>3532379</a>
|
42
|
+
</ContentRowCol>
|
43
|
+
<ContentRowCol widthPx={160}>
|
44
|
+
May 23, 2018 @ 4:38 PM
|
45
|
+
</ContentRowCol>
|
46
|
+
</ContentRow>
|
47
|
+
)
|
48
|
+
}
|
49
|
+
`},withCheckboxAndFavorite:{react:i.code`
|
50
|
+
import { ContentRow, ContentRowCol } from "@sps-woodland/content-rows";
|
51
|
+
import { Icon } from "@sps-woodland/core";
|
52
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
53
|
+
|
54
|
+
function Component() {
|
55
|
+
const { formValue, formMeta, updateForm } = useSpsForm({
|
56
|
+
selected: false
|
57
|
+
});
|
58
|
+
|
59
|
+
function selectRow() {
|
60
|
+
updateForm({ selected: !formValue.selected })
|
61
|
+
}
|
62
|
+
|
63
|
+
return (
|
64
|
+
<ContentRow
|
65
|
+
selectable
|
66
|
+
selected={formValue.selected}
|
67
|
+
onSelectionChange={selectRow}
|
68
|
+
>
|
69
|
+
<ContentRowCol style={{ width: "2.9rem" }}>
|
70
|
+
<Icon icon="star" size="md" color="blue-medium" />
|
71
|
+
</ContentRowCol>
|
72
|
+
<ContentRowCol>
|
73
|
+
<Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />
|
74
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>3532379</a>
|
75
|
+
</ContentRowCol>
|
76
|
+
<ContentRowCol widthPx={160}>
|
77
|
+
May 23, 2018 @ 4:38 PM
|
78
|
+
</ContentRowCol>
|
79
|
+
</ContentRow>
|
80
|
+
)
|
81
|
+
}
|
82
|
+
`}}},expandable:{label:"Expandable Content Rows",examples:{basic:{react:i.code`
|
83
|
+
import { ContentRow, ContentRowCol, ContentRowExpansion } from "@sps-woodland/content-rows";
|
84
|
+
import { Card } from "@sps-woodland/cards";
|
85
|
+
import { Icon } from "@sps-woodland/core";
|
86
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
87
|
+
|
88
|
+
function Component() {
|
89
|
+
return (
|
90
|
+
<ContentRow>
|
91
|
+
<ContentRowCol>
|
92
|
+
<Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />
|
93
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>3532379</a>
|
94
|
+
</ContentRowCol>
|
95
|
+
<ContentRowCol widthPx={160}>
|
96
|
+
May 23, 2018 @ 4:38 PM
|
97
|
+
</ContentRowCol>
|
98
|
+
<ContentRowExpansion>
|
99
|
+
<Card>
|
100
|
+
<br />
|
101
|
+
<br />
|
102
|
+
<br />
|
103
|
+
<br />
|
104
|
+
Additional content
|
105
|
+
<br />
|
106
|
+
<br />
|
107
|
+
<br />
|
108
|
+
<br />
|
109
|
+
</Card>
|
110
|
+
</ContentRowExpansion>
|
111
|
+
</ContentRow>
|
112
|
+
)
|
113
|
+
}
|
114
|
+
`},expandableWithCheckbox:{react:i.code`
|
115
|
+
import { ContentRow, ContentRowCol, ContentRowExpansion } from "@sps-woodland/content-rows";
|
116
|
+
import { Card } from "@sps-woodland/cards";
|
117
|
+
import { Icon } from "@sps-woodland/core";
|
118
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
119
|
+
|
120
|
+
function Component() {
|
121
|
+
const { formValue, formMeta, updateForm } = useSpsForm({
|
122
|
+
selected: false
|
123
|
+
});
|
124
|
+
|
125
|
+
function selectRow() {
|
126
|
+
updateForm({ selected: !formValue.selected })
|
127
|
+
}
|
128
|
+
|
129
|
+
return (
|
130
|
+
<ContentRow
|
131
|
+
selectable
|
132
|
+
selected={formValue.selected}
|
133
|
+
onSelectionChange={selectRow}
|
134
|
+
>
|
135
|
+
<ContentRowCol>
|
136
|
+
<Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />
|
137
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>3532379</a>
|
138
|
+
</ContentRowCol>
|
139
|
+
<ContentRowCol widthPx={160}>
|
140
|
+
May 23, 2018 @ 4:38 PM
|
141
|
+
</ContentRowCol>
|
142
|
+
<ContentRowExpansion>
|
143
|
+
<Card>
|
144
|
+
<br />
|
145
|
+
<br />
|
146
|
+
<br />
|
147
|
+
<br />
|
148
|
+
Additional content
|
149
|
+
<br />
|
150
|
+
<br />
|
151
|
+
<br />
|
152
|
+
<br />
|
153
|
+
</Card>
|
154
|
+
</ContentRowExpansion>
|
155
|
+
</ContentRow>
|
156
|
+
)
|
157
|
+
}
|
158
|
+
`},expandableWithCheckboxAlternate:{react:i.code`
|
159
|
+
import { ContentRow, ContentRowCol, ContentRowExpansion } from "@sps-woodland/content-rows";
|
160
|
+
import { Card } from "@sps-woodland/cards";
|
161
|
+
import { Icon } from "@sps-woodland/core";
|
162
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
163
|
+
|
164
|
+
function Component() {
|
165
|
+
const { formValue, formMeta, updateForm } = useSpsForm({
|
166
|
+
selected: false
|
167
|
+
});
|
168
|
+
|
169
|
+
function selectRow() {
|
170
|
+
updateForm({ selected: !formValue.selected })
|
171
|
+
}
|
172
|
+
|
173
|
+
return (
|
174
|
+
<ContentRow
|
175
|
+
selectable
|
176
|
+
selected={formValue.selected}
|
177
|
+
onSelectionChange={selectRow}
|
178
|
+
alternateLayout
|
179
|
+
>
|
180
|
+
<ContentRowCol>
|
181
|
+
<Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />
|
182
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>3532379</a>
|
183
|
+
</ContentRowCol>
|
184
|
+
<ContentRowCol widthPx={160}>
|
185
|
+
May 23, 2018 @ 4:38 PM
|
186
|
+
</ContentRowCol>
|
187
|
+
<ContentRowExpansion>
|
188
|
+
<Card>
|
189
|
+
<br />
|
190
|
+
<br />
|
191
|
+
<br />
|
192
|
+
<br />
|
193
|
+
Additional content
|
194
|
+
<br />
|
195
|
+
<br />
|
196
|
+
<br />
|
197
|
+
<br />
|
198
|
+
</Card>
|
199
|
+
</ContentRowExpansion>
|
200
|
+
</ContentRow>
|
201
|
+
)
|
202
|
+
}
|
203
|
+
`},expandableWithCheckboxAndFavorite:{react:i.code`
|
204
|
+
import { ContentRow, ContentRowCol, ContentRowExpansion } from "@sps-woodland/content-rows";
|
205
|
+
import { Card } from "@sps-woodland/cards";
|
206
|
+
import { Icon } from "@sps-woodland/core";
|
207
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
208
|
+
|
209
|
+
function Component() {
|
210
|
+
const { formValue, formMeta, updateForm } = useSpsForm({
|
211
|
+
selected: false
|
212
|
+
});
|
213
|
+
|
214
|
+
function selectRow() {
|
215
|
+
updateForm({ selected: !formValue.selected })
|
216
|
+
}
|
217
|
+
|
218
|
+
return (
|
219
|
+
<ContentRow
|
220
|
+
selectable
|
221
|
+
selected={formValue.selected}
|
222
|
+
onSelectionChange={selectRow}
|
223
|
+
>
|
224
|
+
<ContentRowCol style={{ width: "2.9rem" }}>
|
225
|
+
<Icon icon="star" size="md" color="blue-medium" />
|
226
|
+
</ContentRowCol>
|
227
|
+
<ContentRowCol>
|
228
|
+
<Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />
|
229
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>3532379</a>
|
230
|
+
</ContentRowCol>
|
231
|
+
<ContentRowCol widthPx={160}>
|
232
|
+
May 23, 2018 @ 4:38 PM
|
233
|
+
</ContentRowCol>
|
234
|
+
<ContentRowExpansion>
|
235
|
+
<Card>
|
236
|
+
<br />
|
237
|
+
<br />
|
238
|
+
<br />
|
239
|
+
<br />
|
240
|
+
Additional content
|
241
|
+
<br />
|
242
|
+
<br />
|
243
|
+
<br />
|
244
|
+
<br />
|
245
|
+
</Card>
|
246
|
+
</ContentRowExpansion>
|
247
|
+
</ContentRow>
|
248
|
+
)
|
249
|
+
}
|
250
|
+
`},expandableWithCheckboxAndFavoriteAlternate:{react:i.code`
|
251
|
+
import { ContentRow, ContentRowCol, ContentRowExpansion } from "@sps-woodland/content-rows";
|
252
|
+
import { Card } from "@sps-woodland/cards";
|
253
|
+
import { Icon } from "@sps-woodland/core";
|
254
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
255
|
+
|
256
|
+
function Component() {
|
257
|
+
const { formValue, formMeta, updateForm } = useSpsForm({
|
258
|
+
selected: false
|
259
|
+
});
|
260
|
+
|
261
|
+
function selectRow() {
|
262
|
+
updateForm({ selected: !formValue.selected })
|
263
|
+
}
|
264
|
+
|
265
|
+
return (
|
266
|
+
<ContentRow
|
267
|
+
selectable
|
268
|
+
selected={formValue.selected}
|
269
|
+
onSelectionChange={selectRow}
|
270
|
+
alternateLayout
|
271
|
+
>
|
272
|
+
<ContentRowCol style={{ width: "2.9rem" }}>
|
273
|
+
<Icon icon="star" size="md" color="blue-medium" />
|
274
|
+
</ContentRowCol>
|
275
|
+
<ContentRowCol>
|
276
|
+
<Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />
|
277
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>3532379</a>
|
278
|
+
</ContentRowCol>
|
279
|
+
<ContentRowCol widthPx={160}>
|
280
|
+
May 23, 2018 @ 4:38 PM
|
281
|
+
</ContentRowCol>
|
282
|
+
<ContentRowExpansion>
|
283
|
+
<Card>
|
284
|
+
<br />
|
285
|
+
<br />
|
286
|
+
<br />
|
287
|
+
<br />
|
288
|
+
Additional content
|
289
|
+
<br />
|
290
|
+
<br />
|
291
|
+
<br />
|
292
|
+
<br />
|
293
|
+
</Card>
|
294
|
+
</ContentRowExpansion>
|
295
|
+
</ContentRow>
|
296
|
+
)
|
297
|
+
}
|
298
|
+
`}}},sortable:{label:"Sortable Content Rows",examples:{basic:{react:i.code`
|
299
|
+
import { ContentRow, ContentRowCol, ContentRowExpansion } from "@sps-woodland/content-rows";
|
300
|
+
import { Card } from "@sps-woodland/cards";
|
301
|
+
import { SortingHeader, SortingHeaderCell } from "@sps-woodland/sortable-header";
|
302
|
+
import { grid } from "@sps-woodland/tokens";
|
303
|
+
|
304
|
+
function Component() {
|
305
|
+
const [sort, setSort] = React.useState([{ key: 'id', direction: SortDirection.DESCENDING }]);
|
306
|
+
const { formValue, formMeta, updateForm } = useSpsForm({
|
307
|
+
selected: null
|
308
|
+
});
|
309
|
+
|
310
|
+
function selectRow(id) {
|
311
|
+
updateForm({ selected: formValue.selected !== id ? id : null });
|
312
|
+
}
|
313
|
+
|
314
|
+
const items = React.useMemo(() => [
|
315
|
+
{
|
316
|
+
id: '9712323',
|
317
|
+
type: '850',
|
318
|
+
status: 'processing',
|
319
|
+
timestamp: 'July 21, 2021 @ 4:40 PM'
|
320
|
+
},
|
321
|
+
{
|
322
|
+
id: '8712378',
|
323
|
+
type: '810',
|
324
|
+
status: 'success',
|
325
|
+
timestamp: 'May 24, 2021 @ 4:39 PM'
|
326
|
+
},
|
327
|
+
{
|
328
|
+
id: '8912389',
|
329
|
+
type: '850',
|
330
|
+
status: 'success',
|
331
|
+
timestamp: 'May 23, 2021 @ 4:38 PM'
|
332
|
+
}
|
333
|
+
].sort((a, b) => {
|
334
|
+
if (!sort.length) {
|
335
|
+
return 0;
|
336
|
+
}
|
337
|
+
|
338
|
+
const [{ key, direction }] = sort;
|
339
|
+
if (a[key] < b[key]) {
|
340
|
+
return direction === SortDirection.ASCENDING ? -1 : 1;
|
341
|
+
} else if (a[key] > b[key]) {
|
342
|
+
return direction === SortDirection.ASCENDING ? 1 : -1;
|
343
|
+
} else {
|
344
|
+
return 0;
|
345
|
+
}
|
346
|
+
}), [sort]);
|
347
|
+
|
348
|
+
return (
|
349
|
+
<div className={grid.root}>
|
350
|
+
<SortingHeader sort={sort} onSortChange={setSort} className={grid[12]}>
|
351
|
+
<SortingHeaderCell sortDisabled widthRem={2.9} />
|
352
|
+
<SortingHeaderCell sortDisabled widthRem={2.9} />
|
353
|
+
<SortingHeaderCell sortKey='id'>ID</SortingHeaderCell>
|
354
|
+
<SortingHeaderCell sortKey='type'>Type</SortingHeaderCell>
|
355
|
+
<SortingHeaderCell sortKey='timestamp' widthPx={150}>Timestamp</SortingHeaderCell>
|
356
|
+
</SortingHeader>
|
357
|
+
|
358
|
+
{items.map(item => {
|
359
|
+
return (
|
360
|
+
<ContentRow
|
361
|
+
key={item.id}
|
362
|
+
selectable
|
363
|
+
selected={formValue.selected === item.id}
|
364
|
+
onSelectionChange={() => selectRow(item.id)}
|
365
|
+
className={grid[12]}
|
366
|
+
>
|
367
|
+
<ContentRowCol>
|
368
|
+
{item.status === 'processing' && <Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />}
|
369
|
+
{item.status === 'success' && <Icon className={sprinkles({ mr: "sm" })} icon="status-ok" size="lg" color="green-medium" />}
|
370
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>{item.id}</a>
|
371
|
+
</ContentRowCol>
|
372
|
+
<ContentRowCol>
|
373
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>{item.type}</a>
|
374
|
+
</ContentRowCol>
|
375
|
+
<ContentRowCol widthPx={150}>
|
376
|
+
{item.timestamp}
|
377
|
+
</ContentRowCol>
|
378
|
+
<ContentRowExpansion>
|
379
|
+
<Card>
|
380
|
+
<br />
|
381
|
+
<br />
|
382
|
+
<br />
|
383
|
+
<br />
|
384
|
+
Additional content
|
385
|
+
<br />
|
386
|
+
<br />
|
387
|
+
<br />
|
388
|
+
<br />
|
389
|
+
</Card>
|
390
|
+
</ContentRowExpansion>
|
391
|
+
</ContentRow>
|
392
|
+
);
|
393
|
+
})}
|
394
|
+
</div>
|
395
|
+
)
|
396
|
+
}
|
397
|
+
`}}}}},L={"Content Rows":B};exports.ContentRow=x;exports.ContentRowCol=p;exports.ContentRowExpansion=f;exports.MANIFEST=L;
|
package/lib/index.d.ts
ADDED
package/lib/index.es.js
ADDED
@@ -0,0 +1,623 @@
|
|
1
|
+
import * as s from "react";
|
2
|
+
import { Metadata as b, cl as p, selectChildren as _, I18nContext as O, Icon as A } from "@sps-woodland/core";
|
3
|
+
import { SpsCheckbox as D } from "@spscommerce/ds-react";
|
4
|
+
import { code as i } from "@spscommerce/utils";
|
5
|
+
function H(e, t, o) {
|
6
|
+
return t in e ? Object.defineProperty(e, t, {
|
7
|
+
value: o,
|
8
|
+
enumerable: !0,
|
9
|
+
configurable: !0,
|
10
|
+
writable: !0
|
11
|
+
}) : e[t] = o, e;
|
12
|
+
}
|
13
|
+
function v(e, t) {
|
14
|
+
var o = Object.keys(e);
|
15
|
+
if (Object.getOwnPropertySymbols) {
|
16
|
+
var n = Object.getOwnPropertySymbols(e);
|
17
|
+
t && (n = n.filter(function(r) {
|
18
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
19
|
+
})), o.push.apply(o, n);
|
20
|
+
}
|
21
|
+
return o;
|
22
|
+
}
|
23
|
+
function N(e) {
|
24
|
+
for (var t = 1; t < arguments.length; t++) {
|
25
|
+
var o = arguments[t] != null ? arguments[t] : {};
|
26
|
+
t % 2 ? v(Object(o), !0).forEach(function(n) {
|
27
|
+
H(e, n, o[n]);
|
28
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(o)) : v(Object(o)).forEach(function(n) {
|
29
|
+
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(o, n));
|
30
|
+
});
|
31
|
+
}
|
32
|
+
return e;
|
33
|
+
}
|
34
|
+
var T = (e, t, o) => {
|
35
|
+
for (var n of Object.keys(e)) {
|
36
|
+
var r;
|
37
|
+
if (e[n] !== ((r = t[n]) !== null && r !== void 0 ? r : o[n]))
|
38
|
+
return !1;
|
39
|
+
}
|
40
|
+
return !0;
|
41
|
+
}, x = (e) => (t) => {
|
42
|
+
var o = e.defaultClassName, n = N(N({}, e.defaultVariants), t);
|
43
|
+
for (var r in n) {
|
44
|
+
var a, c = (a = n[r]) !== null && a !== void 0 ? a : e.defaultVariants[r];
|
45
|
+
if (c != null) {
|
46
|
+
var l = c;
|
47
|
+
typeof l == "boolean" && (l = l === !0 ? "true" : "false");
|
48
|
+
var d = e.variantClassNames[r][l];
|
49
|
+
d && (o += " " + d);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
for (var [m, u] of e.compoundVariants)
|
53
|
+
T(m, n, e.defaultVariants) && (o += " " + u);
|
54
|
+
return o;
|
55
|
+
}, G = x({ defaultClassName: "_1mxrufv0", variantClassNames: { lean: { true: "_1mxrufv1", false: "_1mxrufv2" }, borderless: { true: "_1mxrufv3", false: "_1mxrufv4" } }, defaultVariants: { lean: !1, borderless: !1 }, compoundVariants: [] });
|
56
|
+
function C({
|
57
|
+
children: e,
|
58
|
+
className: t,
|
59
|
+
borderless: o,
|
60
|
+
lean: n,
|
61
|
+
widthPx: r,
|
62
|
+
widthRem: a,
|
63
|
+
style: c,
|
64
|
+
...l
|
65
|
+
}) {
|
66
|
+
const d = r ? r / 16 : a, m = d ? {
|
67
|
+
...c,
|
68
|
+
width: `${d}rem`
|
69
|
+
} : c;
|
70
|
+
return /* @__PURE__ */ s.createElement("div", {
|
71
|
+
className: p(G({ lean: n, borderless: o }), t),
|
72
|
+
...l,
|
73
|
+
style: m
|
74
|
+
}, e);
|
75
|
+
}
|
76
|
+
b.set(C, {
|
77
|
+
name: "Content Row Col",
|
78
|
+
props: {
|
79
|
+
borderless: { type: "boolean" },
|
80
|
+
lean: { type: "boolean" },
|
81
|
+
widthPx: { type: "number" },
|
82
|
+
widthRem: { type: "number" }
|
83
|
+
}
|
84
|
+
});
|
85
|
+
var K = x({ defaultClassName: "_11ztjee1", variantClassNames: { expanded: { true: "_11ztjee2", false: "_11ztjee3" } }, defaultVariants: { expanded: !1 }, compoundVariants: [] }), W = x({ defaultClassName: "_11ztjee4", variantClassNames: { expanded: { true: "_11ztjee5", false: "_11ztjee6" }, selected: { true: "_11ztjee7", false: "_11ztjee8" }, cardSpacing: { true: "_11ztjee9", false: "_11ztjeea" } }, defaultVariants: { expanded: !1, selected: !1, cardSpacing: !1 }, compoundVariants: [[{ expanded: !0, cardSpacing: !0 }, "_11ztjeeb"]] }), B = "_11ztjeee", L = "_11ztjeec", J = "_11ztjeed", P = "_11ztjeef";
|
86
|
+
function y({
|
87
|
+
children: e,
|
88
|
+
className: t,
|
89
|
+
...o
|
90
|
+
}) {
|
91
|
+
return /* @__PURE__ */ s.createElement("div", {
|
92
|
+
className: p(B, t),
|
93
|
+
...o
|
94
|
+
}, e);
|
95
|
+
}
|
96
|
+
b.set(y, {
|
97
|
+
name: "Content Row Expansion"
|
98
|
+
});
|
99
|
+
function I({
|
100
|
+
children: e,
|
101
|
+
className: t,
|
102
|
+
alternateLayout: o = !1,
|
103
|
+
initiallyExpanded: n = !1,
|
104
|
+
cardSpacing: r = !1,
|
105
|
+
expanded: a,
|
106
|
+
onBeforeCollapsed: c,
|
107
|
+
onBeforeExpanded: l,
|
108
|
+
onSelectionChange: d,
|
109
|
+
onCollapsed: m,
|
110
|
+
onExpanded: u,
|
111
|
+
selectable: h = !1,
|
112
|
+
selected: g,
|
113
|
+
...M
|
114
|
+
}) {
|
115
|
+
const [V, [f]] = _(e, [
|
116
|
+
{ type: C },
|
117
|
+
{ type: y }
|
118
|
+
]), { t: z } = s.useContext(O), [R, E] = s.useState(n), w = typeof a == "boolean" ? a : R;
|
119
|
+
function F(j) {
|
120
|
+
j.stopPropagation(), w && (!c || c()) ? (E(!1), m && m()) : !w && (!l || l()) && (E(!0), u && u());
|
121
|
+
}
|
122
|
+
const k = () => /* @__PURE__ */ s.createElement(D, {
|
123
|
+
checked: g,
|
124
|
+
onChange: d
|
125
|
+
}), S = () => /* @__PURE__ */ s.createElement("button", {
|
126
|
+
type: "button",
|
127
|
+
className: p(L),
|
128
|
+
onClick: F,
|
129
|
+
"aria-label": z(`design-system:contentRow.${w ? "collapse" : "expand"}`)
|
130
|
+
}, /* @__PURE__ */ s.createElement(A, {
|
131
|
+
className: p(J),
|
132
|
+
icon: w ? "minus-circle" : "plus-circle"
|
133
|
+
}));
|
134
|
+
return /* @__PURE__ */ s.createElement("div", {
|
135
|
+
className: p(K({ expanded: a || R }), t),
|
136
|
+
...M
|
137
|
+
}, /* @__PURE__ */ s.createElement("div", {
|
138
|
+
className: p(
|
139
|
+
W({
|
140
|
+
expanded: a || R,
|
141
|
+
selected: g,
|
142
|
+
cardSpacing: r
|
143
|
+
})
|
144
|
+
)
|
145
|
+
}, h && !o && /* @__PURE__ */ s.createElement(C, {
|
146
|
+
widthPx: 46
|
147
|
+
}, /* @__PURE__ */ s.createElement(k, null)), f && !o && /* @__PURE__ */ s.createElement(C, {
|
148
|
+
widthPx: 44
|
149
|
+
}, /* @__PURE__ */ s.createElement(S, null)), f && h && o && /* @__PURE__ */ s.createElement(C, {
|
150
|
+
widthPx: 46
|
151
|
+
}, /* @__PURE__ */ s.createElement("section", {
|
152
|
+
className: P
|
153
|
+
}, /* @__PURE__ */ s.createElement(k, null)), /* @__PURE__ */ s.createElement("section", {
|
154
|
+
className: P
|
155
|
+
}, /* @__PURE__ */ s.createElement(S, null))), V), f);
|
156
|
+
}
|
157
|
+
b.set(I, {
|
158
|
+
name: "Content Row",
|
159
|
+
props: {
|
160
|
+
alternateLayout: { type: "boolean", default: "false" },
|
161
|
+
initiallyExpanded: { type: "boolean", default: "false" },
|
162
|
+
cardSpacing: { type: "boolean", default: "false" },
|
163
|
+
expanded: { type: "boolean" },
|
164
|
+
onBeforeCollapsed: { type: "() => boolean" },
|
165
|
+
onBeforeExpanded: { type: "() => boolean" },
|
166
|
+
onSelectionChange: { type: "ChangeEventHandler" },
|
167
|
+
onCollapsed: { type: "() => void" },
|
168
|
+
onExpanded: { type: "() => void" },
|
169
|
+
selectable: { type: "boolean", default: "false" },
|
170
|
+
selected: { type: "boolean" }
|
171
|
+
}
|
172
|
+
});
|
173
|
+
const q = {
|
174
|
+
components: [I, C, y],
|
175
|
+
examples: {
|
176
|
+
basic: {
|
177
|
+
label: "Content Rows",
|
178
|
+
examples: {
|
179
|
+
basic: {
|
180
|
+
react: i`
|
181
|
+
import { ContentRow, ContentRowCol } from "@sps-woodland/content-rows";
|
182
|
+
import { Icon } from "@sps-woodland/core";
|
183
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
184
|
+
|
185
|
+
function Component() {
|
186
|
+
return (
|
187
|
+
<ContentRow>
|
188
|
+
<ContentRowCol>
|
189
|
+
<Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />
|
190
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>3532379</a>
|
191
|
+
</ContentRowCol>
|
192
|
+
<ContentRowCol widthPx={160}>
|
193
|
+
May 23, 2018 @ 4:38 PM
|
194
|
+
</ContentRowCol>
|
195
|
+
</ContentRow>
|
196
|
+
)
|
197
|
+
}
|
198
|
+
`
|
199
|
+
},
|
200
|
+
withCheckbox: {
|
201
|
+
react: i`
|
202
|
+
import { ContentRow, ContentRowCol } from "@sps-woodland/content-rows";
|
203
|
+
import { Icon } from "@sps-woodland/core";
|
204
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
205
|
+
|
206
|
+
function Component() {
|
207
|
+
const { formValue, formMeta, updateForm } = useSpsForm({
|
208
|
+
selected: false
|
209
|
+
});
|
210
|
+
|
211
|
+
function selectRow() {
|
212
|
+
updateForm({ selected: !formValue.selected })
|
213
|
+
}
|
214
|
+
|
215
|
+
return (
|
216
|
+
<ContentRow
|
217
|
+
selectable
|
218
|
+
selected={formValue.selected}
|
219
|
+
onSelectionChange={selectRow}
|
220
|
+
>
|
221
|
+
<ContentRowCol>
|
222
|
+
<Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />
|
223
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>3532379</a>
|
224
|
+
</ContentRowCol>
|
225
|
+
<ContentRowCol widthPx={160}>
|
226
|
+
May 23, 2018 @ 4:38 PM
|
227
|
+
</ContentRowCol>
|
228
|
+
</ContentRow>
|
229
|
+
)
|
230
|
+
}
|
231
|
+
`
|
232
|
+
},
|
233
|
+
withCheckboxAndFavorite: {
|
234
|
+
react: i`
|
235
|
+
import { ContentRow, ContentRowCol } from "@sps-woodland/content-rows";
|
236
|
+
import { Icon } from "@sps-woodland/core";
|
237
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
238
|
+
|
239
|
+
function Component() {
|
240
|
+
const { formValue, formMeta, updateForm } = useSpsForm({
|
241
|
+
selected: false
|
242
|
+
});
|
243
|
+
|
244
|
+
function selectRow() {
|
245
|
+
updateForm({ selected: !formValue.selected })
|
246
|
+
}
|
247
|
+
|
248
|
+
return (
|
249
|
+
<ContentRow
|
250
|
+
selectable
|
251
|
+
selected={formValue.selected}
|
252
|
+
onSelectionChange={selectRow}
|
253
|
+
>
|
254
|
+
<ContentRowCol style={{ width: "2.9rem" }}>
|
255
|
+
<Icon icon="star" size="md" color="blue-medium" />
|
256
|
+
</ContentRowCol>
|
257
|
+
<ContentRowCol>
|
258
|
+
<Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />
|
259
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>3532379</a>
|
260
|
+
</ContentRowCol>
|
261
|
+
<ContentRowCol widthPx={160}>
|
262
|
+
May 23, 2018 @ 4:38 PM
|
263
|
+
</ContentRowCol>
|
264
|
+
</ContentRow>
|
265
|
+
)
|
266
|
+
}
|
267
|
+
`
|
268
|
+
}
|
269
|
+
}
|
270
|
+
},
|
271
|
+
expandable: {
|
272
|
+
label: "Expandable Content Rows",
|
273
|
+
examples: {
|
274
|
+
basic: {
|
275
|
+
react: i`
|
276
|
+
import { ContentRow, ContentRowCol, ContentRowExpansion } from "@sps-woodland/content-rows";
|
277
|
+
import { Card } from "@sps-woodland/cards";
|
278
|
+
import { Icon } from "@sps-woodland/core";
|
279
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
280
|
+
|
281
|
+
function Component() {
|
282
|
+
return (
|
283
|
+
<ContentRow>
|
284
|
+
<ContentRowCol>
|
285
|
+
<Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />
|
286
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>3532379</a>
|
287
|
+
</ContentRowCol>
|
288
|
+
<ContentRowCol widthPx={160}>
|
289
|
+
May 23, 2018 @ 4:38 PM
|
290
|
+
</ContentRowCol>
|
291
|
+
<ContentRowExpansion>
|
292
|
+
<Card>
|
293
|
+
<br />
|
294
|
+
<br />
|
295
|
+
<br />
|
296
|
+
<br />
|
297
|
+
Additional content
|
298
|
+
<br />
|
299
|
+
<br />
|
300
|
+
<br />
|
301
|
+
<br />
|
302
|
+
</Card>
|
303
|
+
</ContentRowExpansion>
|
304
|
+
</ContentRow>
|
305
|
+
)
|
306
|
+
}
|
307
|
+
`
|
308
|
+
},
|
309
|
+
expandableWithCheckbox: {
|
310
|
+
react: i`
|
311
|
+
import { ContentRow, ContentRowCol, ContentRowExpansion } from "@sps-woodland/content-rows";
|
312
|
+
import { Card } from "@sps-woodland/cards";
|
313
|
+
import { Icon } from "@sps-woodland/core";
|
314
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
315
|
+
|
316
|
+
function Component() {
|
317
|
+
const { formValue, formMeta, updateForm } = useSpsForm({
|
318
|
+
selected: false
|
319
|
+
});
|
320
|
+
|
321
|
+
function selectRow() {
|
322
|
+
updateForm({ selected: !formValue.selected })
|
323
|
+
}
|
324
|
+
|
325
|
+
return (
|
326
|
+
<ContentRow
|
327
|
+
selectable
|
328
|
+
selected={formValue.selected}
|
329
|
+
onSelectionChange={selectRow}
|
330
|
+
>
|
331
|
+
<ContentRowCol>
|
332
|
+
<Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />
|
333
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>3532379</a>
|
334
|
+
</ContentRowCol>
|
335
|
+
<ContentRowCol widthPx={160}>
|
336
|
+
May 23, 2018 @ 4:38 PM
|
337
|
+
</ContentRowCol>
|
338
|
+
<ContentRowExpansion>
|
339
|
+
<Card>
|
340
|
+
<br />
|
341
|
+
<br />
|
342
|
+
<br />
|
343
|
+
<br />
|
344
|
+
Additional content
|
345
|
+
<br />
|
346
|
+
<br />
|
347
|
+
<br />
|
348
|
+
<br />
|
349
|
+
</Card>
|
350
|
+
</ContentRowExpansion>
|
351
|
+
</ContentRow>
|
352
|
+
)
|
353
|
+
}
|
354
|
+
`
|
355
|
+
},
|
356
|
+
expandableWithCheckboxAlternate: {
|
357
|
+
react: i`
|
358
|
+
import { ContentRow, ContentRowCol, ContentRowExpansion } from "@sps-woodland/content-rows";
|
359
|
+
import { Card } from "@sps-woodland/cards";
|
360
|
+
import { Icon } from "@sps-woodland/core";
|
361
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
362
|
+
|
363
|
+
function Component() {
|
364
|
+
const { formValue, formMeta, updateForm } = useSpsForm({
|
365
|
+
selected: false
|
366
|
+
});
|
367
|
+
|
368
|
+
function selectRow() {
|
369
|
+
updateForm({ selected: !formValue.selected })
|
370
|
+
}
|
371
|
+
|
372
|
+
return (
|
373
|
+
<ContentRow
|
374
|
+
selectable
|
375
|
+
selected={formValue.selected}
|
376
|
+
onSelectionChange={selectRow}
|
377
|
+
alternateLayout
|
378
|
+
>
|
379
|
+
<ContentRowCol>
|
380
|
+
<Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />
|
381
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>3532379</a>
|
382
|
+
</ContentRowCol>
|
383
|
+
<ContentRowCol widthPx={160}>
|
384
|
+
May 23, 2018 @ 4:38 PM
|
385
|
+
</ContentRowCol>
|
386
|
+
<ContentRowExpansion>
|
387
|
+
<Card>
|
388
|
+
<br />
|
389
|
+
<br />
|
390
|
+
<br />
|
391
|
+
<br />
|
392
|
+
Additional content
|
393
|
+
<br />
|
394
|
+
<br />
|
395
|
+
<br />
|
396
|
+
<br />
|
397
|
+
</Card>
|
398
|
+
</ContentRowExpansion>
|
399
|
+
</ContentRow>
|
400
|
+
)
|
401
|
+
}
|
402
|
+
`
|
403
|
+
},
|
404
|
+
expandableWithCheckboxAndFavorite: {
|
405
|
+
react: i`
|
406
|
+
import { ContentRow, ContentRowCol, ContentRowExpansion } from "@sps-woodland/content-rows";
|
407
|
+
import { Card } from "@sps-woodland/cards";
|
408
|
+
import { Icon } from "@sps-woodland/core";
|
409
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
410
|
+
|
411
|
+
function Component() {
|
412
|
+
const { formValue, formMeta, updateForm } = useSpsForm({
|
413
|
+
selected: false
|
414
|
+
});
|
415
|
+
|
416
|
+
function selectRow() {
|
417
|
+
updateForm({ selected: !formValue.selected })
|
418
|
+
}
|
419
|
+
|
420
|
+
return (
|
421
|
+
<ContentRow
|
422
|
+
selectable
|
423
|
+
selected={formValue.selected}
|
424
|
+
onSelectionChange={selectRow}
|
425
|
+
>
|
426
|
+
<ContentRowCol style={{ width: "2.9rem" }}>
|
427
|
+
<Icon icon="star" size="md" color="blue-medium" />
|
428
|
+
</ContentRowCol>
|
429
|
+
<ContentRowCol>
|
430
|
+
<Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />
|
431
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>3532379</a>
|
432
|
+
</ContentRowCol>
|
433
|
+
<ContentRowCol widthPx={160}>
|
434
|
+
May 23, 2018 @ 4:38 PM
|
435
|
+
</ContentRowCol>
|
436
|
+
<ContentRowExpansion>
|
437
|
+
<Card>
|
438
|
+
<br />
|
439
|
+
<br />
|
440
|
+
<br />
|
441
|
+
<br />
|
442
|
+
Additional content
|
443
|
+
<br />
|
444
|
+
<br />
|
445
|
+
<br />
|
446
|
+
<br />
|
447
|
+
</Card>
|
448
|
+
</ContentRowExpansion>
|
449
|
+
</ContentRow>
|
450
|
+
)
|
451
|
+
}
|
452
|
+
`
|
453
|
+
},
|
454
|
+
expandableWithCheckboxAndFavoriteAlternate: {
|
455
|
+
react: i`
|
456
|
+
import { ContentRow, ContentRowCol, ContentRowExpansion } from "@sps-woodland/content-rows";
|
457
|
+
import { Card } from "@sps-woodland/cards";
|
458
|
+
import { Icon } from "@sps-woodland/core";
|
459
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
460
|
+
|
461
|
+
function Component() {
|
462
|
+
const { formValue, formMeta, updateForm } = useSpsForm({
|
463
|
+
selected: false
|
464
|
+
});
|
465
|
+
|
466
|
+
function selectRow() {
|
467
|
+
updateForm({ selected: !formValue.selected })
|
468
|
+
}
|
469
|
+
|
470
|
+
return (
|
471
|
+
<ContentRow
|
472
|
+
selectable
|
473
|
+
selected={formValue.selected}
|
474
|
+
onSelectionChange={selectRow}
|
475
|
+
alternateLayout
|
476
|
+
>
|
477
|
+
<ContentRowCol style={{ width: "2.9rem" }}>
|
478
|
+
<Icon icon="star" size="md" color="blue-medium" />
|
479
|
+
</ContentRowCol>
|
480
|
+
<ContentRowCol>
|
481
|
+
<Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />
|
482
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>3532379</a>
|
483
|
+
</ContentRowCol>
|
484
|
+
<ContentRowCol widthPx={160}>
|
485
|
+
May 23, 2018 @ 4:38 PM
|
486
|
+
</ContentRowCol>
|
487
|
+
<ContentRowExpansion>
|
488
|
+
<Card>
|
489
|
+
<br />
|
490
|
+
<br />
|
491
|
+
<br />
|
492
|
+
<br />
|
493
|
+
Additional content
|
494
|
+
<br />
|
495
|
+
<br />
|
496
|
+
<br />
|
497
|
+
<br />
|
498
|
+
</Card>
|
499
|
+
</ContentRowExpansion>
|
500
|
+
</ContentRow>
|
501
|
+
)
|
502
|
+
}
|
503
|
+
`
|
504
|
+
}
|
505
|
+
}
|
506
|
+
},
|
507
|
+
sortable: {
|
508
|
+
label: "Sortable Content Rows",
|
509
|
+
examples: {
|
510
|
+
basic: {
|
511
|
+
react: i`
|
512
|
+
import { ContentRow, ContentRowCol, ContentRowExpansion } from "@sps-woodland/content-rows";
|
513
|
+
import { Card } from "@sps-woodland/cards";
|
514
|
+
import { SortingHeader, SortingHeaderCell } from "@sps-woodland/sortable-header";
|
515
|
+
import { grid } from "@sps-woodland/tokens";
|
516
|
+
|
517
|
+
function Component() {
|
518
|
+
const [sort, setSort] = React.useState([{ key: 'id', direction: SortDirection.DESCENDING }]);
|
519
|
+
const { formValue, formMeta, updateForm } = useSpsForm({
|
520
|
+
selected: null
|
521
|
+
});
|
522
|
+
|
523
|
+
function selectRow(id) {
|
524
|
+
updateForm({ selected: formValue.selected !== id ? id : null });
|
525
|
+
}
|
526
|
+
|
527
|
+
const items = React.useMemo(() => [
|
528
|
+
{
|
529
|
+
id: '9712323',
|
530
|
+
type: '850',
|
531
|
+
status: 'processing',
|
532
|
+
timestamp: 'July 21, 2021 @ 4:40 PM'
|
533
|
+
},
|
534
|
+
{
|
535
|
+
id: '8712378',
|
536
|
+
type: '810',
|
537
|
+
status: 'success',
|
538
|
+
timestamp: 'May 24, 2021 @ 4:39 PM'
|
539
|
+
},
|
540
|
+
{
|
541
|
+
id: '8912389',
|
542
|
+
type: '850',
|
543
|
+
status: 'success',
|
544
|
+
timestamp: 'May 23, 2021 @ 4:38 PM'
|
545
|
+
}
|
546
|
+
].sort((a, b) => {
|
547
|
+
if (!sort.length) {
|
548
|
+
return 0;
|
549
|
+
}
|
550
|
+
|
551
|
+
const [{ key, direction }] = sort;
|
552
|
+
if (a[key] < b[key]) {
|
553
|
+
return direction === SortDirection.ASCENDING ? -1 : 1;
|
554
|
+
} else if (a[key] > b[key]) {
|
555
|
+
return direction === SortDirection.ASCENDING ? 1 : -1;
|
556
|
+
} else {
|
557
|
+
return 0;
|
558
|
+
}
|
559
|
+
}), [sort]);
|
560
|
+
|
561
|
+
return (
|
562
|
+
<div className={grid.root}>
|
563
|
+
<SortingHeader sort={sort} onSortChange={setSort} className={grid[12]}>
|
564
|
+
<SortingHeaderCell sortDisabled widthRem={2.9} />
|
565
|
+
<SortingHeaderCell sortDisabled widthRem={2.9} />
|
566
|
+
<SortingHeaderCell sortKey='id'>ID</SortingHeaderCell>
|
567
|
+
<SortingHeaderCell sortKey='type'>Type</SortingHeaderCell>
|
568
|
+
<SortingHeaderCell sortKey='timestamp' widthPx={150}>Timestamp</SortingHeaderCell>
|
569
|
+
</SortingHeader>
|
570
|
+
|
571
|
+
{items.map(item => {
|
572
|
+
return (
|
573
|
+
<ContentRow
|
574
|
+
key={item.id}
|
575
|
+
selectable
|
576
|
+
selected={formValue.selected === item.id}
|
577
|
+
onSelectionChange={() => selectRow(item.id)}
|
578
|
+
className={grid[12]}
|
579
|
+
>
|
580
|
+
<ContentRowCol>
|
581
|
+
{item.status === 'processing' && <Icon className={sprinkles({ mr: "sm" })} icon="status-in-process" size="lg" color="purple-medium" />}
|
582
|
+
{item.status === 'success' && <Icon className={sprinkles({ mr: "sm" })} icon="status-ok" size="lg" color="green-medium" />}
|
583
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>{item.id}</a>
|
584
|
+
</ContentRowCol>
|
585
|
+
<ContentRowCol>
|
586
|
+
<a href="#" className={sprinkles({ fs: "body-md" })}>{item.type}</a>
|
587
|
+
</ContentRowCol>
|
588
|
+
<ContentRowCol widthPx={150}>
|
589
|
+
{item.timestamp}
|
590
|
+
</ContentRowCol>
|
591
|
+
<ContentRowExpansion>
|
592
|
+
<Card>
|
593
|
+
<br />
|
594
|
+
<br />
|
595
|
+
<br />
|
596
|
+
<br />
|
597
|
+
Additional content
|
598
|
+
<br />
|
599
|
+
<br />
|
600
|
+
<br />
|
601
|
+
<br />
|
602
|
+
</Card>
|
603
|
+
</ContentRowExpansion>
|
604
|
+
</ContentRow>
|
605
|
+
);
|
606
|
+
})}
|
607
|
+
</div>
|
608
|
+
)
|
609
|
+
}
|
610
|
+
`
|
611
|
+
}
|
612
|
+
}
|
613
|
+
}
|
614
|
+
}
|
615
|
+
}, Y = {
|
616
|
+
"Content Rows": q
|
617
|
+
};
|
618
|
+
export {
|
619
|
+
I as ContentRow,
|
620
|
+
C as ContentRowCol,
|
621
|
+
y as ContentRowExpansion,
|
622
|
+
Y as MANIFEST
|
623
|
+
};
|
package/lib/style.css
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
._1mxrufv0{display:table-cell;padding:1rem;vertical-align:middle}._1mxrufv1{padding:.5rem 1rem}._1mxrufv4:not(:first-child){border-left:.0625rem solid #d2d4d4}._1mxrufv0>*{vertical-align:middle}._11ztjee1{background:#ffffff;display:block}._11ztjee2{--_11ztjee0: block}._11ztjee3{--_11ztjee0: none}._11ztjee4{border-width:.0625rem;border-style:solid;border-color:#d2d4d4;border-radius:.25rem;display:table;table-layout:fixed;width:100.06%}._11ztjee5{border-top-left-radius:.25rem;border-top-right-radius:.25rem;border-bottom-right-radius:0;border-bottom-left-radius:0}._11ztjee7{background:#e6f2f8;border-color:#007db8}._11ztjee9{border-radius:.25rem;margin-top:1rem}._11ztjeeb{border-top-left-radius:.25rem;border-top-right-radius:.25rem;border-bottom-right-radius:0;border-bottom-left-radius:0}._11ztjeec{background:none;border:0;padding:0}._11ztjeed{color:#007db8;cursor:pointer;font-size:1rem;line-height:1.125rem;padding:0;vertical-align:middle}._11ztjeed:hover{color:#09638d}._11ztjeee{background:#f3f4f4;border-color:#d2d4d4;border-top-left-radius:0;border-top-right-radius:0;border-bottom-right-radius:.25rem;border-bottom-left-radius:.25rem;border-style:solid;border-top-width:0;border-right-width:.0625rem;border-bottom-width:.0625rem;border-left-width:.0625rem;display:var(--_11ztjee0);padding:1rem}._11ztjeef{padding:1rem}._11ztjeef:first-child{margin:-1rem -1rem 0}._11ztjeef:last-child{border-top-width:.0625rem;border-right-width:0;border-bottom-width:0;border-left-width:0;border-style:solid;border-top-color:#d2d4d4;margin:0 -1rem -1rem}
|
package/package.json
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
{
|
2
|
+
"name": "@sps-woodland/content-row",
|
3
|
+
"description": "SPS Woodland Design System page title component",
|
4
|
+
"version": "7.0.0",
|
5
|
+
"author": "SPS Commerce",
|
6
|
+
"license": "UNLICENSED",
|
7
|
+
"repository": "https://github.com/SPSCommerce/woodland/tree/main/packages/@sps-woodland/page-title",
|
8
|
+
"homepage": "https://github.com/SPSCommerce/woodland/tree/master/packages/@sps-woodland/page-title#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
|
+
"@spscommerce/ds-react": "7.0.0",
|
20
|
+
"@spscommerce/ds-illustrations": "6.37.3",
|
21
|
+
"@spscommerce/ds-shared": "7.0.0",
|
22
|
+
"@spscommerce/ds-colors": "7.0.0",
|
23
|
+
"react": "^16.9.0",
|
24
|
+
"react-dom": "^16.9.0"
|
25
|
+
},
|
26
|
+
"devDependencies": {
|
27
|
+
"@sps-woodland/core": "7.0.0",
|
28
|
+
"@sps-woodland/tokens": "7.0.0",
|
29
|
+
"@spscommerce/utils": "^6.12.1",
|
30
|
+
"@spscommerce/ds-react": "7.0.0",
|
31
|
+
"@spscommerce/ds-illustrations": "6.37.3",
|
32
|
+
"@spscommerce/ds-shared": "7.0.0",
|
33
|
+
"@spscommerce/ds-colors": "7.0.0",
|
34
|
+
"@vanilla-extract/css": "^1.9.1",
|
35
|
+
"@vanilla-extract/recipes": "^0.2.5",
|
36
|
+
"react": "^16.9.0",
|
37
|
+
"react-dom": "^16.9.0"
|
38
|
+
},
|
39
|
+
"scripts": {
|
40
|
+
"build": "pnpm run build:js && pnpm run build:types",
|
41
|
+
"build:js": "vite build",
|
42
|
+
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir lib",
|
43
|
+
"watch": "vite build --watch",
|
44
|
+
"clean": "git clean -fdX",
|
45
|
+
"pub": "node ../../../scripts/publish-package.js"
|
46
|
+
}
|
47
|
+
}
|
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
|
+
});
|