@caseparts-org/caseblocks 0.0.109 → 0.0.110

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.
@@ -10,7 +10,8 @@ export interface AccountProps extends React.HTMLAttributes<HTMLDivElement>, Hide
10
10
  /** The account user's initials. */
11
11
  initials: string;
12
12
  };
13
- accountRoute: string;
14
13
  onLoginClick: () => void;
14
+ /** Optional content to show when clicking the authenticated container */
15
+ popoverContent?: React.ReactNode;
15
16
  }
16
17
  export declare function Account(props: AccountProps): import("react/jsx-runtime").JSX.Element;
@@ -1,86 +1,120 @@
1
- import { jsx as i, jsxs as n } from "react/jsx-runtime";
2
- import { getHideAtStyles as a } from "../../atoms/HideAt.js";
1
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
2
+ import { getHideAtStyles as c } from "../../atoms/HideAt.js";
3
3
  import { Icon as f } from "../../atoms/Icon/Icon.js";
4
- import { Text as l } from "../../atoms/Text/Text.js";
4
+ import { Text as m } from "../../atoms/Text/Text.js";
5
5
  import { Avatar as h } from "../Avatar/Avatar.js";
6
- import { Flex as d } from "../../atoms/Flex/Flex.js";
7
- import { Button as A } from "../../atoms/Button/Button.js";
8
- import { c as u } from "../../clsx-OuTLNxxd.js";
9
- import { Link as x } from "../../atoms/Link/Link.js";
10
- import '../../assets/Account.css';const p = "_loggedIn_1aoh3_1", I = "_customer_1aoh3_12", s = {
11
- loggedIn: p,
12
- customer: I
6
+ import { Flex as a } from "../../atoms/Flex/Flex.js";
7
+ import { Button as u } from "../../atoms/Button/Button.js";
8
+ import { Popover as p } from "../../atoms/Popover/Popover.js";
9
+ import { c as d } from "../../clsx-OuTLNxxd.js";
10
+ import '../../assets/Account.css';const x = "_loggedIn_1aoh3_1", A = "_customer_1aoh3_12", o = {
11
+ loggedIn: x,
12
+ customer: A
13
13
  };
14
- function _(e) {
15
- return e.account !== void 0;
14
+ function I(i) {
15
+ return i.account !== void 0;
16
16
  }
17
- function P(e) {
18
- return _(e) ? /* @__PURE__ */ i(k, { ...e }) : /* @__PURE__ */ i(v, { ...e });
17
+ function P(i) {
18
+ return I(i) ? /* @__PURE__ */ t(v, { ...i }) : /* @__PURE__ */ t(k, { ...i });
19
19
  }
20
- function k(e) {
20
+ function v(i) {
21
21
  const {
22
- account: t,
23
- accountRoute: o,
24
- onLoginClick: m,
22
+ account: e,
25
23
  className: r,
26
- hideAt: c,
24
+ hideAt: s,
25
+ popoverContent: l,
27
26
  ...g
28
- } = e;
29
- return /* @__PURE__ */ n(
27
+ } = i;
28
+ return l ? /* @__PURE__ */ t(
29
+ p,
30
+ {
31
+ position: "bottom right",
32
+ trigger: /* @__PURE__ */ n(
33
+ "div",
34
+ {
35
+ className: d(o.loggedIn, c(s), r),
36
+ ...g,
37
+ children: [
38
+ /* @__PURE__ */ n(
39
+ a,
40
+ {
41
+ flexDirection: "column",
42
+ alignItems: "flex-end",
43
+ hideAt: ["sm", "md"],
44
+ className: o.customer,
45
+ children: [
46
+ /* @__PURE__ */ n(m, { size: "xxs", children: [
47
+ "Acct: ",
48
+ e == null ? void 0 : e.number
49
+ ] }),
50
+ /* @__PURE__ */ n(m, { size: "sm", variant: "display", colorToken: "links", children: [
51
+ "Hello ",
52
+ e == null ? void 0 : e.name
53
+ ] })
54
+ ]
55
+ }
56
+ ),
57
+ /* @__PURE__ */ t(h, { initials: e.initials })
58
+ ]
59
+ }
60
+ ),
61
+ children: l
62
+ }
63
+ ) : /* @__PURE__ */ n(
30
64
  "div",
31
65
  {
32
- className: u(s.loggedIn, a(c), r),
66
+ className: d(o.loggedIn, c(s), r),
33
67
  ...g,
34
68
  children: [
35
69
  /* @__PURE__ */ n(
36
- d,
70
+ a,
37
71
  {
38
72
  flexDirection: "column",
39
73
  alignItems: "flex-end",
40
74
  hideAt: ["sm", "md"],
41
- className: s.customer,
75
+ className: o.customer,
42
76
  children: [
43
- /* @__PURE__ */ n(l, { size: "xxs", children: [
77
+ /* @__PURE__ */ n(m, { size: "xxs", children: [
44
78
  "Acct: ",
45
- t == null ? void 0 : t.number
79
+ e == null ? void 0 : e.number
46
80
  ] }),
47
- /* @__PURE__ */ i(x, { href: o, children: /* @__PURE__ */ n(l, { size: "sm", variant: "display", children: [
81
+ /* @__PURE__ */ n(m, { size: "sm", variant: "display", colorToken: "links", children: [
48
82
  "Hello ",
49
- t == null ? void 0 : t.name
50
- ] }) })
83
+ e == null ? void 0 : e.name
84
+ ] })
51
85
  ]
52
86
  }
53
87
  ),
54
- /* @__PURE__ */ i(h, { initials: t.initials, accountRoute: o })
88
+ /* @__PURE__ */ t(h, { initials: e.initials })
55
89
  ]
56
90
  }
57
91
  );
58
92
  }
59
- function v(e) {
60
- const { accountRoute: t, onLoginClick: o, className: m, hideAt: r, ...c } = e;
93
+ function k(i) {
94
+ const { onLoginClick: e, className: r, hideAt: s, ...l } = i;
61
95
  return /* @__PURE__ */ n(
62
- d,
96
+ a,
63
97
  {
64
98
  flexDirection: "row",
65
99
  alignItems: "center",
66
- ...c,
67
- className: u(
68
- s.unauthenticated,
69
- a(r),
70
- m
100
+ ...l,
101
+ className: d(
102
+ o.unauthenticated,
103
+ c(s),
104
+ r
71
105
  ),
72
106
  children: [
73
- /* @__PURE__ */ i(
74
- A,
107
+ /* @__PURE__ */ t(
108
+ u,
75
109
  {
76
- onClick: o,
110
+ onClick: e,
77
111
  size: "sm",
78
112
  variant: "primary",
79
113
  hideAt: ["sm", "md"],
80
114
  children: "Sign In / Register"
81
115
  }
82
116
  ),
83
- /* @__PURE__ */ i(f, { iconKey: "fa-kit fa-user-anon", size: "lg", hideAt: "lg" })
117
+ /* @__PURE__ */ t(f, { iconKey: "fa-kit fa-user-anon", size: "lg", hideAt: "lg" })
84
118
  ]
85
119
  }
86
120
  );
@@ -1,5 +1,5 @@
1
1
  import { Account as t } from "./Account.js";
2
- const c = {
2
+ const o = {
3
3
  title: "Case Parts/Molecules/Account",
4
4
  component: t,
5
5
  parameters: {
@@ -8,9 +8,8 @@ const c = {
8
8
  },
9
9
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
10
10
  tags: ["autodocs"]
11
- }, n = {
11
+ }, e = {
12
12
  args: {
13
- accountRoute: "/account",
14
13
  onLoginClick: () => {
15
14
  }
16
15
  }
@@ -21,13 +20,12 @@ const c = {
21
20
  initials: "RS",
22
21
  number: "123456789012"
23
22
  },
24
- accountRoute: "/account",
25
23
  onLoginClick: () => {
26
24
  }
27
25
  }
28
26
  };
29
27
  export {
30
28
  a as Authenticated,
31
- n as Unauthenticated,
32
- c as default
29
+ e as Unauthenticated,
30
+ o as default
33
31
  };
@@ -2,6 +2,5 @@ import { HideAtProps } from '../../atoms/HideAt';
2
2
  export interface AvatarProps extends React.HTMLAttributes<HTMLDivElement>, HideAtProps {
3
3
  /** The user's initials (2 characters) */
4
4
  initials: string;
5
- accountRoute: string;
6
5
  }
7
6
  export declare function Avatar(props: AvatarProps): import("react/jsx-runtime").JSX.Element;
@@ -1,32 +1,31 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { Flex as m } from "../../atoms/Flex/Flex.js";
3
- import { Link as c } from "../../atoms/Link/Link.js";
4
- import { getHideAtStyles as l } from "../../atoms/HideAt.js";
5
- import { c as f } from "../../clsx-OuTLNxxd.js";
6
- import { t as r } from "../../Text.module-Dzhzk2fH.js";
7
- import '../../assets/Avatar.css';const p = "_avatar_nvnsd_1", x = {
8
- avatar: p
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { Flex as n } from "../../atoms/Flex/Flex.js";
3
+ import { getHideAtStyles as m } from "../../atoms/HideAt.js";
4
+ import { c } from "../../clsx-OuTLNxxd.js";
5
+ import { t } from "../../Text.module-Dzhzk2fH.js";
6
+ import '../../assets/Avatar.css';const l = "_avatar_nvnsd_1", f = {
7
+ avatar: l
9
8
  };
10
- function A(e) {
11
- const { accountRoute: a, initials: s, className: o, hideAt: i, ...n } = e;
12
- return /* @__PURE__ */ t(c, { href: a, children: /* @__PURE__ */ t(
13
- m,
9
+ function u(r) {
10
+ const { initials: e, className: a, hideAt: s, ...i } = r;
11
+ return /* @__PURE__ */ o(
12
+ n,
14
13
  {
15
14
  flexDirection: "row",
16
15
  alignItems: "center",
17
16
  justifyContent: "center",
18
- className: f(
19
- x.avatar,
20
- r["text-display"],
21
- r["text-md"],
22
- l(i),
23
- o
17
+ className: c(
18
+ f.avatar,
19
+ t["text-display"],
20
+ t["text-md"],
21
+ m(s),
22
+ a
24
23
  ),
25
- ...n,
26
- children: s.substring(0, 2)
24
+ ...i,
25
+ children: e.substring(0, 2)
27
26
  }
28
- ) });
27
+ );
29
28
  }
30
29
  export {
31
- A as Avatar
30
+ u as Avatar
32
31
  };
@@ -10,8 +10,7 @@ const e = {
10
10
  tags: ["autodocs"]
11
11
  }, o = {
12
12
  args: {
13
- initials: "RS",
14
- accountRoute: "/account"
13
+ initials: "RS"
15
14
  }
16
15
  };
17
16
  export {
@@ -8,12 +8,13 @@ export interface MainNavProps extends CartPropsBase, React.HTMLAttributes<HTMLDi
8
8
  faqRoute: string;
9
9
  customPartsRoute: string;
10
10
  aboutUsRoute: string;
11
- accountRoute: string;
12
11
  contactRoute: string;
13
12
  cart: ShoppingCart;
14
13
  onLoginClick: () => void;
15
14
  onSearch: (_input: string) => void;
16
15
  onClickModelSerial: () => void;
16
+ /** Content shown in the account popover when authenticated */
17
+ accountPopoverContent?: React.ReactNode;
17
18
  }
18
19
  export type MainNavHandle = ShoppingCartHandle;
19
20
  export declare const MainNav: React.ForwardRefExoticComponent<MainNavProps & React.RefAttributes<ShoppingCartHandle>>;
@@ -31,19 +31,19 @@ import '../../assets/MainNav.css';const G = "_main_19pdr_1", K = "_column_19pdr_
31
31
  faqRoute: v,
32
32
  customPartsRoute: d,
33
33
  aboutUsRoute: A,
34
- accountRoute: L,
35
34
  contactRoute: h,
36
- cart: x,
37
- open: C,
35
+ cart: L,
36
+ open: x,
38
37
  // consume external panel control props from CartPropsBase
39
- className: k,
40
- onLoginClick: y,
38
+ className: C,
39
+ onLoginClick: k,
41
40
  onSearch: p,
42
41
  onClickModelSerial: f,
43
- onCartClick: b,
42
+ onCartClick: y,
43
+ accountPopoverContent: b,
44
44
  ...w
45
45
  }, j) {
46
- return /* @__PURE__ */ e(z, { ...w, gridWrapperClassName: s(r.main, k), children: /* @__PURE__ */ o(I, { span: 12, className: r.column, children: [
46
+ return /* @__PURE__ */ e(z, { ...w, gridWrapperClassName: s(r.main, C), children: /* @__PURE__ */ o(I, { span: 12, className: r.column, children: [
47
47
  /* @__PURE__ */ o(
48
48
  t,
49
49
  {
@@ -69,18 +69,18 @@ import '../../assets/MainNav.css';const G = "_main_19pdr_1", K = "_column_19pdr_
69
69
  H,
70
70
  {
71
71
  account: c,
72
- accountRoute: L,
73
- onLoginClick: y,
74
- className: r.avatar
72
+ onLoginClick: k,
73
+ className: r.avatar,
74
+ popoverContent: b
75
75
  }
76
76
  ) }),
77
77
  /* @__PURE__ */ e(
78
78
  F,
79
79
  {
80
80
  ref: j,
81
- cart: x,
82
- open: C,
83
- onCartClick: b
81
+ cart: L,
82
+ open: x,
83
+ onCartClick: y
84
84
  }
85
85
  ),
86
86
  /* @__PURE__ */ e(U, { hideAt: ["lg"], children: /* @__PURE__ */ o("ul", { className: r.menuList, children: [
@@ -1,16 +1,19 @@
1
- import { jsxs as u, Fragment as s, jsx as c } from "react/jsx-runtime";
2
- import { useState as b } from "react";
3
- import { MainNav as d } from "./MainNav.js";
4
- import { CartSlideInPanel as m } from "../../molecules/Cart/CartSlideInPanel.js";
5
- const I = {
1
+ import { jsxs as u, Fragment as h, jsx as i } from "react/jsx-runtime";
2
+ import { useState as p } from "react";
3
+ import { MainNav as b } from "./MainNav.js";
4
+ import { Text as d } from "../../atoms/Text/Text.js";
5
+ import { Link as s } from "../../atoms/Link/Link.js";
6
+ import { Button as v } from "../../atoms/Button/Button.js";
7
+ import { CartSlideInPanel as g } from "../../molecules/Cart/CartSlideInPanel.js";
8
+ const U = {
6
9
  title: "Case Parts/Organisms/MainNav",
7
- component: d,
10
+ component: b,
8
11
  parameters: {
9
12
  // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
10
13
  layout: "fullscreen"
11
14
  }
12
15
  // tags: ["autodocs"],
13
- }, o = [
16
+ }, r = [
14
17
  {
15
18
  id: 0,
16
19
  label: "Shop by Brands",
@@ -103,7 +106,7 @@ const I = {
103
106
  route: "#",
104
107
  children: []
105
108
  }
106
- ], a = "https://m.media-amazon.com/images/I/216+JEttsYL._UF1000,1000_QL80_.jpg", r = {
109
+ ], a = "https://m.media-amazon.com/images/I/216+JEttsYL._UF1000,1000_QL80_.jpg", n = {
107
110
  items: [
108
111
  { id: 1, itemId: "1094-01", description: "Kason Door Closer - Flush", price: "$99.99", quantity: 1, imageUrl: a, availability: "In Stock", availabilityId: "available" },
109
112
  { id: 2, itemId: "810810", description: "True Door Gasket", price: "$99.99", quantity: 1, imageUrl: a, availability: "In Stock", availabilityId: "available" },
@@ -119,30 +122,36 @@ const I = {
119
122
  { id: 12, itemId: "1092-02", description: "Kason Door Closer - Offset", price: "$99.99", quantity: 1, imageUrl: a, availability: "In Stock", availabilityId: "available" }
120
123
  ]
121
124
  };
122
- function v(e) {
125
+ function y(e) {
123
126
  return `$${e.items.reduce(
124
- (t, i) => t + (parseFloat(i.price.replace(/[^0-9.]/g, "")) || 0) * i.quantity,
127
+ (t, l) => t + (parseFloat(l.price.replace(/[^0-9.]/g, "")) || 0) * l.quantity,
125
128
  0
126
129
  ).toFixed(2)}`;
127
130
  }
128
- const n = (e) => {
129
- const [l, t] = b(!1);
130
- return /* @__PURE__ */ u(s, { children: [
131
- /* @__PURE__ */ c(
132
- d,
131
+ const m = /* @__PURE__ */ u("div", { style: { display: "flex", flexDirection: "column", gap: 8, minWidth: 220 }, children: [
132
+ /* @__PURE__ */ i(d, { size: "sm", weight: "semibold", children: "Account" }),
133
+ /* @__PURE__ */ i(d, { size: "xs", children: "Signed in as Ringo" }),
134
+ /* @__PURE__ */ i(s, { href: "/account", children: "View Account" }),
135
+ /* @__PURE__ */ i(s, { href: "/orders", children: "Order History" }),
136
+ /* @__PURE__ */ i(v, { size: "sm", variant: "secondary", onClick: () => alert("Sign out"), children: "Sign Out" })
137
+ ] }), c = (e) => {
138
+ const [o, t] = p(!1);
139
+ return /* @__PURE__ */ u(h, { children: [
140
+ /* @__PURE__ */ i(
141
+ b,
133
142
  {
134
143
  ...e,
135
- open: l,
136
- onCartClick: () => t((i) => !i)
144
+ open: o,
145
+ onCartClick: () => t((l) => !l)
137
146
  }
138
147
  ),
139
- /* @__PURE__ */ c(
140
- m,
148
+ /* @__PURE__ */ i(
149
+ g,
141
150
  {
142
- open: l,
151
+ open: o,
143
152
  onClose: () => t(!1),
144
153
  cart: e.cart,
145
- subtotal: v(e.cart),
154
+ subtotal: y(e.cart),
146
155
  itemPriceLabel: "List Price",
147
156
  contactHref: e.contactRoute,
148
157
  contactLinkBehavior: "new-tab",
@@ -152,13 +161,12 @@ const n = (e) => {
152
161
  }
153
162
  )
154
163
  ] });
155
- }, S = {
164
+ }, D = {
156
165
  args: {
157
166
  account: { name: "Ringo", initials: "RS", number: "123456789012" },
158
- cart: r,
167
+ cart: n,
159
168
  homeRoute: "/",
160
169
  customPartsRoute: "/custom",
161
- accountRoute: "/account",
162
170
  onClickModelSerial: () => {
163
171
  alert("Model/Serial");
164
172
  },
@@ -174,16 +182,16 @@ const n = (e) => {
174
182
  onCartClick: () => {
175
183
  },
176
184
  // placeholder required by component
177
- categories: o
185
+ categories: r,
186
+ accountPopoverContent: m
178
187
  },
179
- render: n
180
- }, C = {
188
+ render: c
189
+ }, $ = {
181
190
  args: {
182
191
  account: { name: "Ringo", initials: "RS", number: "123456789012" },
183
- cart: r,
192
+ cart: n,
184
193
  homeRoute: "/",
185
194
  customPartsRoute: "/custom",
186
- accountRoute: "/account",
187
195
  onClickModelSerial: () => {
188
196
  alert("Model/Serial");
189
197
  },
@@ -198,15 +206,15 @@ const n = (e) => {
198
206
  },
199
207
  onCartClick: () => {
200
208
  },
201
- categories: o
209
+ categories: r,
210
+ accountPopoverContent: m
202
211
  },
203
- render: n
204
- }, k = {
212
+ render: c
213
+ }, L = {
205
214
  args: {
206
- cart: r,
215
+ cart: n,
207
216
  homeRoute: "/",
208
217
  customPartsRoute: "/custom",
209
- accountRoute: "/account",
210
218
  onClickModelSerial: () => {
211
219
  alert("Model/Serial");
212
220
  },
@@ -221,13 +229,13 @@ const n = (e) => {
221
229
  },
222
230
  onCartClick: () => {
223
231
  },
224
- categories: o
232
+ categories: r
225
233
  },
226
- render: n
234
+ render: c
227
235
  };
228
236
  export {
229
- S as Authenticated,
230
- k as Unauthenticated,
231
- C as WithCartItems,
232
- I as default
237
+ D as Authenticated,
238
+ L as Unauthenticated,
239
+ $ as WithCartItems,
240
+ U as default
233
241
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@caseparts-org/caseblocks",
3
3
  "private": false,
4
- "version": "0.0.109",
4
+ "version": "0.0.110",
5
5
  "type": "module",
6
6
  "module": "dist/main.js",
7
7
  "types": "dist/main.d.ts",