@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Mantle RevOps Inc. and affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Litho
|
|
2
|
+
|
|
3
|
+
A modern React component library for building Mantle extensions and web applications. Litho provides a comprehensive set of accessible, themeable, and composable UI components, designed for rapid development and seamless integration with Tailwind CSS and Shopify Polaris icons.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @heymantle/litho
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> **Note:** `tailwindcss`, `react`, and `react-dom` (v18+) are required as peer dependencies.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
1. **Import the CSS** (required for correct styling):
|
|
16
|
+
|
|
17
|
+
```css
|
|
18
|
+
// index.css paths here may differ depending on your project structure
|
|
19
|
+
@source "./node_modules/@heymantle/litho";
|
|
20
|
+
@import "./node_modules/@heymantle/litho/index.css";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
2. **Wrap your app with `AppProvider`** (required for `Frame` and/or `Form` usage):
|
|
24
|
+
|
|
25
|
+
```jsx
|
|
26
|
+
import { AppProvider, Page, Button } from "litho";
|
|
27
|
+
|
|
28
|
+
function App() {
|
|
29
|
+
return (
|
|
30
|
+
<AppProvider darkModeAvailable darkModeStorageKey="my-app-dark-mode">
|
|
31
|
+
<Page title="Welcome to Litho">
|
|
32
|
+
<Button primary onClick={() => alert("Hello!")}>
|
|
33
|
+
Click me
|
|
34
|
+
</Button>
|
|
35
|
+
</Page>
|
|
36
|
+
</AppProvider>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
3. **Use any component**:
|
|
42
|
+
|
|
43
|
+
```jsx
|
|
44
|
+
import { Banner, Card, ResourceList } from 'litho';
|
|
45
|
+
|
|
46
|
+
<Banner status="success" title="Success!">
|
|
47
|
+
Your operation was successful.
|
|
48
|
+
</Banner>
|
|
49
|
+
|
|
50
|
+
<Card>
|
|
51
|
+
<ResourceList
|
|
52
|
+
items={[{ id: 1, name: 'Item 1' }]}
|
|
53
|
+
renderItem={item => <div key={item.id}>{item.name}</div>}
|
|
54
|
+
/>
|
|
55
|
+
</Card>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Components
|
|
59
|
+
|
|
60
|
+
Litho exports a wide range of components, including:
|
|
61
|
+
|
|
62
|
+
- **Layout:** `Page`, `Frame`, `Layout`, `Card`, `Grid`, `HorizontalStack`, `VerticalStack`
|
|
63
|
+
- **Forms:** `TextField`, `Select`, `Checkbox`, `RadioButton`, `RangeSlider`, `ChoiceList`, `DatePicker`, `ColorField`
|
|
64
|
+
- **Navigation:** `Navigation`, `Tabs`, `Pagination`, `TopBar`, `Pane`
|
|
65
|
+
- **Feedback:** `Banner`, `Tip`, `InlineError`, `EmptyState`, `Loading`, `SkeletonText`, `FooterHelp`
|
|
66
|
+
- **Actions:** `Button`, `ButtonGroup`, `ActionList`, `Popover`, `Modal`, `ContextualSaveBar`
|
|
67
|
+
- **Data Display:** `Table`, `ResourceList`, `List`, `Badge`, `Tag`, `Thumbnail`, `Image`, `Tooltip`
|
|
68
|
+
- **Utilities:** `useIndexResourceState`, `useTableScrollState`, and more
|
|
69
|
+
|
|
70
|
+
See the [source code](./components/) for full API documentation and JSDoc usage examples for each component.
|
|
71
|
+
|
|
72
|
+
## Theming & Customization
|
|
73
|
+
|
|
74
|
+
- Litho is designed to work with Tailwind CSS. You can customize themes and extend styles using your Tailwind config.
|
|
75
|
+
|
|
76
|
+
```css
|
|
77
|
+
// index.css paths here may differ depending on your project structure
|
|
78
|
+
@source "./node_modules/@heymantle/litho";
|
|
79
|
+
@import "./node_modules/@heymantle/litho/index.css";
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Peer Dependencies
|
|
83
|
+
|
|
84
|
+
- `react` >= 18
|
|
85
|
+
- `react-dom` >= 18
|
|
86
|
+
- `tailwindcss` >= 4
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
ISC
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return _default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _jsxruntime = require("react/jsx-runtime");
|
|
13
|
+
var _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
14
|
+
var _tailwindvariants = require("tailwind-variants");
|
|
15
|
+
var _index = require("../index");
|
|
16
|
+
var _polarisicons = require("@shopify/polaris-icons");
|
|
17
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
18
|
+
if (typeof WeakMap !== "function") return null;
|
|
19
|
+
var cacheBabelInterop = new WeakMap();
|
|
20
|
+
var cacheNodeInterop = new WeakMap();
|
|
21
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
22
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
23
|
+
})(nodeInterop);
|
|
24
|
+
}
|
|
25
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
26
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
27
|
+
return obj;
|
|
28
|
+
}
|
|
29
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
30
|
+
return {
|
|
31
|
+
default: obj
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
35
|
+
if (cache && cache.has(obj)) {
|
|
36
|
+
return cache.get(obj);
|
|
37
|
+
}
|
|
38
|
+
var newObj = {
|
|
39
|
+
__proto__: null
|
|
40
|
+
};
|
|
41
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
42
|
+
for(var key in obj){
|
|
43
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
44
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
45
|
+
if (desc && (desc.get || desc.set)) {
|
|
46
|
+
Object.defineProperty(newObj, key, desc);
|
|
47
|
+
} else {
|
|
48
|
+
newObj[key] = obj[key];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
newObj.default = obj;
|
|
53
|
+
if (cache) {
|
|
54
|
+
cache.set(obj, newObj);
|
|
55
|
+
}
|
|
56
|
+
return newObj;
|
|
57
|
+
}
|
|
58
|
+
var styles = (0, _tailwindvariants.tv)({
|
|
59
|
+
base: "Litho-ActionList",
|
|
60
|
+
variants: {
|
|
61
|
+
fullWidth: {
|
|
62
|
+
true: "w-full",
|
|
63
|
+
false: ""
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
defaultVariants: {
|
|
67
|
+
fullWidth: false
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
var sectionStyles = (0, _tailwindvariants.tv)({
|
|
71
|
+
base: "Litho-ActionList__Section border-b border-edge-default last:border-b-0",
|
|
72
|
+
variants: {
|
|
73
|
+
padded: {
|
|
74
|
+
true: "p-2",
|
|
75
|
+
false: ""
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
var itemStyles = (0, _tailwindvariants.tv)({
|
|
80
|
+
base: "Litho-ActionList__Item flex items-center gap-2 py-1.5 px-2.5 rounded-md truncate focus:outline-none focus:ring-2 focus:ring-inset focus:ring-transparent focus:ring-offset-2 focus:ring-offset-form-focus-active",
|
|
81
|
+
variants: {
|
|
82
|
+
disabled: {
|
|
83
|
+
true: "cursor-not-allowed hover:bg-transparent",
|
|
84
|
+
false: "cursor-pointer"
|
|
85
|
+
},
|
|
86
|
+
destructive: {
|
|
87
|
+
true: "hover:bg-form-bg-error-low",
|
|
88
|
+
false: "hover:bg-tint-2 active:bg-tint-3"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
defaultVariants: {
|
|
92
|
+
disabled: false,
|
|
93
|
+
destructive: false
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* ActionList component renders a list of actionable items with optional sections.
|
|
98
|
+
* Supports keyboard navigation and action triggers on item selection.
|
|
99
|
+
*
|
|
100
|
+
* @component
|
|
101
|
+
* @param {Object} props - Component properties.
|
|
102
|
+
* @param {Array} [props.sections] - Sections containing items for the action list.
|
|
103
|
+
* Each section has a title and a list of items.
|
|
104
|
+
* @param {Array} [props.items] - List of items to render in the action list when no sections are provided.
|
|
105
|
+
* @param {string} [props.iconColor="subdued"] - Default color for icons in the action items.
|
|
106
|
+
* @param {function} [props.onActionAnyItem] - Callback function invoked whenever any action item is selected.
|
|
107
|
+
* @param {boolean} [props.fullWidth=false] - Whether to apply full width styling to the action list.
|
|
108
|
+
* @param {boolean} [props.showSecondaryAction=false] - Whether to show the secondary action icon.
|
|
109
|
+
* @example
|
|
110
|
+
* const items = [{ content: 'Item 1', onAction: () => {} }];
|
|
111
|
+
* <ActionList items={items} />
|
|
112
|
+
*
|
|
113
|
+
* @returns {JSX.Element} The rendered ActionList component.
|
|
114
|
+
*/ function ActionList() {
|
|
115
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
116
|
+
var sections = props.sections, _props_padded = props.padded, padded = _props_padded === void 0 ? true : _props_padded, tmp = props.items, initialItems = tmp === void 0 ? [] : tmp, tmp1 = props.iconColor, _iconColor = tmp1 === void 0 ? "subdued" : tmp1, onActionAnyItem = props.onActionAnyItem, className = props.className, _props_fullWidth = props.fullWidth, fullWidth = _props_fullWidth === void 0 ? false : _props_fullWidth;
|
|
117
|
+
var sectionTitleAsKeys = true;
|
|
118
|
+
var items = initialItems || (sections ? sections.flatMap(function(section) {
|
|
119
|
+
return section.items;
|
|
120
|
+
}) : []);
|
|
121
|
+
var actionListRef = (0, _react.useRef)(null);
|
|
122
|
+
var itemRefs = (0, _react.useRef)([]);
|
|
123
|
+
var handleKeyDown = function(e) {
|
|
124
|
+
if (!actionListRef.current.contains(e.target)) return;
|
|
125
|
+
var enabledItems = itemRefs.current.filter(function(ref) {
|
|
126
|
+
return ref && ref.getAttribute("tabIndex") !== "-1";
|
|
127
|
+
});
|
|
128
|
+
var focusedIndex = enabledItems.findIndex(function(ref) {
|
|
129
|
+
return ref === document.activeElement;
|
|
130
|
+
});
|
|
131
|
+
if (e.key === "ArrowDown") {
|
|
132
|
+
var nextIndex = (focusedIndex + 1) % enabledItems.length;
|
|
133
|
+
enabledItems[nextIndex].focus();
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
} else if (e.key === "ArrowUp") {
|
|
136
|
+
var prevIndex = (focusedIndex - 1 + enabledItems.length) % enabledItems.length;
|
|
137
|
+
enabledItems[prevIndex].focus();
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
} else if (e.key === "Enter") {
|
|
140
|
+
var focusedItem = enabledItems[focusedIndex];
|
|
141
|
+
if (focusedItem) {
|
|
142
|
+
focusedItem.click();
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
(0, _react.useEffect)(function() {
|
|
148
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
149
|
+
return function() {
|
|
150
|
+
window.removeEventListener("keydown", handleKeyDown);
|
|
151
|
+
};
|
|
152
|
+
}, []);
|
|
153
|
+
var classes = styles({
|
|
154
|
+
fullWidth: fullWidth
|
|
155
|
+
});
|
|
156
|
+
var sectionClasses = sectionStyles({
|
|
157
|
+
padded: padded
|
|
158
|
+
});
|
|
159
|
+
var isSectioned = sections && sections.length > 0;
|
|
160
|
+
if (isSectioned) {
|
|
161
|
+
sectionTitleAsKeys = sections.every(function(section) {
|
|
162
|
+
return Object.prototype.hasOwnProperty.call(section, "title");
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
var ActionListItem = function(param) {
|
|
166
|
+
var item = param.item, index = param.index;
|
|
167
|
+
var content = item.content, disabled = item.disabled, destructive = item.destructive, icon = item.icon, onAction = item.onAction, prefix = item.prefix, imageUrl = item.imageUrl, url = item.url, secondaryAction = item.secondaryAction;
|
|
168
|
+
var iconColor = disabled ? "disabled" : destructive ? "critical" : _iconColor;
|
|
169
|
+
var textColor = disabled ? "disabled" : destructive ? "critical" : "default";
|
|
170
|
+
var itemClasses = itemStyles({
|
|
171
|
+
disabled: disabled,
|
|
172
|
+
destructive: destructive
|
|
173
|
+
});
|
|
174
|
+
var secondaryActionContent = secondaryAction ? /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
175
|
+
className: "Litho-ActionList__Item__SecondaryAction rounded-sm px-1 hover:bg-tint-2 active:bg-tint-3",
|
|
176
|
+
onClick: function(e) {
|
|
177
|
+
e.stopPropagation();
|
|
178
|
+
secondaryAction.onAction();
|
|
179
|
+
},
|
|
180
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Icon, {
|
|
181
|
+
source: (secondaryAction === null || secondaryAction === void 0 ? void 0 : secondaryAction.icon) || _polarisicons.MobileHorizontalDotsMajor,
|
|
182
|
+
color: "subdued"
|
|
183
|
+
})
|
|
184
|
+
}) : null;
|
|
185
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("a", {
|
|
186
|
+
ref: function(el) {
|
|
187
|
+
return itemRefs.current[index] = el;
|
|
188
|
+
},
|
|
189
|
+
className: itemClasses,
|
|
190
|
+
tabIndex: disabled ? -1 : 0,
|
|
191
|
+
onClick: function(e) {
|
|
192
|
+
e.stopPropagation();
|
|
193
|
+
if (disabled) return;
|
|
194
|
+
if (onAction) onAction();
|
|
195
|
+
if (url) window.open(url, "_blank");
|
|
196
|
+
if (onActionAnyItem) onActionAnyItem();
|
|
197
|
+
},
|
|
198
|
+
children: [
|
|
199
|
+
prefix ? /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
200
|
+
className: "Litho-ActionList__Item__Prefix w-5 h-5 flex items-center justify-center shrink-0",
|
|
201
|
+
children: prefix
|
|
202
|
+
}) : icon ? /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
203
|
+
className: "Litho-ActionList__Item__Icon shrink-0",
|
|
204
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Icon, {
|
|
205
|
+
source: icon,
|
|
206
|
+
color: iconColor,
|
|
207
|
+
stroke: item === null || item === void 0 ? void 0 : item.iconStroke,
|
|
208
|
+
display: item === null || item === void 0 ? void 0 : item.iconDisplay
|
|
209
|
+
})
|
|
210
|
+
}) : imageUrl ? /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
211
|
+
className: "Litho-ActionList__Item__Image shrink-0",
|
|
212
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)("img", {
|
|
213
|
+
src: imageUrl,
|
|
214
|
+
alt: content,
|
|
215
|
+
className: "w-5 h-5 rounded-sm"
|
|
216
|
+
})
|
|
217
|
+
}) : null,
|
|
218
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
219
|
+
className: "flex-1",
|
|
220
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Text, {
|
|
221
|
+
color: textColor,
|
|
222
|
+
truncate: true,
|
|
223
|
+
children: content
|
|
224
|
+
})
|
|
225
|
+
}),
|
|
226
|
+
(secondaryAction === null || secondaryAction === void 0 ? void 0 : secondaryAction.tooltip) ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Tooltip, {
|
|
227
|
+
content: secondaryAction.tooltip,
|
|
228
|
+
children: secondaryActionContent
|
|
229
|
+
}) : secondaryActionContent
|
|
230
|
+
]
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
234
|
+
ref: actionListRef,
|
|
235
|
+
className: "".concat(classes).concat(className ? " ".concat(className) : ""),
|
|
236
|
+
tabIndex: -1,
|
|
237
|
+
children: isSectioned ? sections.map(function(section, sectionIndex) {
|
|
238
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
239
|
+
className: sectionClasses,
|
|
240
|
+
children: [
|
|
241
|
+
section.title && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
242
|
+
className: "Litho-ActionList__SectionTitle px-2 py-1",
|
|
243
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Text, {
|
|
244
|
+
variant: "headingSm",
|
|
245
|
+
children: section.title
|
|
246
|
+
})
|
|
247
|
+
}),
|
|
248
|
+
section.items.map(function(item, itemIndex) {
|
|
249
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(ActionListItem, {
|
|
250
|
+
item: item,
|
|
251
|
+
index: sectionIndex * section.items.length + itemIndex
|
|
252
|
+
}, "item-".concat(sectionIndex, "-").concat(itemIndex));
|
|
253
|
+
})
|
|
254
|
+
]
|
|
255
|
+
}, sectionTitleAsKeys ? section.title : sectionIndex);
|
|
256
|
+
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
257
|
+
className: sectionClasses,
|
|
258
|
+
children: items.map(function(item, itemIndex) {
|
|
259
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(ActionListItem, {
|
|
260
|
+
item: item,
|
|
261
|
+
index: itemIndex
|
|
262
|
+
}, "item-".concat(itemIndex));
|
|
263
|
+
})
|
|
264
|
+
})
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
var _default = ActionList;
|
|
@@ -0,0 +1,73 @@
|
|
|
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 styles = (0, _tailwindvariants.tv)({
|
|
15
|
+
base: "Litho-AnnouncementBar text-center p-2 min-h-10 flex items-center justify-center bg-brand",
|
|
16
|
+
variants: {
|
|
17
|
+
fixed: {
|
|
18
|
+
true: "fixed top-0 left-0 right-0"
|
|
19
|
+
},
|
|
20
|
+
interactive: {
|
|
21
|
+
true: "cursor-pointer hover:bg-brand-low active:bg-brand-lower",
|
|
22
|
+
false: ""
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
var iconContainerStyles = (0, _tailwindvariants.tv)({
|
|
27
|
+
base: "Litho-AnnouncementBar__IconContainer",
|
|
28
|
+
variants: {
|
|
29
|
+
animateIcon: {
|
|
30
|
+
bounce: "animate-bounce"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* AnnouncementBar Component
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} props - Component properties.
|
|
38
|
+
* @param {Function} [props.onClick] - Click handler function.
|
|
39
|
+
* @param {string} props.content - Text content to be displayed.
|
|
40
|
+
* @param {string} [props.icon] - Icon source name.
|
|
41
|
+
* @param {"bounce"} [props.animateIcon] - Animation type for the icon.
|
|
42
|
+
*
|
|
43
|
+
* @returns {JSX.Element} AnnouncementBar component.
|
|
44
|
+
*/ function AnnouncementBar() {
|
|
45
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
46
|
+
var onClick = props.onClick, content = props.content, icon = props.icon, animateIcon = props.animateIcon, _props_fixed = props.fixed, fixed = _props_fixed === void 0 ? false : _props_fixed;
|
|
47
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
48
|
+
className: styles({
|
|
49
|
+
fixed: fixed,
|
|
50
|
+
interactive: !!onClick
|
|
51
|
+
}),
|
|
52
|
+
onClick: onClick,
|
|
53
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
54
|
+
className: "flex items-center justify-center gap-4",
|
|
55
|
+
children: [
|
|
56
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Text, {
|
|
57
|
+
fontWeight: "medium",
|
|
58
|
+
className: "text-md",
|
|
59
|
+
children: content
|
|
60
|
+
}),
|
|
61
|
+
icon && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
62
|
+
className: iconContainerStyles({
|
|
63
|
+
animateIcon: animateIcon
|
|
64
|
+
}),
|
|
65
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_index.Icon, {
|
|
66
|
+
source: icon
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
var _default = AnnouncementBar;
|