@caseparts-org/caseblocks 0.0.156 → 0.0.157

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.
@@ -0,0 +1 @@
1
+ ._error_10jtk_1{display:flex;flex-direction:column;align-items:center;justify-content:center;max-width:100%;overflow-x:hidden;gap:var(--spacing-spacing-2xs);padding:var(--spacing-spacing-2xs);border:1px solid var(--border-border-error-warning);border-radius:var(--border-radius-sm);background-color:color-mix(in srgb,var(--color-alerts-error-warning) 8%,transparent);transition:all .3s ease-in}._variantError_10jtk_16{border-color:var(--border-border-error-warning);background-color:color-mix(in srgb,var(--color-alerts-error-warning) 8%,transparent)}._variantWarning_10jtk_21{border-color:var(--border-border-warning);background-color:color-mix(in srgb,var(--color-alerts-warning) 8%,transparent)}._variantDefault_10jtk_26{border-color:var(--border-border-primary);background-color:var(--surface-surface-primary)}._errorHeader_10jtk_31{width:100%;display:flex;flex-direction:row;align-items:center;justify-content:space-between;gap:var(--spacing-spacing-2xs)}._errorHeaderContent_10jtk_40{min-width:0;display:flex;flex-direction:row;align-items:center;gap:var(--spacing-spacing-2xs)}._detailsToggleButton_10jtk_48{width:1.5rem;height:1.5rem;border:none;border-radius:var(--border-radius-xs);background:transparent;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}._detailsToggleButton_10jtk_48:hover,._detailsToggleButton_10jtk_48:focus-visible{background-color:var(--surface-surface-secondary)}._detailsChevron_10jtk_66{display:inline-flex;align-items:center;justify-content:center;transform:rotate(0);transition:transform .2s ease}._detailsChevronOpen_10jtk_74{transform:rotate(180deg)}._errorDetails_10jtk_78{position:relative;padding:var(--spacing-spacing-2xs);border:1px solid var(--border-border-primary);background-color:var(--surface-surface-primary);border-radius:var(--border-radius-sm);overflow:hidden;white-space:pre-wrap;word-wrap:break-word;overflow-wrap:break-word;overflow-wrap:anywhere;font-family:monospace;width:100%;transition:max-height .28s ease,opacity .2s ease}._errorDetailsContent_10jtk_94{padding-top:var(--spacing-spacing-3xs);padding-right:2rem}._copyButton_10jtk_99{position:absolute;top:var(--spacing-spacing-3xs);right:var(--spacing-spacing-3xs);width:1.5rem;height:1.5rem;border:none;border-radius:var(--border-radius-xs);background:transparent;cursor:pointer;display:inline-flex;align-items:center;justify-content:center}._copyIcon_10jtk_114,._checkIcon_10jtk_115{position:absolute;display:inline-flex;align-items:center;justify-content:center}._hiddenIcon_10jtk_122{opacity:0;pointer-events:none}._copyButton_10jtk_99:hover,._copyButton_10jtk_99:focus-visible{background-color:var(--surface-surface-secondary)}
@@ -34,6 +34,8 @@ export { ImageViewer } from './molecules/ImageViewer/ImageViewer';
34
34
  export type { ImageViewerProps } from './molecules/ImageViewer/ImageViewer';
35
35
  export { Table } from './molecules/Table/Table';
36
36
  export type { TableProps, TableAlign, ColumnsProps, ColumnProps, BodyProps, RowProps, CellProps, TableComponent } from './molecules/Table/Table';
37
+ export { Error } from './molecules/Error/Error';
38
+ export type { ErrorProps, ErrorMessageProps, ErrorDetailsProps } from './molecules/Error/Error';
37
39
  export { MainNav } from './organisms/MainNav/MainNav';
38
40
  export type { MainNavProps } from './organisms/MainNav/MainNav';
39
41
  export { ChipSelector } from './organisms/ChipSelector/ChipSelector';
@@ -15,10 +15,10 @@ import { configureImage as b } from "./atoms/Image/configureImage.js";
15
15
  import { getHideAtStyles as F } from "./atoms/HideAt.js";
16
16
  import { Logo as N } from "./molecules/Logo/Logo.js";
17
17
  import { SearchBox as z } from "./molecules/SearchBox/SearchBox.js";
18
- import { QuantityInput as O } from "./molecules/QuantityInput/QuantityInput.js";
19
- import { Pricing as R } from "./molecules/Pricing/Pricing.js";
20
- import { Availability as j } from "./molecules/Availability/Availability.js";
21
- import { Avatar as D } from "./molecules/Avatar/Avatar.js";
18
+ import { QuantityInput as G } from "./molecules/QuantityInput/QuantityInput.js";
19
+ import { Pricing as Q } from "./molecules/Pricing/Pricing.js";
20
+ import { Availability as Z } from "./molecules/Availability/Availability.js";
21
+ import { Avatar as q } from "./molecules/Avatar/Avatar.js";
22
22
  import { BannerCard as J } from "./molecules/BannerCard/BannerCard.js";
23
23
  import { CardLink as U } from "./molecules/CardLink/CardLink.js";
24
24
  import { Breadcrumbs as X } from "./molecules/Breadcrumbs/Breadcrumbs.js";
@@ -40,29 +40,31 @@ import { AddToCart as vo } from "./molecules/AddToCart/AddToCart.js";
40
40
  import { Modal as ho } from "./molecules/Modal/Modal.js";
41
41
  import { ImageViewer as yo } from "./molecules/ImageViewer/ImageViewer.js";
42
42
  import { T as Ho } from "./Table-BX4PtCNE.js";
43
- import { MainNav as Vo } from "./organisms/MainNav/MainNav.js";
44
- import { ChipSelector as Go } from "./organisms/ChipSelector/ChipSelector.js";
45
- import { Product as Qo } from "./organisms/Product/Product.js";
46
- import { Carousel as Zo } from "./organisms/Carousel/Carousel.js";
47
- import { Footer as qo } from "./organisms/Footer/Footer.js";
48
- import { default as Eo } from "./organisms/SpinZoomViewer/SpinZoomViewer.js";
43
+ import { Error as Vo } from "./molecules/Error/Error.js";
44
+ import { MainNav as Eo } from "./organisms/MainNav/MainNav.js";
45
+ import { ChipSelector as Oo } from "./organisms/ChipSelector/ChipSelector.js";
46
+ import { Product as Ro } from "./organisms/Product/Product.js";
47
+ import { Carousel as jo } from "./organisms/Carousel/Carousel.js";
48
+ import { Footer as Do } from "./organisms/Footer/Footer.js";
49
+ import { default as Ko } from "./organisms/SpinZoomViewer/SpinZoomViewer.js";
49
50
  export {
50
51
  so as Account,
51
52
  vo as AddToCart,
52
53
  Mo as AnimatedCheckMark,
53
- j as Availability,
54
- D as Avatar,
54
+ Z as Availability,
55
+ q as Avatar,
55
56
  J as BannerCard,
56
57
  X as Breadcrumbs,
57
58
  e as Button,
58
59
  U as CardLink,
59
- Zo as Carousel,
60
+ jo as Carousel,
60
61
  Po as CartSlideInPanel,
61
62
  Co as Chip,
62
- Go as ChipSelector,
63
+ Oo as ChipSelector,
63
64
  f as Column,
65
+ Vo as Error,
64
66
  p as Flex,
65
- qo as Footer,
67
+ Do as Footer,
66
68
  x as Grid,
67
69
  n as Head,
68
70
  oo as HorizontalScroll,
@@ -72,20 +74,20 @@ export {
72
74
  P as Link,
73
75
  L as LinkButton,
74
76
  N as Logo,
75
- Vo as MainNav,
77
+ Eo as MainNav,
76
78
  po as Markdown,
77
79
  ho as Modal,
78
80
  _ as NotFound,
79
81
  uo as Popover,
80
82
  fo as PreprocessedMarkdown,
81
- R as Pricing,
82
- Qo as Product,
83
- O as QuantityInput,
83
+ Q as Pricing,
84
+ Ro as Product,
85
+ G as QuantityInput,
84
86
  u as Root,
85
87
  z as SearchBox,
86
88
  s as Separator,
87
89
  eo as SlideInPanel,
88
- Eo as SpinZoomViewer,
90
+ Ko as SpinZoomViewer,
89
91
  Ao as StatefulButton,
90
92
  Ho as Table,
91
93
  C as Text,
package/dist/main.d.ts CHANGED
@@ -22,6 +22,8 @@ export type { ChipProps } from './molecules/Chip/Chip';
22
22
  export { Logo } from './molecules/Logo/Logo';
23
23
  export { SearchBox } from './molecules/SearchBox/SearchBox';
24
24
  export type { SearchBoxProps } from './molecules/SearchBox/SearchBox';
25
+ export { Error } from './molecules/Error/Error';
26
+ export type { ErrorProps, ErrorMessageProps, ErrorDetailsProps, } from './molecules/Error/Error';
25
27
  export { ToggleView } from './molecules/ToggleView/ToggleView';
26
28
  export type { ToggleViewProps, ToggleOptionProps, ToggleOptionBaseProps, } from './molecules/ToggleView/ToggleView';
27
29
  export { MainNav } from './organisms/MainNav/MainNav';
package/dist/main.js CHANGED
@@ -9,29 +9,31 @@ import { Text as S } from "./atoms/Text/Text.js";
9
9
  import { Input as v } from "./atoms/Input/Input.js";
10
10
  import { Account as B } from "./molecules/Account/Account.js";
11
11
  import { Avatar as T } from "./molecules/Avatar/Avatar.js";
12
- import { Chip as F } from "./molecules/Chip/Chip.js";
13
- import { Logo as H } from "./molecules/Logo/Logo.js";
14
- import { SearchBox as M } from "./molecules/SearchBox/SearchBox.js";
15
- import { ToggleView as R } from "./molecules/ToggleView/ToggleView.js";
16
- import { MainNav as b } from "./organisms/MainNav/MainNav.js";
17
- import { ChipSelector as k } from "./organisms/ChipSelector/ChipSelector.js";
12
+ import { Chip as E } from "./molecules/Chip/Chip.js";
13
+ import { Logo as G } from "./molecules/Logo/Logo.js";
14
+ import { SearchBox as L } from "./molecules/SearchBox/SearchBox.js";
15
+ import { Error as N } from "./molecules/Error/Error.js";
16
+ import { ToggleView as V } from "./molecules/ToggleView/ToggleView.js";
17
+ import { MainNav as j } from "./organisms/MainNav/MainNav.js";
18
+ import { ChipSelector as q } from "./organisms/ChipSelector/ChipSelector.js";
18
19
  export {
19
20
  B as Account,
20
21
  T as Avatar,
21
22
  e as Button,
22
- F as Chip,
23
- k as ChipSelector,
23
+ E as Chip,
24
+ q as ChipSelector,
24
25
  m as Column,
26
+ N as Error,
25
27
  p as Flex,
26
28
  f as Grid,
27
29
  n as Head,
28
30
  i as Icon,
29
31
  v as Input,
30
- H as Logo,
31
- b as MainNav,
32
+ G as Logo,
33
+ j as MainNav,
32
34
  u as Root,
33
- M as SearchBox,
35
+ L as SearchBox,
34
36
  h as Separator,
35
37
  S as Text,
36
- R as ToggleView
38
+ V as ToggleView
37
39
  };
@@ -0,0 +1,24 @@
1
+ import { default as React, ReactNode } from 'react';
2
+ export interface ErrorProps {
3
+ isVisible?: boolean;
4
+ className?: string;
5
+ children?: ReactNode;
6
+ hideDetails?: boolean;
7
+ detailsMaxHeight?: number | string;
8
+ variant?: "error" | "warning" | "default";
9
+ }
10
+ export interface ErrorMessageProps {
11
+ children?: ReactNode;
12
+ }
13
+ export interface ErrorDetailsProps {
14
+ children?: ReactNode;
15
+ hide?: boolean;
16
+ }
17
+ declare function ErrorMessage({ children }: ErrorMessageProps): import("react/jsx-runtime").JSX.Element;
18
+ declare function ErrorDetails({ children }: ErrorDetailsProps): import("react/jsx-runtime").JSX.Element;
19
+ interface ErrorComponent extends React.FC<ErrorProps> {
20
+ Message: typeof ErrorMessage;
21
+ Details: typeof ErrorDetails;
22
+ }
23
+ export declare const Error: ErrorComponent;
24
+ export {};
@@ -0,0 +1,148 @@
1
+ import { jsxs as c, jsx as r, Fragment as b } from "react/jsx-runtime";
2
+ import p, { useState as v, useMemo as R, useEffect as D } from "react";
3
+ import { c as f } from "../../clsx-OuTLNxxd.js";
4
+ import { Icon as m } from "../../atoms/Icon/Icon.js";
5
+ import { Text as K } from "../../atoms/Text/Text.js";
6
+ import '../../assets/Error.css';const V = "_error_10jtk_1", W = "_variantError_10jtk_16", $ = "_variantWarning_10jtk_21", F = "_variantDefault_10jtk_26", L = "_errorHeader_10jtk_31", q = "_errorHeaderContent_10jtk_40", U = "_detailsToggleButton_10jtk_48", Y = "_detailsChevron_10jtk_66", G = "_detailsChevronOpen_10jtk_74", J = "_errorDetails_10jtk_78", P = "_errorDetailsContent_10jtk_94", Q = "_copyButton_10jtk_99", X = "_copyIcon_10jtk_114", Z = "_checkIcon_10jtk_115", ee = "_hiddenIcon_10jtk_122", t = {
7
+ error: V,
8
+ variantError: W,
9
+ variantWarning: $,
10
+ variantDefault: F,
11
+ errorHeader: L,
12
+ errorHeaderContent: q,
13
+ detailsToggleButton: U,
14
+ detailsChevron: Y,
15
+ detailsChevronOpen: G,
16
+ errorDetails: J,
17
+ errorDetailsContent: P,
18
+ copyButton: Q,
19
+ copyIcon: X,
20
+ checkIcon: Z,
21
+ hiddenIcon: ee
22
+ };
23
+ function x({ children: n }) {
24
+ return /* @__PURE__ */ r(b, { children: n });
25
+ }
26
+ function S({ children: n }) {
27
+ return /* @__PURE__ */ r(b, { children: n });
28
+ }
29
+ function N(n) {
30
+ return p.isValidElement(n) && n.type === x;
31
+ }
32
+ function E(n) {
33
+ return p.isValidElement(n) && n.type === S;
34
+ }
35
+ function te({
36
+ isVisible: n = !0,
37
+ className: H,
38
+ children: T,
39
+ hideDetails: I = !1,
40
+ detailsMaxHeight: _ = 300,
41
+ variant: d = "error"
42
+ }) {
43
+ const [o, h] = v(!1), [g, y] = v(!1), [a, k] = v(!1), s = R(() => {
44
+ const e = p.Children.toArray(T), u = e.find(
45
+ (l) => E(l) && !l.props.hide
46
+ ), w = e.find(N), j = e.filter(
47
+ (l) => !E(l) && !N(l)
48
+ );
49
+ return {
50
+ message: w ? w.props.children : j.length > 0 ? j : null,
51
+ details: I ? null : u ? u.props.children : null
52
+ };
53
+ }, [T, I]), i = !!s.details;
54
+ if (D(() => {
55
+ i || (h(!1), y(!1));
56
+ }, [i]), D(() => {
57
+ if (o || !g)
58
+ return;
59
+ const e = window.setTimeout(() => y(!1), 280);
60
+ return () => window.clearTimeout(e);
61
+ }, [o, g]), D(() => {
62
+ if (!a)
63
+ return;
64
+ const e = window.setTimeout(() => k(!1), 1500);
65
+ return () => window.clearTimeout(e);
66
+ }, [a]), !n || !s.message)
67
+ return null;
68
+ const A = t[`variant${d[0].toUpperCase()}${d.slice(1)}`], B = d === "warning" ? "warning" : d === "default" ? "default" : "error-warning", M = typeof _ == "number" ? `${_}px` : _, C = (e) => e == null || typeof e == "boolean" ? "" : typeof e == "string" || typeof e == "number" ? String(e) : Array.isArray(e) ? e.map((u) => C(u)).join("") : p.isValidElement(e) ? C(e.props.children) : "", O = async () => {
69
+ if (!i)
70
+ return;
71
+ const e = C(s.details);
72
+ if (e.trim())
73
+ try {
74
+ await navigator.clipboard.writeText(e), k(!0);
75
+ } catch {
76
+ k(!1);
77
+ }
78
+ }, z = () => {
79
+ if (o) {
80
+ h(!1);
81
+ return;
82
+ }
83
+ y(!0), window.requestAnimationFrame(() => {
84
+ h(!0);
85
+ });
86
+ };
87
+ return /* @__PURE__ */ c("div", { className: f(t.error, A, H), children: [
88
+ /* @__PURE__ */ c("div", { className: t.errorHeader, children: [
89
+ /* @__PURE__ */ c("div", { className: t.errorHeaderContent, children: [
90
+ /* @__PURE__ */ r(
91
+ m,
92
+ {
93
+ iconKey: "fa-solid fa-triangle-exclamation",
94
+ size: "md",
95
+ colorToken: B
96
+ }
97
+ ),
98
+ typeof s.message == "string" || typeof s.message == "number" ? /* @__PURE__ */ r(K, { size: "md", children: s.message }) : s.message
99
+ ] }),
100
+ i && /* @__PURE__ */ r(
101
+ "button",
102
+ {
103
+ type: "button",
104
+ className: t.detailsToggleButton,
105
+ "aria-label": o ? "Hide details" : "Show details",
106
+ title: o ? "Hide details" : "Show details",
107
+ onClick: z,
108
+ children: /* @__PURE__ */ r("span", { className: f(t.detailsChevron, o && t.detailsChevronOpen), children: /* @__PURE__ */ r(m, { iconKey: "fa-light fa-chevron-down", size: "sm", colorToken: "default" }) })
109
+ }
110
+ )
111
+ ] }),
112
+ i && g && /* @__PURE__ */ c(
113
+ "div",
114
+ {
115
+ className: t.errorDetails,
116
+ style: {
117
+ maxHeight: o ? M : "0px",
118
+ opacity: o ? 1 : 0,
119
+ overflowY: o ? "auto" : "hidden"
120
+ },
121
+ children: [
122
+ /* @__PURE__ */ c(
123
+ "button",
124
+ {
125
+ type: "button",
126
+ className: t.copyButton,
127
+ "aria-label": "Copy error details",
128
+ title: a ? "Copied" : "Copy details",
129
+ onClick: O,
130
+ children: [
131
+ /* @__PURE__ */ r("span", { className: f(t.copyIcon, a && t.hiddenIcon), children: /* @__PURE__ */ r(m, { iconKey: "fa-regular fa-copy", size: "sm", colorToken: "default" }) }),
132
+ /* @__PURE__ */ r("span", { className: f(t.checkIcon, !a && t.hiddenIcon), children: /* @__PURE__ */ r(m, { iconKey: "fa-regular fa-check", size: "sm", colorToken: "default" }) })
133
+ ]
134
+ }
135
+ ),
136
+ /* @__PURE__ */ r("div", { className: t.errorDetailsContent, children: s.details })
137
+ ]
138
+ }
139
+ )
140
+ ] });
141
+ }
142
+ const ce = Object.assign(te, {
143
+ Message: x,
144
+ Details: S
145
+ });
146
+ export {
147
+ ce as Error
148
+ };
@@ -0,0 +1,16 @@
1
+ import { Meta, StoryObj } from '@storybook/react-vite';
2
+ interface DemoArgs {
3
+ isVisible: boolean;
4
+ hideDetails: boolean;
5
+ detailsMaxHeight: number;
6
+ variant: "error" | "warning" | "default";
7
+ message: string;
8
+ details: string;
9
+ }
10
+ declare const meta: Meta<DemoArgs>;
11
+ export default meta;
12
+ type Story = StoryObj<DemoArgs>;
13
+ export declare const Playground: Story;
14
+ export declare const ComposedChildren: Story;
15
+ export declare const WithoutDetails: Story;
16
+ export declare const Hidden: Story;
@@ -0,0 +1,105 @@
1
+ import { jsx as t, jsxs as s } from "react/jsx-runtime";
2
+ import { Error as i } from "./Error.js";
3
+ const o = {
4
+ title: "Case Parts/Molecules/Error",
5
+ component: i,
6
+ tags: ["autodocs"],
7
+ parameters: {
8
+ layout: "centered",
9
+ docs: {
10
+ description: {
11
+ component: `
12
+ A composed error message component.
13
+
14
+ Usage:
15
+ - \`<Error />\` as the root wrapper
16
+ - \`<Error.Message />\` for the primary message
17
+ - \`<Error.Details />\` for expandable diagnostic details
18
+ `.trim()
19
+ }
20
+ }
21
+ },
22
+ argTypes: {
23
+ isVisible: {
24
+ control: { type: "boolean" },
25
+ description: "Controls whether the message is rendered."
26
+ },
27
+ hideDetails: {
28
+ control: { type: "boolean" },
29
+ description: "Force-hide details content and toggle even when provided."
30
+ },
31
+ detailsMaxHeight: {
32
+ control: { type: "number", min: 80, max: 800, step: 10 },
33
+ description: "Maximum details panel height in px before vertical scrolling."
34
+ },
35
+ variant: {
36
+ control: { type: "radio" },
37
+ options: ["error", "warning", "default"],
38
+ description: "Visual style variant."
39
+ },
40
+ message: {
41
+ control: { type: "text" },
42
+ description: "Primary message text."
43
+ },
44
+ details: {
45
+ control: { type: "text" },
46
+ description: "Details text shown in expandable panel."
47
+ }
48
+ },
49
+ args: {
50
+ isVisible: !0,
51
+ hideDetails: !1,
52
+ detailsMaxHeight: 300,
53
+ variant: "error",
54
+ message: "We could not load your cart.",
55
+ details: `Request failed with status 503.
56
+ TraceId: 3de8c8ff-33b7-49c8-a4b7-739f1f3a11a9`
57
+ }
58
+ }, n = {
59
+ render: (e) => /* @__PURE__ */ t("div", { style: { width: 640 }, children: /* @__PURE__ */ s(
60
+ i,
61
+ {
62
+ isVisible: e.isVisible,
63
+ hideDetails: e.hideDetails,
64
+ detailsMaxHeight: e.detailsMaxHeight,
65
+ variant: e.variant,
66
+ children: [
67
+ /* @__PURE__ */ t(i.Message, { children: e.message }),
68
+ /* @__PURE__ */ t(i.Details, { children: e.details })
69
+ ]
70
+ }
71
+ ) })
72
+ }, l = {
73
+ args: {
74
+ message: "Inventory service reported a warning.",
75
+ details: `The data source responded with stale data.
76
+ Last refresh: 7m 12s ago.`,
77
+ variant: "warning"
78
+ }
79
+ }, d = {
80
+ render: (e) => /* @__PURE__ */ t("div", { style: { width: 640 }, children: /* @__PURE__ */ t(
81
+ i,
82
+ {
83
+ isVisible: e.isVisible,
84
+ hideDetails: e.hideDetails,
85
+ detailsMaxHeight: e.detailsMaxHeight,
86
+ variant: e.variant,
87
+ children: /* @__PURE__ */ t(i.Message, { children: e.message })
88
+ }
89
+ ) }),
90
+ args: {
91
+ message: "An unknown issue occurred.",
92
+ variant: "default"
93
+ }
94
+ }, c = {
95
+ args: {
96
+ isVisible: !1
97
+ }
98
+ };
99
+ export {
100
+ l as ComposedChildren,
101
+ c as Hidden,
102
+ n as Playground,
103
+ d as WithoutDetails,
104
+ o as default
105
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@caseparts-org/caseblocks",
3
3
  "private": false,
4
- "version": "0.0.156",
4
+ "version": "0.0.157",
5
5
  "type": "module",
6
6
  "module": "dist/main.js",
7
7
  "types": "dist/main.d.ts",