@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,137 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
function _define_property(obj, key, value) {
|
|
3
|
+
if (key in obj) {
|
|
4
|
+
Object.defineProperty(obj, key, {
|
|
5
|
+
value: value,
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
writable: true
|
|
9
|
+
});
|
|
10
|
+
} else {
|
|
11
|
+
obj[key] = value;
|
|
12
|
+
}
|
|
13
|
+
return obj;
|
|
14
|
+
}
|
|
15
|
+
function _object_spread(target) {
|
|
16
|
+
for(var i = 1; i < arguments.length; i++){
|
|
17
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
18
|
+
var ownKeys = Object.keys(source);
|
|
19
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
20
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
21
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
ownKeys.forEach(function(key) {
|
|
25
|
+
_define_property(target, key, source[key]);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return target;
|
|
29
|
+
}
|
|
30
|
+
function ownKeys(object, enumerableOnly) {
|
|
31
|
+
var keys = Object.keys(object);
|
|
32
|
+
if (Object.getOwnPropertySymbols) {
|
|
33
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
34
|
+
if (enumerableOnly) {
|
|
35
|
+
symbols = symbols.filter(function(sym) {
|
|
36
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
keys.push.apply(keys, symbols);
|
|
40
|
+
}
|
|
41
|
+
return keys;
|
|
42
|
+
}
|
|
43
|
+
function _object_spread_props(target, source) {
|
|
44
|
+
source = source != null ? source : {};
|
|
45
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
46
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
47
|
+
} else {
|
|
48
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
49
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return target;
|
|
53
|
+
}
|
|
54
|
+
function _object_without_properties(source, excluded) {
|
|
55
|
+
if (source == null) return {};
|
|
56
|
+
var target = _object_without_properties_loose(source, excluded);
|
|
57
|
+
var key, i;
|
|
58
|
+
if (Object.getOwnPropertySymbols) {
|
|
59
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
60
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
61
|
+
key = sourceSymbolKeys[i];
|
|
62
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
63
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
64
|
+
target[key] = source[key];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return target;
|
|
68
|
+
}
|
|
69
|
+
function _object_without_properties_loose(source, excluded) {
|
|
70
|
+
if (source == null) return {};
|
|
71
|
+
var target = {};
|
|
72
|
+
var sourceKeys = Object.keys(source);
|
|
73
|
+
var key, i;
|
|
74
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
75
|
+
key = sourceKeys[i];
|
|
76
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
77
|
+
target[key] = source[key];
|
|
78
|
+
}
|
|
79
|
+
return target;
|
|
80
|
+
}
|
|
81
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
82
|
+
import React, { createContext } from "react";
|
|
83
|
+
import { tv } from "tailwind-variants";
|
|
84
|
+
var styles = tv({
|
|
85
|
+
base: "Litho-ButtonGroup flex flex-row",
|
|
86
|
+
variants: {
|
|
87
|
+
segmented: {
|
|
88
|
+
true: "Litho-ButtonGroup--Segmented",
|
|
89
|
+
false: "gap-2"
|
|
90
|
+
},
|
|
91
|
+
noWrap: {
|
|
92
|
+
true: "flex-nowrap"
|
|
93
|
+
},
|
|
94
|
+
fullWidth: {
|
|
95
|
+
true: "Litho-ButtonGroup--FullWidth"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
export var ButtonGroupContext = /*#__PURE__*/ createContext(false);
|
|
100
|
+
/**
|
|
101
|
+
* ButtonGroup Component
|
|
102
|
+
*
|
|
103
|
+
* @param {object} props - The properties object.
|
|
104
|
+
* @param {React.ReactNode} [props.children] - The child components to be rendered inside the button group.
|
|
105
|
+
* @param {boolean} [props.segmented=false] - Determines whether the button group has segmented styling.
|
|
106
|
+
* @param {string} [props.id] - The unique identifier for the button group.
|
|
107
|
+
* @param {string} [props.className] - Additional class names to be added to the button group.
|
|
108
|
+
* @param {boolean} [props.fullWidth=false] - Determines if the button group spans the full width of the container.
|
|
109
|
+
* @param {boolean} [props.noWrap=false] - Determines if the buttons inside the group do not wrap.
|
|
110
|
+
* @param {object} [props.restProps] - Additional props to be spread onto the container element.
|
|
111
|
+
* @returns {JSX.Element} The rendered ButtonGroup component.
|
|
112
|
+
*/ function ButtonGroup() {
|
|
113
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
114
|
+
var children = props.children, _props_segmented = props.segmented, segmented = _props_segmented === void 0 ? false : _props_segmented, id = props.id, className = props.className, _props_fullWidth = props.fullWidth, fullWidth = _props_fullWidth === void 0 ? false : _props_fullWidth, _props_noWrap = props.noWrap, noWrap = _props_noWrap === void 0 ? false : _props_noWrap, restProps = _object_without_properties(props, [
|
|
115
|
+
"children",
|
|
116
|
+
"segmented",
|
|
117
|
+
"id",
|
|
118
|
+
"className",
|
|
119
|
+
"fullWidth",
|
|
120
|
+
"noWrap"
|
|
121
|
+
]);
|
|
122
|
+
var classes = styles({
|
|
123
|
+
segmented: segmented,
|
|
124
|
+
noWrap: noWrap,
|
|
125
|
+
fullWidth: fullWidth
|
|
126
|
+
});
|
|
127
|
+
return /*#__PURE__*/ _jsx(ButtonGroupContext.Provider, {
|
|
128
|
+
value: segmented,
|
|
129
|
+
children: /*#__PURE__*/ _jsx("div", _object_spread_props(_object_spread({
|
|
130
|
+
id: id,
|
|
131
|
+
className: "".concat(classes).concat(className ? " ".concat(className) : "")
|
|
132
|
+
}, restProps), {
|
|
133
|
+
children: children
|
|
134
|
+
}))
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
export default ButtonGroup;
|
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
function _type_of(obj) {
|
|
3
|
+
"@swc/helpers - typeof";
|
|
4
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
5
|
+
}
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
|
+
import React, { useContext } from "react";
|
|
8
|
+
import { tv } from "tailwind-variants";
|
|
9
|
+
import { FrameContext } from "./AppProvider.js";
|
|
10
|
+
import Button from "./Button.js";
|
|
11
|
+
import Icon from "./Icon.js";
|
|
12
|
+
import Spinner from "./Spinner.js";
|
|
13
|
+
import Text from "./Text.js";
|
|
14
|
+
import Tooltip from "./Tooltip.js";
|
|
15
|
+
var styles = tv({
|
|
16
|
+
base: "Litho-Card relative",
|
|
17
|
+
variants: {
|
|
18
|
+
hideOnPrint: {
|
|
19
|
+
true: "print:hidden",
|
|
20
|
+
false: ""
|
|
21
|
+
},
|
|
22
|
+
allowOverflow: {
|
|
23
|
+
true: "overflow-visible",
|
|
24
|
+
false: "overflow-hidden"
|
|
25
|
+
},
|
|
26
|
+
subdued: {
|
|
27
|
+
true: "bg-surface-higher",
|
|
28
|
+
false: ""
|
|
29
|
+
},
|
|
30
|
+
alternate: {
|
|
31
|
+
true: "bg-surface-lower",
|
|
32
|
+
false: ""
|
|
33
|
+
},
|
|
34
|
+
isClickable: {
|
|
35
|
+
true: "cursor-pointer hover:ring hover:ring-form-focus hover:outline-form-border-focus",
|
|
36
|
+
false: ""
|
|
37
|
+
},
|
|
38
|
+
fullWidthOnMobile: {
|
|
39
|
+
true: "-left-4 w-full-plus-8",
|
|
40
|
+
false: ""
|
|
41
|
+
},
|
|
42
|
+
roundedOnMobile: {
|
|
43
|
+
true: "rounded-md",
|
|
44
|
+
false: "rounded-none @md:rounded-md"
|
|
45
|
+
},
|
|
46
|
+
outlined: {
|
|
47
|
+
true: "outline outline-tint-3",
|
|
48
|
+
false: ""
|
|
49
|
+
},
|
|
50
|
+
highlighted: {
|
|
51
|
+
true: "cursor-pointer ring ring-form-focus outline outline-form-border-focus",
|
|
52
|
+
false: ""
|
|
53
|
+
},
|
|
54
|
+
shadow: {
|
|
55
|
+
default: "shadow-card",
|
|
56
|
+
strong: "shadow-card-strong",
|
|
57
|
+
none: ""
|
|
58
|
+
},
|
|
59
|
+
embedded: {
|
|
60
|
+
true: "",
|
|
61
|
+
false: ""
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
compoundVariants: [
|
|
65
|
+
{
|
|
66
|
+
embedded: false,
|
|
67
|
+
fullWidthOnMobile: true,
|
|
68
|
+
className: "@md:left-0 @md:rounded-md @md:w-auto"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
embedded: true,
|
|
72
|
+
fullWidthOnMobile: true,
|
|
73
|
+
className: "@md-embed:left-0 @md-embed:w-auto @md-embed:rounded-md"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
subdued: false,
|
|
77
|
+
alternate: false,
|
|
78
|
+
highlighted: false,
|
|
79
|
+
className: "bg-surface-highest outline outline-tint-2 @md:outline-tint-1 dark:outline-hidden dark:border-t dark:border-tint-alt-2"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
subdued: false,
|
|
83
|
+
alternate: false,
|
|
84
|
+
highlighted: true,
|
|
85
|
+
className: "bg-surface-highest dark:border-t dark:border-tint-alt-2"
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
defaultVariants: {
|
|
89
|
+
isClickable: false,
|
|
90
|
+
subdued: false,
|
|
91
|
+
alternate: false,
|
|
92
|
+
outlined: false,
|
|
93
|
+
highlighted: false,
|
|
94
|
+
shadow: "default",
|
|
95
|
+
embedded: false
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
var headerStyles = tv({
|
|
99
|
+
base: "Litho-Card__Header p-2 pl-4 @md:p-3 @md:pl-5 flex flex-col justify-center items-stretch gap-1",
|
|
100
|
+
variants: {
|
|
101
|
+
removeHeaderBottomPadding: {
|
|
102
|
+
true: "pb-1 @md:pb-1 min-h-11 @md:min-h-12",
|
|
103
|
+
false: "min-h-12 @md:min-h-14"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
var bodyStyles = tv({
|
|
108
|
+
base: "Litho-Card__Body",
|
|
109
|
+
variants: {
|
|
110
|
+
padding: {
|
|
111
|
+
none: "p-0",
|
|
112
|
+
half: "pr-2 pb-4 pl-2 @md:pr-2.5 @md:pl-2.5 @md:pb-2.5",
|
|
113
|
+
full: "pr-4 pb-4 pl-4 @md:pr-5 @md:pl-5 @md:pb-5"
|
|
114
|
+
},
|
|
115
|
+
fullHeight: {
|
|
116
|
+
true: "h-full"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
compoundVariants: [
|
|
120
|
+
{
|
|
121
|
+
showHeader: false,
|
|
122
|
+
padding: "full",
|
|
123
|
+
className: "pt-4 @md:pt-5"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
showHeader: true,
|
|
127
|
+
padding: "full",
|
|
128
|
+
className: "pt-0 @md:pt-0"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
showHeader: false,
|
|
132
|
+
padding: "half",
|
|
133
|
+
className: "pt-2 @md:pt-2.5"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
showHeader: true,
|
|
137
|
+
padding: "half",
|
|
138
|
+
className: "pt-0 @md:pt-0"
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
});
|
|
142
|
+
/**
|
|
143
|
+
* Card component for creating styled containers with optional headers, actions, and children.
|
|
144
|
+
*
|
|
145
|
+
* @component
|
|
146
|
+
* @param {Object} props - Props for the Card component.
|
|
147
|
+
* @param {boolean} [props.allowOverflow=false] - Allows content to overflow the Card boundaries.
|
|
148
|
+
* @param {React.ReactNode} [props.children] - Child elements to render inside the Card.
|
|
149
|
+
* @param {boolean} [props.hideOnPrint] - Hides the Card when printing.
|
|
150
|
+
* @param {string|React.ReactNode} [props.title] - Title of the Card.
|
|
151
|
+
* @param {string} [props.titleVariant='headingMd'] - Typography variant for the Card title.
|
|
152
|
+
* @param {string} [props.description] - Description of the Card.
|
|
153
|
+
* @param {React.ElementType|Object} [props.icon] - Icon to render alongside the title.
|
|
154
|
+
* @param {React.ReactNode|import("./Tooltip").TooltipContentObject} [props.tooltip] - Tooltip content for the title.
|
|
155
|
+
* @param {string} [props.tooltipPreferredPosition='above'] - Preferred position for the tooltip.
|
|
156
|
+
* @param {boolean} [props.outlined=false] - Applies outlined styling to the Card.
|
|
157
|
+
* @param {string} [props.shadow='default'] - Applies a shadow to the Card. Can be 'default', or 'none'.
|
|
158
|
+
* @param {boolean} [props.highlighted=false] - Applies highlighted styling to the Card.
|
|
159
|
+
* @param {boolean} [props.subdued=false] - Applies subdued styling to the Card.
|
|
160
|
+
* @param {boolean} [props.alternate=false] - Applies alternate styling to the Card.
|
|
161
|
+
* @param {boolean} [props.padded=false] - Adds padding to the Card body.
|
|
162
|
+
* @param {boolean} [props.loading=false] - Shows a loading spinner in place of the title.
|
|
163
|
+
* @param {boolean} [props.paddedHalf=false] - Adds half padding to the Card body.
|
|
164
|
+
* @param {boolean} [props.removeHeaderBottomPadding=false] - Removes bottom padding from the header.
|
|
165
|
+
* @param {Function} [props.onClick] - Click handler for the Card, making it clickable.
|
|
166
|
+
* @param {Object} [props.emptyState={}] - Configures the empty state of the Card.
|
|
167
|
+
* @param {Object} [props.action] - Action button or configuration to render in the Card header.
|
|
168
|
+
* @param {string} [props.className] - Additional classes to apply to the Card.
|
|
169
|
+
* @param {string} [props.headerClassName] - Additional classes to apply to the Card header.
|
|
170
|
+
* @param {React.ReactNode} [props.accessory] - Accessory element to render in the header.
|
|
171
|
+
* @param {boolean} [props.fullWidthOnMobile=true] - Makes the Card full width on mobile.
|
|
172
|
+
* @param {boolean} [props.roundedOnMobile=false] - Makes the Card rounded on mobile.
|
|
173
|
+
* @returns {React.ReactElement} The rendered Card component.
|
|
174
|
+
*/ var Card = function(param) {
|
|
175
|
+
var _param_allowOverflow = param.allowOverflow, allowOverflow = _param_allowOverflow === void 0 ? false : _param_allowOverflow, _param_roundedOnMobile = param.roundedOnMobile, roundedOnMobile = _param_roundedOnMobile === void 0 ? false : _param_roundedOnMobile, children = param.children, hideOnPrint = param.hideOnPrint, title = param.title, _param_titleVariant = param.titleVariant, titleVariant = _param_titleVariant === void 0 ? "headingMd" : _param_titleVariant, description = param.description, icon = param.icon, tooltip = param.tooltip, _param_tooltipPreferredPosition = param.tooltipPreferredPosition, tooltipPreferredPosition = _param_tooltipPreferredPosition === void 0 ? "above" : _param_tooltipPreferredPosition, _param_outlined = param.outlined, outlined = _param_outlined === void 0 ? false : _param_outlined, _param_highlighted = param.highlighted, highlighted = _param_highlighted === void 0 ? false : _param_highlighted, _param_subdued = param.subdued, subdued = _param_subdued === void 0 ? false : _param_subdued, _param_alternate = param.alternate, alternate = _param_alternate === void 0 ? false : _param_alternate, _param_padded = param.padded, padded = _param_padded === void 0 ? false : _param_padded, _param_loading = param.loading, loading = _param_loading === void 0 ? false : _param_loading, _param_paddedHalf = param.paddedHalf, paddedHalf = _param_paddedHalf === void 0 ? false : _param_paddedHalf, _param_removeHeaderBottomPadding = param.removeHeaderBottomPadding, removeHeaderBottomPadding = _param_removeHeaderBottomPadding === void 0 ? false : _param_removeHeaderBottomPadding, onClick = param.onClick, _param_emptyState = param.emptyState, emptyState = _param_emptyState === void 0 ? {} : _param_emptyState, action = param.action, className = param.className, headerClassName = param.headerClassName, accessory = param.accessory, _param_fullHeightBody = param.fullHeightBody, fullHeightBody = _param_fullHeightBody === void 0 ? false : _param_fullHeightBody, _param_fullWidthOnMobile = param.fullWidthOnMobile, fullWidthOnMobile = _param_fullWidthOnMobile === void 0 ? true : _param_fullWidthOnMobile, _param_shadow = param.shadow, shadow = _param_shadow === void 0 ? "default" : _param_shadow;
|
|
176
|
+
var embedded = useContext(FrameContext).embedded;
|
|
177
|
+
var showHeader = !!(title || action);
|
|
178
|
+
var isClickable = !!onClick;
|
|
179
|
+
var classes = styles({
|
|
180
|
+
hideOnPrint: hideOnPrint,
|
|
181
|
+
subdued: subdued,
|
|
182
|
+
alternate: alternate,
|
|
183
|
+
allowOverflow: allowOverflow,
|
|
184
|
+
isClickable: isClickable,
|
|
185
|
+
fullWidthOnMobile: fullWidthOnMobile,
|
|
186
|
+
roundedOnMobile: roundedOnMobile,
|
|
187
|
+
outlined: outlined,
|
|
188
|
+
shadow: shadow,
|
|
189
|
+
highlighted: highlighted,
|
|
190
|
+
embedded: embedded
|
|
191
|
+
});
|
|
192
|
+
var headerClasses = headerStyles({
|
|
193
|
+
padded: padded,
|
|
194
|
+
removeHeaderBottomPadding: removeHeaderBottomPadding
|
|
195
|
+
});
|
|
196
|
+
var processCardChildren = function(children) {
|
|
197
|
+
if (!children) return null;
|
|
198
|
+
var firstSectionDetected = false;
|
|
199
|
+
function process(child) {
|
|
200
|
+
if (/*#__PURE__*/ React.isValidElement(child)) {
|
|
201
|
+
if (child.type.displayName === "Card.Section" && !firstSectionDetected) {
|
|
202
|
+
firstSectionDetected = true;
|
|
203
|
+
return /*#__PURE__*/ React.cloneElement(child, {
|
|
204
|
+
isFirst: true,
|
|
205
|
+
cardHasHeader: showHeader
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
if (child.props.children) {
|
|
209
|
+
var nestedChildren = React.Children.toArray(child.props.children).map(process);
|
|
210
|
+
return /*#__PURE__*/ React.cloneElement(child, {
|
|
211
|
+
children: nestedChildren
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return child;
|
|
216
|
+
}
|
|
217
|
+
return React.Children.toArray(children).map(process);
|
|
218
|
+
};
|
|
219
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
220
|
+
className: "".concat(classes).concat(className ? " ".concat(className) : ""),
|
|
221
|
+
onClick: isClickable ? onClick : undefined,
|
|
222
|
+
children: [
|
|
223
|
+
showHeader && /*#__PURE__*/ _jsxs("div", {
|
|
224
|
+
className: "".concat(headerClasses).concat(headerClassName ? " ".concat(headerClassName) : ""),
|
|
225
|
+
children: [
|
|
226
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
227
|
+
className: "w-full flex gap-2 justify-between items-center",
|
|
228
|
+
children: [
|
|
229
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
230
|
+
className: "Litho-Card__HeaderTitle flex items-center gap-2",
|
|
231
|
+
children: [
|
|
232
|
+
loading ? /*#__PURE__*/ _jsx(Spinner, {
|
|
233
|
+
size: "small"
|
|
234
|
+
}) : /*#__PURE__*/ _jsxs(_Fragment, {
|
|
235
|
+
children: [
|
|
236
|
+
icon && typeof icon === "function" && /*#__PURE__*/ _jsx(Icon, {
|
|
237
|
+
source: icon,
|
|
238
|
+
color: "subdued"
|
|
239
|
+
}),
|
|
240
|
+
icon && (typeof icon === "undefined" ? "undefined" : _type_of(icon)) === "object" && icon
|
|
241
|
+
]
|
|
242
|
+
}),
|
|
243
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
244
|
+
children: [
|
|
245
|
+
title && typeof title === "string" ? /*#__PURE__*/ _jsx(Text, {
|
|
246
|
+
variant: titleVariant,
|
|
247
|
+
children: title
|
|
248
|
+
}) : title,
|
|
249
|
+
description && /*#__PURE__*/ _jsx(Text, {
|
|
250
|
+
color: "subdued",
|
|
251
|
+
children: description
|
|
252
|
+
})
|
|
253
|
+
]
|
|
254
|
+
}),
|
|
255
|
+
tooltip && /*#__PURE__*/ _jsx(Tooltip, {
|
|
256
|
+
content: tooltip,
|
|
257
|
+
preferredPosition: tooltipPreferredPosition
|
|
258
|
+
})
|
|
259
|
+
]
|
|
260
|
+
}),
|
|
261
|
+
action && /*#__PURE__*/ _jsx("div", {
|
|
262
|
+
className: "Litho-Card__HeaderAction self-start",
|
|
263
|
+
children: action.content ? /*#__PURE__*/ _jsx(Button, {
|
|
264
|
+
link: true,
|
|
265
|
+
onClick: action.onAction || action.onClick,
|
|
266
|
+
primary: action.primary,
|
|
267
|
+
destructive: action.destructive,
|
|
268
|
+
icon: action.icon,
|
|
269
|
+
loading: action.loading,
|
|
270
|
+
disabled: action.disabled,
|
|
271
|
+
connectedDisclosure: action.connectedDisclosure,
|
|
272
|
+
children: action.content
|
|
273
|
+
}) : action
|
|
274
|
+
})
|
|
275
|
+
]
|
|
276
|
+
}),
|
|
277
|
+
accessory && /*#__PURE__*/ _jsx("div", {
|
|
278
|
+
className: "Litho-Card__HeaderAccessory pr-2",
|
|
279
|
+
children: accessory
|
|
280
|
+
})
|
|
281
|
+
]
|
|
282
|
+
}),
|
|
283
|
+
emptyState.showIf ? /*#__PURE__*/ _jsx("div", {
|
|
284
|
+
className: bodyStyles({
|
|
285
|
+
padding: "full",
|
|
286
|
+
showHeader: showHeader,
|
|
287
|
+
fullHeight: fullHeightBody
|
|
288
|
+
}),
|
|
289
|
+
children: /*#__PURE__*/ _jsx(Text, {
|
|
290
|
+
color: "subdued",
|
|
291
|
+
children: emptyState.text
|
|
292
|
+
})
|
|
293
|
+
}) : /*#__PURE__*/ _jsx("div", {
|
|
294
|
+
className: bodyStyles({
|
|
295
|
+
padding: padded ? "full" : paddedHalf ? "half" : "none",
|
|
296
|
+
showHeader: showHeader,
|
|
297
|
+
fullHeight: fullHeightBody
|
|
298
|
+
}),
|
|
299
|
+
children: processCardChildren(children)
|
|
300
|
+
})
|
|
301
|
+
]
|
|
302
|
+
});
|
|
303
|
+
};
|
|
304
|
+
var sectionStyles = tv({
|
|
305
|
+
base: "Litho-Card__Section flex flex-col",
|
|
306
|
+
variants: {
|
|
307
|
+
headerGap: {
|
|
308
|
+
1: "gap-1",
|
|
309
|
+
2: "gap-2",
|
|
310
|
+
3: "gap-3",
|
|
311
|
+
4: "gap-4"
|
|
312
|
+
},
|
|
313
|
+
borderBottom: {
|
|
314
|
+
true: "border-b border-edge-default last:border-b-0",
|
|
315
|
+
false: ""
|
|
316
|
+
},
|
|
317
|
+
borderTop: {
|
|
318
|
+
true: "border-t border-edge-default",
|
|
319
|
+
false: ""
|
|
320
|
+
},
|
|
321
|
+
subdued: {
|
|
322
|
+
true: "bg-surface-higher",
|
|
323
|
+
false: ""
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
var sectionHeaderStyles = tv({
|
|
328
|
+
base: "Litho-Card__SectionHeader pr-2 pt-2 pl-4 @md:pr-3 @md:pt-3 @md:pl-5 min-h-9 @md:min-h-10"
|
|
329
|
+
});
|
|
330
|
+
var sectionBodyStyles = tv({
|
|
331
|
+
base: "Litho-Card__SectionBody flex flex-col",
|
|
332
|
+
variants: {
|
|
333
|
+
gap: {
|
|
334
|
+
1: "gap-1",
|
|
335
|
+
2: "gap-2",
|
|
336
|
+
3: "gap-3",
|
|
337
|
+
4: "gap-4"
|
|
338
|
+
},
|
|
339
|
+
padding: {
|
|
340
|
+
none: "p-0",
|
|
341
|
+
half: "",
|
|
342
|
+
full: ""
|
|
343
|
+
},
|
|
344
|
+
isFirst: {
|
|
345
|
+
true: "",
|
|
346
|
+
false: ""
|
|
347
|
+
},
|
|
348
|
+
showHeader: {
|
|
349
|
+
true: "",
|
|
350
|
+
false: ""
|
|
351
|
+
},
|
|
352
|
+
cardHasHeader: {
|
|
353
|
+
true: "",
|
|
354
|
+
false: ""
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
compoundVariants: [
|
|
358
|
+
{
|
|
359
|
+
showHeader: true,
|
|
360
|
+
isFirst: true,
|
|
361
|
+
className: "pt-0!"
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
cardHasHeader: true,
|
|
365
|
+
isFirst: true,
|
|
366
|
+
className: "pt-0!"
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
showHeader: false,
|
|
370
|
+
padding: "full",
|
|
371
|
+
className: "p-4 @md:p-5"
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
showHeader: false,
|
|
375
|
+
padding: "half",
|
|
376
|
+
className: "p-2 @md:p-2.5"
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
showHeader: true,
|
|
380
|
+
padding: "full",
|
|
381
|
+
className: "p-4 pt-1 @md:p-5 @md:pt-1"
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
showHeader: true,
|
|
385
|
+
padding: "half",
|
|
386
|
+
className: "p-2 pt-1 @md:p-2.5 @md:pt-1"
|
|
387
|
+
}
|
|
388
|
+
]
|
|
389
|
+
});
|
|
390
|
+
/**
|
|
391
|
+
* Section component for dividing the Card into segments.
|
|
392
|
+
*
|
|
393
|
+
* @component
|
|
394
|
+
* @param {Object} props - Props for the Section component.
|
|
395
|
+
* @param {string|React.ReactNode} [props.title] - Title of the Section.
|
|
396
|
+
* @param {string} [props.titleVariant='headingSm'] - Typography variant for the Section title.
|
|
397
|
+
* @param {Object} [props.action] - Action button or configuration to render in the Section header.
|
|
398
|
+
* @param {React.ReactNode} [props.children] - Child elements to render inside the Section.
|
|
399
|
+
* @param {boolean} [props.padded=true] - Adds padding to the Section body.
|
|
400
|
+
* @param {boolean} [props.paddedHalf=false] - Adds half padding to the Section body.
|
|
401
|
+
* @param {boolean} [props.isFirst=false] - Indicates whether this is the first Section in the Card.
|
|
402
|
+
* @param {boolean} [props.cardHasHeader=false] - Indicates whether the Card has a header.
|
|
403
|
+
* @param {boolean} [props.borderBottom=true] - Adds a bottom border to the Section.
|
|
404
|
+
* @param {boolean} [props.borderTop=false] - Adds a top border to the Section.
|
|
405
|
+
* @param {boolean} [props.subdued=false] - Applies subdued styling to the Section.
|
|
406
|
+
* @param {string} [props.headerGap='0'] - Gap between items in the Section header.
|
|
407
|
+
* @param {string} [props.gap='0'] - Gap between items in the Section body.
|
|
408
|
+
* @param {React.ElementType|Object} [props.icon] - Icon to render alongside the title.
|
|
409
|
+
* @param {string} [props.tooltip] - Tooltip content for the title.
|
|
410
|
+
* @param {string} [props.description] - Description text for the Section.
|
|
411
|
+
* @param {React.ReactNode} [props.accessory] - Accessory element to render in the Section header.
|
|
412
|
+
* @param {Object} [props.emptyState={}] - Configures the empty state of the Section.
|
|
413
|
+
*
|
|
414
|
+
* @returns {React.ReactElement} The rendered Section component.
|
|
415
|
+
*/ Card.Section = function(param) {
|
|
416
|
+
var title = param.title, _param_titleVariant = param.titleVariant, titleVariant = _param_titleVariant === void 0 ? "headingSm" : _param_titleVariant, action = param.action, children = param.children, _param_padded = param.padded, padded = _param_padded === void 0 ? true : _param_padded, _param_paddedHalf = param.paddedHalf, paddedHalf = _param_paddedHalf === void 0 ? false : _param_paddedHalf, _param_isFirst = param.isFirst, isFirst = _param_isFirst === void 0 ? false : _param_isFirst, _param_cardHasHeader = param.cardHasHeader, cardHasHeader = _param_cardHasHeader === void 0 ? false : _param_cardHasHeader, _param_borderBottom = param.borderBottom, borderBottom = _param_borderBottom === void 0 ? true : _param_borderBottom, _param_borderTop = param.borderTop, borderTop = _param_borderTop === void 0 ? false : _param_borderTop, _param_subdued = param.subdued, subdued = _param_subdued === void 0 ? false : _param_subdued, _param_headerGap = param.headerGap, headerGap = _param_headerGap === void 0 ? "0" : _param_headerGap, _param_gap = param.gap, gap = _param_gap === void 0 ? "0" : _param_gap, icon = param.icon, tooltip = param.tooltip, description = param.description, accessory = param.accessory, _param_emptyState = param.emptyState, emptyState = _param_emptyState === void 0 ? {} : _param_emptyState, className = param.className;
|
|
417
|
+
var showHeader = !!(title || action);
|
|
418
|
+
var sectionClasses = sectionStyles({
|
|
419
|
+
borderBottom: borderBottom,
|
|
420
|
+
borderTop: borderTop,
|
|
421
|
+
subdued: subdued,
|
|
422
|
+
headerGap: headerGap
|
|
423
|
+
});
|
|
424
|
+
var sectionHeaderClasses = sectionHeaderStyles();
|
|
425
|
+
var sectionBodyClasses = sectionBodyStyles({
|
|
426
|
+
padding: paddedHalf ? "half" : padded ? "full" : "none",
|
|
427
|
+
showHeader: showHeader,
|
|
428
|
+
cardHasHeader: cardHasHeader,
|
|
429
|
+
isFirst: isFirst,
|
|
430
|
+
gap: gap
|
|
431
|
+
});
|
|
432
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
433
|
+
className: "".concat(sectionClasses).concat(className ? " ".concat(className) : ""),
|
|
434
|
+
children: [
|
|
435
|
+
showHeader && /*#__PURE__*/ _jsxs("div", {
|
|
436
|
+
className: sectionHeaderClasses,
|
|
437
|
+
children: [
|
|
438
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
439
|
+
className: "flex items-center justify-between gap-1",
|
|
440
|
+
children: [
|
|
441
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
442
|
+
className: "flex items-center gap-2 min-h-8",
|
|
443
|
+
children: [
|
|
444
|
+
icon && typeof icon === "function" && /*#__PURE__*/ _jsx(Icon, {
|
|
445
|
+
source: icon,
|
|
446
|
+
color: "subdued"
|
|
447
|
+
}),
|
|
448
|
+
icon && (typeof icon === "undefined" ? "undefined" : _type_of(icon)) === "object" && icon,
|
|
449
|
+
title && typeof title === "string" ? /*#__PURE__*/ _jsx(Text, {
|
|
450
|
+
variant: titleVariant,
|
|
451
|
+
children: title
|
|
452
|
+
}) : title,
|
|
453
|
+
tooltip && /*#__PURE__*/ _jsx(Tooltip, {
|
|
454
|
+
content: tooltip,
|
|
455
|
+
preferredPosition: "above"
|
|
456
|
+
})
|
|
457
|
+
]
|
|
458
|
+
}),
|
|
459
|
+
accessory && /*#__PURE__*/ _jsx("div", {
|
|
460
|
+
className: "Litho-CardSection__HeaderAccessory pr-2",
|
|
461
|
+
children: accessory
|
|
462
|
+
}),
|
|
463
|
+
action && /*#__PURE__*/ _jsx("div", {
|
|
464
|
+
className: "Litho-CardSection__HeaderAction",
|
|
465
|
+
children: action.content ? /*#__PURE__*/ _jsx(Button, {
|
|
466
|
+
link: true,
|
|
467
|
+
onClick: action.onAction,
|
|
468
|
+
primary: action.primary,
|
|
469
|
+
destructive: action.destructive,
|
|
470
|
+
icon: action.icon,
|
|
471
|
+
loading: action.loading,
|
|
472
|
+
disabled: action.disabled,
|
|
473
|
+
connectedDisclosure: action.connectedDisclosure,
|
|
474
|
+
children: action.content
|
|
475
|
+
}) : action
|
|
476
|
+
})
|
|
477
|
+
]
|
|
478
|
+
}),
|
|
479
|
+
description && /*#__PURE__*/ _jsx(Text, {
|
|
480
|
+
color: "subdued",
|
|
481
|
+
children: description
|
|
482
|
+
})
|
|
483
|
+
]
|
|
484
|
+
}),
|
|
485
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
486
|
+
className: sectionBodyClasses,
|
|
487
|
+
children: [
|
|
488
|
+
emptyState.showIf && /*#__PURE__*/ _jsx("div", {
|
|
489
|
+
className: paddedHalf ? "px-2 @md:px-2.5 pb-2" : !padded ? "px-4 @md:px-5 pb-4" : "",
|
|
490
|
+
children: /*#__PURE__*/ _jsx(Text, {
|
|
491
|
+
color: "subdued",
|
|
492
|
+
children: emptyState.text
|
|
493
|
+
})
|
|
494
|
+
}),
|
|
495
|
+
children
|
|
496
|
+
]
|
|
497
|
+
})
|
|
498
|
+
]
|
|
499
|
+
});
|
|
500
|
+
};
|
|
501
|
+
Card.Section.displayName = "Card.Section";
|
|
502
|
+
var clickableRowStyles = tv({
|
|
503
|
+
base: "Litho-Card__ClickableRow flex py-1.5 px-2.5 cursor-pointer rounded-md hover:bg-tint-2 active:bg-tint-3",
|
|
504
|
+
variants: {
|
|
505
|
+
disabled: {
|
|
506
|
+
true: "opacity-50 cursor-not-allowed pointer-events-none"
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
/**
|
|
511
|
+
* ClickableRow component for creating clickable rows inside the Card.
|
|
512
|
+
*
|
|
513
|
+
* @component
|
|
514
|
+
* @param {Object} props - Props for the ClickableRow component.
|
|
515
|
+
* @param {React.ReactNode} [props.children] - Child elements to render inside the row.
|
|
516
|
+
* @param {Function} [props.onClick] - Click handler for the row.
|
|
517
|
+
* @param {string} [props.id] - ID to apply to the row element.
|
|
518
|
+
* @param {string} [props.url] - URL to open when the row is clicked.
|
|
519
|
+
* @param {boolean} [props.disabled=false] - Disables interaction with the row.
|
|
520
|
+
*
|
|
521
|
+
* @returns {React.ReactElement} The rendered ClickableRow component.
|
|
522
|
+
*/ Card.ClickableRow = function(param) {
|
|
523
|
+
var children = param.children, onClick = param.onClick, id = param.id, url = param.url, _param_disabled = param.disabled, disabled = _param_disabled === void 0 ? false : _param_disabled, className = param.className;
|
|
524
|
+
var classes = clickableRowStyles({
|
|
525
|
+
disabled: disabled
|
|
526
|
+
});
|
|
527
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
528
|
+
id: id,
|
|
529
|
+
onClick: url ? function() {
|
|
530
|
+
return window.open(url, "_blank");
|
|
531
|
+
} : onClick,
|
|
532
|
+
className: "".concat(classes).concat(className ? " ".concat(className) : ""),
|
|
533
|
+
children: children
|
|
534
|
+
});
|
|
535
|
+
};
|
|
536
|
+
Card.ClickableRow.displayName = "Card.ClickableRow";
|
|
537
|
+
export default Card;
|