@heymantle/litho 0.0.1
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/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/cjs/components/ActionList.js +267 -0
- package/dist/cjs/components/AnnouncementBar.js +73 -0
- package/dist/cjs/components/AppProvider.js +245 -0
- package/dist/cjs/components/Autocomplete.js +351 -0
- package/dist/cjs/components/Badge.js +234 -0
- package/dist/cjs/components/Banner.js +264 -0
- package/dist/cjs/components/Box.js +247 -0
- package/dist/cjs/components/Button.js +1018 -0
- package/dist/cjs/components/ButtonGroup.js +196 -0
- package/dist/cjs/components/Card.js +593 -0
- package/dist/cjs/components/Checkbox.js +175 -0
- package/dist/cjs/components/ChoiceList.js +160 -0
- package/dist/cjs/components/Collapsible.js +42 -0
- package/dist/cjs/components/ColorField.js +159 -0
- package/dist/cjs/components/ContextualSaveBar.js +53 -0
- package/dist/cjs/components/DatePicker.js +547 -0
- package/dist/cjs/components/Divider.js +50 -0
- package/dist/cjs/components/DropZone.js +547 -0
- package/dist/cjs/components/EmptyState.js +111 -0
- package/dist/cjs/components/Filters.js +874 -0
- package/dist/cjs/components/FooterHelp.js +48 -0
- package/dist/cjs/components/Form.js +44 -0
- package/dist/cjs/components/Frame.js +386 -0
- package/dist/cjs/components/FrameSaveBar.js +239 -0
- package/dist/cjs/components/Grid.js +151 -0
- package/dist/cjs/components/HorizontalStack.js +180 -0
- package/dist/cjs/components/Icon.js +346 -0
- package/dist/cjs/components/Image.js +191 -0
- package/dist/cjs/components/InlineError.js +57 -0
- package/dist/cjs/components/Label.js +78 -0
- package/dist/cjs/components/Layout.js +228 -0
- package/dist/cjs/components/LayoutSection.js +133 -0
- package/dist/cjs/components/Link.js +128 -0
- package/dist/cjs/components/List.js +69 -0
- package/dist/cjs/components/Listbox.js +211 -0
- package/dist/cjs/components/Loading.js +103 -0
- package/dist/cjs/components/Modal.js +449 -0
- package/dist/cjs/components/Navigation.js +331 -0
- package/dist/cjs/components/Page.js +529 -0
- package/dist/cjs/components/Pagination.js +109 -0
- package/dist/cjs/components/Pane.js +128 -0
- package/dist/cjs/components/Popover.js +365 -0
- package/dist/cjs/components/PopoverManager.js +34 -0
- package/dist/cjs/components/ProgressBar.js +124 -0
- package/dist/cjs/components/RadioButton.js +172 -0
- package/dist/cjs/components/RadioButtonCard.js +193 -0
- package/dist/cjs/components/RangeSlider.js +235 -0
- package/dist/cjs/components/ResourceList.js +105 -0
- package/dist/cjs/components/Select.js +300 -0
- package/dist/cjs/components/SkeletonText.js +130 -0
- package/dist/cjs/components/Spinner.js +72 -0
- package/dist/cjs/components/Table.js +1184 -0
- package/dist/cjs/components/Tabs.js +421 -0
- package/dist/cjs/components/Tag.js +165 -0
- package/dist/cjs/components/Text.js +274 -0
- package/dist/cjs/components/TextField.js +584 -0
- package/dist/cjs/components/Thumbnail.js +73 -0
- package/dist/cjs/components/TimePicker.js +23 -0
- package/dist/cjs/components/Tip.js +220 -0
- package/dist/cjs/components/Tooltip.js +431 -0
- package/dist/cjs/components/TopBar.js +210 -0
- package/dist/cjs/components/VerticalStack.js +161 -0
- package/dist/cjs/index.js +308 -0
- package/dist/cjs/styles/Table.js +591 -0
- package/dist/cjs/utilities/dates.js +339 -0
- package/dist/cjs/utilities/useIndexResourceState.js +175 -0
- package/dist/cjs/utilities/useMounted.js +67 -0
- package/dist/cjs/utilities/useTableScrollState.js +142 -0
- package/dist/esm/components/ActionList.js +216 -0
- package/dist/esm/components/AnnouncementBar.js +63 -0
- package/dist/esm/components/AppProvider.js +185 -0
- package/dist/esm/components/Autocomplete.js +300 -0
- package/dist/esm/components/Badge.js +225 -0
- package/dist/esm/components/Banner.js +254 -0
- package/dist/esm/components/Box.js +238 -0
- package/dist/esm/components/Button.js +967 -0
- package/dist/esm/components/ButtonGroup.js +137 -0
- package/dist/esm/components/Card.js +537 -0
- package/dist/esm/components/Checkbox.js +165 -0
- package/dist/esm/components/ChoiceList.js +145 -0
- package/dist/esm/components/Collapsible.js +32 -0
- package/dist/esm/components/ColorField.js +149 -0
- package/dist/esm/components/ContextualSaveBar.js +43 -0
- package/dist/esm/components/DatePicker.js +532 -0
- package/dist/esm/components/Divider.js +41 -0
- package/dist/esm/components/DropZone.js +537 -0
- package/dist/esm/components/EmptyState.js +101 -0
- package/dist/esm/components/Filters.js +823 -0
- package/dist/esm/components/FooterHelp.js +38 -0
- package/dist/esm/components/Form.js +35 -0
- package/dist/esm/components/Frame.js +376 -0
- package/dist/esm/components/FrameSaveBar.js +229 -0
- package/dist/esm/components/Grid.js +142 -0
- package/dist/esm/components/HorizontalStack.js +171 -0
- package/dist/esm/components/Icon.js +296 -0
- package/dist/esm/components/Image.js +141 -0
- package/dist/esm/components/InlineError.js +43 -0
- package/dist/esm/components/Label.js +63 -0
- package/dist/esm/components/Layout.js +164 -0
- package/dist/esm/components/LayoutSection.js +82 -0
- package/dist/esm/components/Link.js +119 -0
- package/dist/esm/components/List.js +61 -0
- package/dist/esm/components/Listbox.js +201 -0
- package/dist/esm/components/Loading.js +93 -0
- package/dist/esm/components/Modal.js +390 -0
- package/dist/esm/components/Navigation.js +321 -0
- package/dist/esm/components/Page.js +473 -0
- package/dist/esm/components/Pagination.js +99 -0
- package/dist/esm/components/Pane.js +118 -0
- package/dist/esm/components/Popover.js +350 -0
- package/dist/esm/components/PopoverManager.js +24 -0
- package/dist/esm/components/ProgressBar.js +114 -0
- package/dist/esm/components/RadioButton.js +157 -0
- package/dist/esm/components/RadioButtonCard.js +178 -0
- package/dist/esm/components/RangeSlider.js +225 -0
- package/dist/esm/components/ResourceList.js +95 -0
- package/dist/esm/components/Select.js +285 -0
- package/dist/esm/components/SkeletonText.js +120 -0
- package/dist/esm/components/Spinner.js +63 -0
- package/dist/esm/components/Table.js +1129 -0
- package/dist/esm/components/Tabs.js +366 -0
- package/dist/esm/components/Tag.js +151 -0
- package/dist/esm/components/Text.js +265 -0
- package/dist/esm/components/TextField.js +533 -0
- package/dist/esm/components/Thumbnail.js +63 -0
- package/dist/esm/components/TimePicker.js +13 -0
- package/dist/esm/components/Tip.js +169 -0
- package/dist/esm/components/Tooltip.js +380 -0
- package/dist/esm/components/TopBar.js +200 -0
- package/dist/esm/components/VerticalStack.js +152 -0
- package/dist/esm/index.js +61 -0
- package/dist/esm/styles/Table.js +581 -0
- package/dist/esm/utilities/dates.js +289 -0
- package/dist/esm/utilities/useIndexResourceState.js +158 -0
- package/dist/esm/utilities/useMounted.js +57 -0
- package/dist/esm/utilities/useTableScrollState.js +132 -0
- package/index.css +1137 -0
- package/package.json +53 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _jsxruntime = require("react/jsx-runtime");
|
|
12
|
+
var _tailwindvariants = require("tailwind-variants");
|
|
13
|
+
var styles = (0, _tailwindvariants.tv)({
|
|
14
|
+
base: "Litho-Badge inline-flex items-center gap-1.5 text-sm rounded-full leading-normal min-h-5.5",
|
|
15
|
+
variants: {
|
|
16
|
+
status: {
|
|
17
|
+
info: "bg-info-alt text-info-alt-fg",
|
|
18
|
+
success: "bg-success-alt text-success-alt-fg dark:bg-success-alt/50",
|
|
19
|
+
warning: "bg-warning-alt text-warning-alt-fg dark:bg-warning-alt/50",
|
|
20
|
+
critical: "bg-critical-alt text-critical-alt-fg dark:bg-critical-alt/50",
|
|
21
|
+
attention: "bg-attention-alt text-attention-alt-fg dark:bg-attention-alt/50",
|
|
22
|
+
highlight: "bg-highlight-alt text-highlight-alt-fg dark:bg-highlight-alt/50",
|
|
23
|
+
insight: "bg-insight-alt text-insight-alt-fg dark:bg-insight-alt/50",
|
|
24
|
+
neutral: "bg-neutral-alt text-neutral-alt-fg dark:bg-neutral-alt/50",
|
|
25
|
+
default: "bg-neutral-alt text-neutral-alt-fg dark:bg-neutral-alt/50"
|
|
26
|
+
},
|
|
27
|
+
progress: {
|
|
28
|
+
true: "pl-2 pr-2.5",
|
|
29
|
+
false: "px-2.5"
|
|
30
|
+
},
|
|
31
|
+
capitalize: {
|
|
32
|
+
true: "capitalize",
|
|
33
|
+
false: ""
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: {
|
|
37
|
+
status: "neutral",
|
|
38
|
+
progress: "null",
|
|
39
|
+
capitalize: false
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var progressBadgeStyles = (0, _tailwindvariants.tv)({
|
|
43
|
+
base: "relative overflow-hidden rounded-max w-2 h-2 border",
|
|
44
|
+
variants: {
|
|
45
|
+
status: {
|
|
46
|
+
default: "border-neutral-alt-icon",
|
|
47
|
+
info: "border-info-alt-icon",
|
|
48
|
+
success: "border-success-alt-icon",
|
|
49
|
+
warning: "border-warning-alt-icon",
|
|
50
|
+
critical: "border-critical-alt-icon",
|
|
51
|
+
attention: "border-attention-alt-icon",
|
|
52
|
+
highlight: "border-highlight-alt-icon",
|
|
53
|
+
insight: "border-insight-alt-icon",
|
|
54
|
+
neutral: "border-neutral-alt-icon"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
compoundVariants: [
|
|
58
|
+
{
|
|
59
|
+
status: "default",
|
|
60
|
+
progress: "complete",
|
|
61
|
+
class: "bg-neutral-alt-icon"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
status: "default",
|
|
65
|
+
progress: "incomplete",
|
|
66
|
+
class: "border-neutral-alt-icon"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
status: "default",
|
|
70
|
+
progress: "partiallyComplete",
|
|
71
|
+
class: "bg-neutral-alt"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
status: "info",
|
|
75
|
+
progress: "complete",
|
|
76
|
+
class: "bg-info-alt-icon"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
status: "info",
|
|
80
|
+
progress: "incomplete",
|
|
81
|
+
class: "border-info-alt-icon"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
status: "info",
|
|
85
|
+
progress: "partiallyComplete",
|
|
86
|
+
class: "bg-info-alt"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
status: "success",
|
|
90
|
+
progress: "complete",
|
|
91
|
+
class: "bg-success-alt-icon"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
status: "success",
|
|
95
|
+
progress: "incomplete",
|
|
96
|
+
class: "border-success-alt-icon"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
status: "success",
|
|
100
|
+
progress: "partiallyComplete",
|
|
101
|
+
class: "bg-success-alt"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
status: "warning",
|
|
105
|
+
progress: "complete",
|
|
106
|
+
class: "bg-warning-alt-icon"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
status: "warning",
|
|
110
|
+
progress: "incomplete",
|
|
111
|
+
class: "border-warning-alt-icon"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
status: "warning",
|
|
115
|
+
progress: "partiallyComplete",
|
|
116
|
+
class: "bg-warning-alt"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
status: "critical",
|
|
120
|
+
progress: "complete",
|
|
121
|
+
class: "bg-critical-alt-icon"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
status: "critical",
|
|
125
|
+
progress: "incomplete",
|
|
126
|
+
class: "border-critical-alt-icon"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
status: "critical",
|
|
130
|
+
progress: "partiallyComplete",
|
|
131
|
+
class: "bg-critical-alt"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
status: "attention",
|
|
135
|
+
progress: "complete",
|
|
136
|
+
class: "bg-attention-alt-icon"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
status: "attention",
|
|
140
|
+
progress: "incomplete",
|
|
141
|
+
class: "border-attention-alt-icon"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
status: "attention",
|
|
145
|
+
progress: "partiallyComplete",
|
|
146
|
+
class: "bg-attention-alt"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
status: "highlight",
|
|
150
|
+
progress: "complete",
|
|
151
|
+
class: "bg-highlight-alt-icon"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
status: "highlight",
|
|
155
|
+
progress: "incomplete",
|
|
156
|
+
class: "border-highlight-alt-icon"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
status: "highlight",
|
|
160
|
+
progress: "partiallyComplete",
|
|
161
|
+
class: "bg-highlight-alt"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
status: "insight",
|
|
165
|
+
progress: "complete",
|
|
166
|
+
class: "bg-insight-alt-icon"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
status: "insight",
|
|
170
|
+
progress: "incomplete",
|
|
171
|
+
class: "border-insight-alt-icon"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
status: "insight",
|
|
175
|
+
progress: "partiallyComplete",
|
|
176
|
+
class: "bg-insight-alt"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
status: "neutral",
|
|
180
|
+
progress: "complete",
|
|
181
|
+
class: "bg-neutral-alt-icon"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
status: "neutral",
|
|
185
|
+
progress: "incomplete",
|
|
186
|
+
class: "border-neutral-alt-icon"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
status: "neutral",
|
|
190
|
+
progress: "partiallyComplete",
|
|
191
|
+
class: "bg-neutral-alt"
|
|
192
|
+
}
|
|
193
|
+
],
|
|
194
|
+
defaultVariants: {
|
|
195
|
+
status: "default",
|
|
196
|
+
progress: "null"
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
/**
|
|
200
|
+
* Badge component with optional progress indicator.
|
|
201
|
+
*
|
|
202
|
+
* @component
|
|
203
|
+
* @param {object} props - Component properties.
|
|
204
|
+
* @param {React.ReactNode} props.children - Content to display within the badge.
|
|
205
|
+
* @param {"complete" | "incomplete" | "partiallyComplete" | null} [props.progress] - Progress state of the badge.
|
|
206
|
+
* @param {boolean} [props.capitalize] - Capitalize the first letter of the badge.
|
|
207
|
+
* @param {"default" | "info" | "success" | "warning" | "critical" | "attention" | "highlight"} [props.status="default"] - Status variant to style the badge.
|
|
208
|
+
* @returns {JSX.Element} - Rendered Badge component with optional progress indicator.
|
|
209
|
+
*/ function Badge() {
|
|
210
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
211
|
+
var children = props.children, progress = props.progress, status = props.status, capitalize = props.capitalize, className = props.className;
|
|
212
|
+
var classes = styles({
|
|
213
|
+
progress: !!progress,
|
|
214
|
+
status: status,
|
|
215
|
+
capitalize: capitalize
|
|
216
|
+
});
|
|
217
|
+
var progressBadgeClasses = progressBadgeStyles({
|
|
218
|
+
progress: progress || "null",
|
|
219
|
+
status: status
|
|
220
|
+
});
|
|
221
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
222
|
+
className: "".concat(classes).concat(className ? " ".concat(className) : ""),
|
|
223
|
+
children: [
|
|
224
|
+
progress && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
225
|
+
className: progressBadgeClasses,
|
|
226
|
+
children: progress === "partiallyComplete" && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
227
|
+
className: "absolute inset-0 top-1/2 h-1/2 bg-".concat(status, "-alt-icon")
|
|
228
|
+
})
|
|
229
|
+
}),
|
|
230
|
+
children
|
|
231
|
+
]
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
var _default = Badge;
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _jsxruntime = require("react/jsx-runtime");
|
|
12
|
+
var _tailwindvariants = require("tailwind-variants");
|
|
13
|
+
var _index = require("../index");
|
|
14
|
+
var _polarisicons = require("@shopify/polaris-icons");
|
|
15
|
+
var styles = (0, _tailwindvariants.tv)({
|
|
16
|
+
base: "Litho-Banner relative rounded-md shadow-card bg-surface-highest outline outline-tint-3"
|
|
17
|
+
});
|
|
18
|
+
var headerStyles = (0, _tailwindvariants.tv)({
|
|
19
|
+
base: "Litho-Banner__Header flex items-start justify-start min-h-3 dark:border-b",
|
|
20
|
+
variants: {
|
|
21
|
+
hasBodyContent: {
|
|
22
|
+
true: "rounded-t-md",
|
|
23
|
+
false: "rounded-md"
|
|
24
|
+
},
|
|
25
|
+
status: {
|
|
26
|
+
success: "bg-success text-success-fg dark:border-b-success-fg/5",
|
|
27
|
+
critical: "bg-critical text-critical-fg dark:border-b-critical-fg/5",
|
|
28
|
+
warning: "bg-attention text-attention-fg dark:border-b-attention-fg/5",
|
|
29
|
+
attention: "bg-attention text-attention-fg dark:border-b-attention-fg/5",
|
|
30
|
+
info: "bg-info text-info-fg dark:border-b-info-fg/5",
|
|
31
|
+
highlight: "bg-highlight text-highlight-fg dark:border-b-highlight-fg/5",
|
|
32
|
+
insight: "bg-insight text-insight-fg dark:border-b-insight-fg/5",
|
|
33
|
+
neutral: "bg-neutral text-neutral-fg dark:border-b-neutral-fg/5"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: {
|
|
37
|
+
status: "neutral"
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
var closeIconStyles = (0, _tailwindvariants.tv)({
|
|
41
|
+
base: "Litho-Banner__Close_Icon p-1 cursor-pointer rounded-md",
|
|
42
|
+
variants: {
|
|
43
|
+
status: {
|
|
44
|
+
success: "hover:bg-success-low active:bg-success-lower",
|
|
45
|
+
critical: "hover:bg-critical-low active:bg-critical-lower",
|
|
46
|
+
warning: "hover:bg-attention-low active:bg-attention-lower",
|
|
47
|
+
attention: "hover:bg-attention-low active:bg-attention-lower",
|
|
48
|
+
info: "hover:bg-info-low active:bg-info-lower",
|
|
49
|
+
highlight: "hover:bg-highlight-low active:bg-highlight-lower",
|
|
50
|
+
insight: "hover:bg-insight-low active:bg-insight-lower",
|
|
51
|
+
neutral: "hover:bg-neutral-low active:bg-neutral-lower"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
defaultVariants: {
|
|
55
|
+
status: "neutral"
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
var STATUS_STYLES = {
|
|
59
|
+
success: {
|
|
60
|
+
fg: "success-fg",
|
|
61
|
+
icon: "success-icon"
|
|
62
|
+
},
|
|
63
|
+
critical: {
|
|
64
|
+
fg: "critical-fg",
|
|
65
|
+
icon: "critical-icon"
|
|
66
|
+
},
|
|
67
|
+
warning: {
|
|
68
|
+
fg: "attention-fg",
|
|
69
|
+
icon: "attention-icon"
|
|
70
|
+
},
|
|
71
|
+
attention: {
|
|
72
|
+
fg: "attention-fg",
|
|
73
|
+
icon: "attention-icon"
|
|
74
|
+
},
|
|
75
|
+
info: {
|
|
76
|
+
fg: "info-fg",
|
|
77
|
+
icon: "info-icon"
|
|
78
|
+
},
|
|
79
|
+
highlight: {
|
|
80
|
+
fg: "highlight-fg",
|
|
81
|
+
icon: "highlight-icon"
|
|
82
|
+
},
|
|
83
|
+
insight: {
|
|
84
|
+
fg: "insight-fg",
|
|
85
|
+
icon: "insight-icon"
|
|
86
|
+
},
|
|
87
|
+
neutral: {
|
|
88
|
+
fg: "neutral-fg",
|
|
89
|
+
icon: "neutral-icon"
|
|
90
|
+
},
|
|
91
|
+
default: {
|
|
92
|
+
fg: "neutral-fg",
|
|
93
|
+
icon: "neutral-icon"
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* @typedef {'neutral' | 'critical' | 'highlight' | 'success' | 'warning' | 'info' | 'caution' | 'attention'} BannerStatus
|
|
98
|
+
*/ /**
|
|
99
|
+
* A Banner component that displays a styled banner with customizable title, status, icon, actions, and dismiss functionality.
|
|
100
|
+
* The banner style and content change based on the provided props, allowing for various statuses and themes.
|
|
101
|
+
*
|
|
102
|
+
* @component
|
|
103
|
+
*
|
|
104
|
+
* @param {Object} props - The properties for configuring the Banner component.
|
|
105
|
+
* @param {string} [props.title=null] - The title text for the banner. If not provided, no title will be displayed.
|
|
106
|
+
* @param {BannerStatus} [props.status='neutral'] - The status of the banner, which determines its color and icon.
|
|
107
|
+
* @param {Function} [props.onDismiss=null] - Callback function to handle the banner's dismiss action.
|
|
108
|
+
* @param {React.ReactNode} [props.children=null] - Additional content to display within the banner.
|
|
109
|
+
* @param {Object} [props.action=null] - Primary action configuration object
|
|
110
|
+
* @param {string} props.action.content - The button label text
|
|
111
|
+
* @param {boolean} [props.action.primary=false] - Whether the button should have primary styling
|
|
112
|
+
* @param {boolean} [props.action.disabled=false] - Whether the button is disabled
|
|
113
|
+
* @param {boolean} [props.action.loading=false] - Whether to show a loading state
|
|
114
|
+
* @param {Function} [props.action.onAction] - Click handler for the action
|
|
115
|
+
* @param {string} [props.action.url] - URL to navigate to when clicked (opens in new tab)
|
|
116
|
+
* @param {Object} [props.secondaryAction=null] - Secondary action configuration object
|
|
117
|
+
* @param {string} props.secondaryAction.content - The action label text
|
|
118
|
+
* @param {boolean} [props.secondaryAction.link=false] - Whether to render as a link instead of a button
|
|
119
|
+
* @param {boolean} [props.secondaryAction.monochrome=false] - Whether the link should be monochrome (only applies if link=true)
|
|
120
|
+
* @param {boolean} [props.secondaryAction.disabled=false] - Whether the action is disabled
|
|
121
|
+
* @param {boolean} [props.secondaryAction.loading=false] - Whether to show a loading state
|
|
122
|
+
* @param {Function} [props.secondaryAction.onAction] - Click handler for the action
|
|
123
|
+
* @param {string} [props.secondaryAction.url] - URL to navigate to when clicked (opens in new tab)
|
|
124
|
+
* @param {FunctionComponent} [props.icon=null] - Custom icon to display on the banner. If not provided, a default icon is used based on the status.
|
|
125
|
+
* @param {boolean} [props.spinner=false] - Shows a spinner icon instead of a status icon when set to true.
|
|
126
|
+
*
|
|
127
|
+
* @returns {JSX.Element} The rendered Banner component.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* <Banner
|
|
131
|
+
* title="Warning"
|
|
132
|
+
* status="warning"
|
|
133
|
+
* onDismiss={() => console.log('Dismissed')}
|
|
134
|
+
* action={{ content: "Action", primary: true, onAction: () => console.log('Action clicked') }}
|
|
135
|
+
* secondaryAction={{ content: "Learn more", link: true, monochrome: true, url: "https://example.com" }}
|
|
136
|
+
* />
|
|
137
|
+
*/ function Banner() {
|
|
138
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
139
|
+
var _props_title = props.title, title = _props_title === void 0 ? null : _props_title, _props_status = props.status, status = _props_status === void 0 ? "neutral" : _props_status, _props_onDismiss = props.onDismiss, onDismiss = _props_onDismiss === void 0 ? null : _props_onDismiss, _props_children = props.children, children = _props_children === void 0 ? null : _props_children, _props_action = props.action, action = _props_action === void 0 ? null : _props_action, _props_secondaryAction = props.secondaryAction, secondaryAction = _props_secondaryAction === void 0 ? null : _props_secondaryAction, _props_icon = props.icon, icon = _props_icon === void 0 ? null : _props_icon, _props_spinner = props.spinner, spinner = _props_spinner === void 0 ? false : _props_spinner;
|
|
140
|
+
var statusColors = STATUS_STYLES[status];
|
|
141
|
+
var hasBodyContent = !!(children || action || secondaryAction);
|
|
142
|
+
var classes = styles({
|
|
143
|
+
status: status
|
|
144
|
+
});
|
|
145
|
+
var headerClasses = headerStyles({
|
|
146
|
+
status: status,
|
|
147
|
+
hasBodyContent: hasBodyContent
|
|
148
|
+
});
|
|
149
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
150
|
+
className: classes,
|
|
151
|
+
children: [
|
|
152
|
+
title ? /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
153
|
+
className: headerClasses,
|
|
154
|
+
children: [
|
|
155
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
156
|
+
className: "Litho-Banner__Icon_Container flex-none p-3 pr-2",
|
|
157
|
+
children: [
|
|
158
|
+
spinner && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Spinner, {
|
|
159
|
+
size: "small"
|
|
160
|
+
}),
|
|
161
|
+
icon && !spinner && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Icon, {
|
|
162
|
+
source: icon,
|
|
163
|
+
color: statusColors.icon || ""
|
|
164
|
+
}),
|
|
165
|
+
!icon && !spinner && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
166
|
+
children: [
|
|
167
|
+
![
|
|
168
|
+
"warning",
|
|
169
|
+
"attention",
|
|
170
|
+
"success"
|
|
171
|
+
].includes(status) && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Icon, {
|
|
172
|
+
source: _polarisicons.CircleInformationMajor,
|
|
173
|
+
color: statusColors.icon
|
|
174
|
+
}),
|
|
175
|
+
[
|
|
176
|
+
"warning",
|
|
177
|
+
"attention"
|
|
178
|
+
].includes(status) && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Icon, {
|
|
179
|
+
source: _polarisicons.CircleAlertMajor,
|
|
180
|
+
color: statusColors.icon
|
|
181
|
+
}),
|
|
182
|
+
status === "success" && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Icon, {
|
|
183
|
+
source: _polarisicons.TickMinor,
|
|
184
|
+
color: statusColors.icon
|
|
185
|
+
})
|
|
186
|
+
]
|
|
187
|
+
})
|
|
188
|
+
]
|
|
189
|
+
}),
|
|
190
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
191
|
+
className: "Litho-Banner__Title grow py-3",
|
|
192
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Text, {
|
|
193
|
+
variant: "headingSm",
|
|
194
|
+
color: statusColors.fg,
|
|
195
|
+
children: title
|
|
196
|
+
})
|
|
197
|
+
}),
|
|
198
|
+
onDismiss && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
199
|
+
className: "Litho-Banner__Close flex-none p-2",
|
|
200
|
+
onClick: onDismiss,
|
|
201
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
202
|
+
className: closeIconStyles({
|
|
203
|
+
status: status
|
|
204
|
+
}),
|
|
205
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Icon, {
|
|
206
|
+
source: _polarisicons.CancelMinor,
|
|
207
|
+
color: statusColors.icon
|
|
208
|
+
})
|
|
209
|
+
})
|
|
210
|
+
})
|
|
211
|
+
]
|
|
212
|
+
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
213
|
+
className: headerClasses
|
|
214
|
+
}),
|
|
215
|
+
hasBodyContent && /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
216
|
+
className: "Litho-Banner__Body_Container p-4 ".concat(title ? " dark:border-t dark:border-t-tint-4" : ""),
|
|
217
|
+
children: [
|
|
218
|
+
children && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
219
|
+
className: "Litho-Banner__Body",
|
|
220
|
+
children: children
|
|
221
|
+
}),
|
|
222
|
+
(action || secondaryAction) && /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
223
|
+
className: "Litho-Banner__Actions flex items-center gap-2".concat((secondaryAction === null || secondaryAction === void 0 ? void 0 : secondaryAction.link) ? " gap-3" : "").concat(children ? " pt-2" : ""),
|
|
224
|
+
children: [
|
|
225
|
+
action && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Button, {
|
|
226
|
+
primary: action.primary,
|
|
227
|
+
disabled: action.disabled,
|
|
228
|
+
loading: action.loading,
|
|
229
|
+
onClick: action.onAction || function() {
|
|
230
|
+
if (action.url) {
|
|
231
|
+
window.open(action.url, "_blank");
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
children: action.content
|
|
235
|
+
}),
|
|
236
|
+
secondaryAction && !secondaryAction.link && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Button, {
|
|
237
|
+
disabled: secondaryAction.disabled,
|
|
238
|
+
loading: secondaryAction.loading,
|
|
239
|
+
onClick: secondaryAction.onAction || function() {
|
|
240
|
+
if (secondaryAction.url) {
|
|
241
|
+
window.open(secondaryAction.url, "_blank");
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
children: secondaryAction.content
|
|
245
|
+
}),
|
|
246
|
+
secondaryAction && secondaryAction.link && /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Link, {
|
|
247
|
+
monochrome: secondaryAction.monochrome,
|
|
248
|
+
disabled: secondaryAction.disabled,
|
|
249
|
+
loading: secondaryAction.loading,
|
|
250
|
+
onClick: secondaryAction.onAction || function() {
|
|
251
|
+
if (secondaryAction.url) {
|
|
252
|
+
window.open(secondaryAction.url, "_blank");
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
children: secondaryAction.content
|
|
256
|
+
})
|
|
257
|
+
]
|
|
258
|
+
})
|
|
259
|
+
]
|
|
260
|
+
})
|
|
261
|
+
]
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
var _default = Banner;
|