@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.
Files changed (140) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +90 -0
  3. package/dist/cjs/components/ActionList.js +267 -0
  4. package/dist/cjs/components/AnnouncementBar.js +73 -0
  5. package/dist/cjs/components/AppProvider.js +245 -0
  6. package/dist/cjs/components/Autocomplete.js +351 -0
  7. package/dist/cjs/components/Badge.js +234 -0
  8. package/dist/cjs/components/Banner.js +264 -0
  9. package/dist/cjs/components/Box.js +247 -0
  10. package/dist/cjs/components/Button.js +1018 -0
  11. package/dist/cjs/components/ButtonGroup.js +196 -0
  12. package/dist/cjs/components/Card.js +593 -0
  13. package/dist/cjs/components/Checkbox.js +175 -0
  14. package/dist/cjs/components/ChoiceList.js +160 -0
  15. package/dist/cjs/components/Collapsible.js +42 -0
  16. package/dist/cjs/components/ColorField.js +159 -0
  17. package/dist/cjs/components/ContextualSaveBar.js +53 -0
  18. package/dist/cjs/components/DatePicker.js +547 -0
  19. package/dist/cjs/components/Divider.js +50 -0
  20. package/dist/cjs/components/DropZone.js +547 -0
  21. package/dist/cjs/components/EmptyState.js +111 -0
  22. package/dist/cjs/components/Filters.js +874 -0
  23. package/dist/cjs/components/FooterHelp.js +48 -0
  24. package/dist/cjs/components/Form.js +44 -0
  25. package/dist/cjs/components/Frame.js +386 -0
  26. package/dist/cjs/components/FrameSaveBar.js +239 -0
  27. package/dist/cjs/components/Grid.js +151 -0
  28. package/dist/cjs/components/HorizontalStack.js +180 -0
  29. package/dist/cjs/components/Icon.js +346 -0
  30. package/dist/cjs/components/Image.js +191 -0
  31. package/dist/cjs/components/InlineError.js +57 -0
  32. package/dist/cjs/components/Label.js +78 -0
  33. package/dist/cjs/components/Layout.js +228 -0
  34. package/dist/cjs/components/LayoutSection.js +133 -0
  35. package/dist/cjs/components/Link.js +128 -0
  36. package/dist/cjs/components/List.js +69 -0
  37. package/dist/cjs/components/Listbox.js +211 -0
  38. package/dist/cjs/components/Loading.js +103 -0
  39. package/dist/cjs/components/Modal.js +449 -0
  40. package/dist/cjs/components/Navigation.js +331 -0
  41. package/dist/cjs/components/Page.js +529 -0
  42. package/dist/cjs/components/Pagination.js +109 -0
  43. package/dist/cjs/components/Pane.js +128 -0
  44. package/dist/cjs/components/Popover.js +365 -0
  45. package/dist/cjs/components/PopoverManager.js +34 -0
  46. package/dist/cjs/components/ProgressBar.js +124 -0
  47. package/dist/cjs/components/RadioButton.js +172 -0
  48. package/dist/cjs/components/RadioButtonCard.js +193 -0
  49. package/dist/cjs/components/RangeSlider.js +235 -0
  50. package/dist/cjs/components/ResourceList.js +105 -0
  51. package/dist/cjs/components/Select.js +300 -0
  52. package/dist/cjs/components/SkeletonText.js +130 -0
  53. package/dist/cjs/components/Spinner.js +72 -0
  54. package/dist/cjs/components/Table.js +1184 -0
  55. package/dist/cjs/components/Tabs.js +421 -0
  56. package/dist/cjs/components/Tag.js +165 -0
  57. package/dist/cjs/components/Text.js +274 -0
  58. package/dist/cjs/components/TextField.js +584 -0
  59. package/dist/cjs/components/Thumbnail.js +73 -0
  60. package/dist/cjs/components/TimePicker.js +23 -0
  61. package/dist/cjs/components/Tip.js +220 -0
  62. package/dist/cjs/components/Tooltip.js +431 -0
  63. package/dist/cjs/components/TopBar.js +210 -0
  64. package/dist/cjs/components/VerticalStack.js +161 -0
  65. package/dist/cjs/index.js +308 -0
  66. package/dist/cjs/styles/Table.js +591 -0
  67. package/dist/cjs/utilities/dates.js +339 -0
  68. package/dist/cjs/utilities/useIndexResourceState.js +175 -0
  69. package/dist/cjs/utilities/useMounted.js +67 -0
  70. package/dist/cjs/utilities/useTableScrollState.js +142 -0
  71. package/dist/esm/components/ActionList.js +216 -0
  72. package/dist/esm/components/AnnouncementBar.js +63 -0
  73. package/dist/esm/components/AppProvider.js +185 -0
  74. package/dist/esm/components/Autocomplete.js +300 -0
  75. package/dist/esm/components/Badge.js +225 -0
  76. package/dist/esm/components/Banner.js +254 -0
  77. package/dist/esm/components/Box.js +238 -0
  78. package/dist/esm/components/Button.js +967 -0
  79. package/dist/esm/components/ButtonGroup.js +137 -0
  80. package/dist/esm/components/Card.js +537 -0
  81. package/dist/esm/components/Checkbox.js +165 -0
  82. package/dist/esm/components/ChoiceList.js +145 -0
  83. package/dist/esm/components/Collapsible.js +32 -0
  84. package/dist/esm/components/ColorField.js +149 -0
  85. package/dist/esm/components/ContextualSaveBar.js +43 -0
  86. package/dist/esm/components/DatePicker.js +532 -0
  87. package/dist/esm/components/Divider.js +41 -0
  88. package/dist/esm/components/DropZone.js +537 -0
  89. package/dist/esm/components/EmptyState.js +101 -0
  90. package/dist/esm/components/Filters.js +823 -0
  91. package/dist/esm/components/FooterHelp.js +38 -0
  92. package/dist/esm/components/Form.js +35 -0
  93. package/dist/esm/components/Frame.js +376 -0
  94. package/dist/esm/components/FrameSaveBar.js +229 -0
  95. package/dist/esm/components/Grid.js +142 -0
  96. package/dist/esm/components/HorizontalStack.js +171 -0
  97. package/dist/esm/components/Icon.js +296 -0
  98. package/dist/esm/components/Image.js +141 -0
  99. package/dist/esm/components/InlineError.js +43 -0
  100. package/dist/esm/components/Label.js +63 -0
  101. package/dist/esm/components/Layout.js +164 -0
  102. package/dist/esm/components/LayoutSection.js +82 -0
  103. package/dist/esm/components/Link.js +119 -0
  104. package/dist/esm/components/List.js +61 -0
  105. package/dist/esm/components/Listbox.js +201 -0
  106. package/dist/esm/components/Loading.js +93 -0
  107. package/dist/esm/components/Modal.js +390 -0
  108. package/dist/esm/components/Navigation.js +321 -0
  109. package/dist/esm/components/Page.js +473 -0
  110. package/dist/esm/components/Pagination.js +99 -0
  111. package/dist/esm/components/Pane.js +118 -0
  112. package/dist/esm/components/Popover.js +350 -0
  113. package/dist/esm/components/PopoverManager.js +24 -0
  114. package/dist/esm/components/ProgressBar.js +114 -0
  115. package/dist/esm/components/RadioButton.js +157 -0
  116. package/dist/esm/components/RadioButtonCard.js +178 -0
  117. package/dist/esm/components/RangeSlider.js +225 -0
  118. package/dist/esm/components/ResourceList.js +95 -0
  119. package/dist/esm/components/Select.js +285 -0
  120. package/dist/esm/components/SkeletonText.js +120 -0
  121. package/dist/esm/components/Spinner.js +63 -0
  122. package/dist/esm/components/Table.js +1129 -0
  123. package/dist/esm/components/Tabs.js +366 -0
  124. package/dist/esm/components/Tag.js +151 -0
  125. package/dist/esm/components/Text.js +265 -0
  126. package/dist/esm/components/TextField.js +533 -0
  127. package/dist/esm/components/Thumbnail.js +63 -0
  128. package/dist/esm/components/TimePicker.js +13 -0
  129. package/dist/esm/components/Tip.js +169 -0
  130. package/dist/esm/components/Tooltip.js +380 -0
  131. package/dist/esm/components/TopBar.js +200 -0
  132. package/dist/esm/components/VerticalStack.js +152 -0
  133. package/dist/esm/index.js +61 -0
  134. package/dist/esm/styles/Table.js +581 -0
  135. package/dist/esm/utilities/dates.js +289 -0
  136. package/dist/esm/utilities/useIndexResourceState.js +158 -0
  137. package/dist/esm/utilities/useMounted.js +57 -0
  138. package/dist/esm/utilities/useTableScrollState.js +132 -0
  139. package/index.css +1137 -0
  140. package/package.json +53 -0
@@ -0,0 +1,142 @@
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 _react = require("react");
12
+ var _usedebounce = require("use-debounce");
13
+ /**
14
+ * A custom hook to manage table scroll state and column widths.
15
+ *
16
+ * @param {Object} params - Parameters for the hook.
17
+ * @param {boolean} params.loading - Indicates if data is loading.
18
+ * @param {React.RefObject<HTMLDivElement>} params.containerRef - Reference to the container element.
19
+ * @param {React.RefObject<HTMLDivElement>} params.tableContainerRef - Reference to the table container element.
20
+ * @param {Function} params.setCanScrollLeft - Function to set the scrollable state on the left.
21
+ * @param {Function} params.setCanScrollRight - Function to set the scrollable state on the right.
22
+ * @param {Function} params.setColumnWidths - Function to set the column widths.
23
+ * @param {Function} params.setRowHeights - Function to set the row heights.
24
+ * @param {Function} params.setIsHeaderSticky - Function to set the sticky state of the header.
25
+ * @param {boolean} params.insideModal - Indicates if the table exists in a modal.
26
+ * @param {any} params.children - Table children elements (triggers recalculations).
27
+ */ var useTableScrollState = function(param) {
28
+ var loading = param.loading, idRef = param.idRef, containerRef = param.containerRef, tableContainerRef = param.tableContainerRef, setCanScrollLeft = param.setCanScrollLeft, setCanScrollRight = param.setCanScrollRight, setColumnWidths = param.setColumnWidths, setRowHeights = param.setRowHeights, setIsHeaderSticky = param.setIsHeaderSticky, stickyHeader = param.stickyHeader, children = param.children, showHoverStates = param.showHoverStates, insideModal = param.insideModal, itemCount = param.itemCount;
29
+ var columnWidthsRef = (0, _react.useRef)([]);
30
+ var rowHeightsRef = (0, _react.useRef)([]);
31
+ var styleSheetRef = (0, _react.useRef)(null);
32
+ var root = document.documentElement;
33
+ var cssValue = getComputedStyle(root).getPropertyValue('--litho-table-header-sticky-at').trim();
34
+ var becomeStickyAt = parseInt(cssValue || 56, 10);
35
+ (0, _react.useEffect)(function() {
36
+ if (!styleSheetRef.current) {
37
+ var styleElement = document.createElement("style");
38
+ document.head.appendChild(styleElement);
39
+ styleSheetRef.current = styleElement.sheet;
40
+ }
41
+ }, []);
42
+ (0, _react.useEffect)(function() {
43
+ if (!tableContainerRef.current || !showHoverStates) return;
44
+ var container = containerRef.current;
45
+ var rows = container.querySelectorAll("tr[data-position]");
46
+ var handleMouseEnter = function(e) {
47
+ var interactive = e.currentTarget.getAttribute("data-interactive") === "true";
48
+ if (!interactive) return;
49
+ var tbody = e.currentTarget.closest("tbody");
50
+ if (!tbody) return;
51
+ var rows = Array.from(tbody.children).filter(function(row) {
52
+ return row.tagName === "TR";
53
+ });
54
+ var rowIndex = rows.indexOf(e.currentTarget) + 1;
55
+ if (styleSheetRef.current) {
56
+ while(styleSheetRef.current.cssRules.length){
57
+ styleSheetRef.current.deleteRule(0);
58
+ }
59
+ styleSheetRef.current.insertRule('[data-id="'.concat(idRef.current, '"] tbody tr:nth-child(').concat(rowIndex, ") { background-color: var(--color-surface-higher); }"), 0);
60
+ }
61
+ };
62
+ var handleMouseLeave = function() {
63
+ if (styleSheetRef.current) {
64
+ while(styleSheetRef.current.cssRules.length){
65
+ styleSheetRef.current.deleteRule(0);
66
+ }
67
+ }
68
+ };
69
+ rows.forEach(function(row) {
70
+ row.addEventListener("mouseenter", handleMouseEnter);
71
+ row.addEventListener("mouseleave", handleMouseLeave);
72
+ });
73
+ return function() {
74
+ rows.forEach(function(row) {
75
+ row.removeEventListener("mouseenter", handleMouseEnter);
76
+ row.removeEventListener("mouseleave", handleMouseLeave);
77
+ });
78
+ };
79
+ }, [
80
+ loading,
81
+ containerRef,
82
+ tableContainerRef,
83
+ itemCount
84
+ ]);
85
+ var updateScrollState = (0, _react.useCallback)(function() {
86
+ if (!tableContainerRef.current) return;
87
+ var container = tableContainerRef.current;
88
+ requestAnimationFrame(function() {
89
+ var scrollLeft = container.scrollLeft, clientWidth = container.clientWidth, scrollWidth = container.scrollWidth;
90
+ setCanScrollLeft(scrollLeft > 0);
91
+ setCanScrollRight(scrollLeft + clientWidth + 4 < scrollWidth);
92
+ var firstRowCells = container.querySelectorAll("tbody > tr:first-child td");
93
+ var rowCells = container.querySelectorAll("tbody > tr");
94
+ columnWidthsRef.current = Array.from(firstRowCells).map(function(td) {
95
+ return td.offsetWidth;
96
+ });
97
+ rowHeightsRef.current = Array.from(rowCells).map(function(tr) {
98
+ return tr.getBoundingClientRect().height;
99
+ });
100
+ setColumnWidths(columnWidthsRef.current);
101
+ setRowHeights(rowHeightsRef.current);
102
+ });
103
+ }, [
104
+ tableContainerRef,
105
+ setCanScrollLeft,
106
+ setCanScrollRight,
107
+ setColumnWidths,
108
+ setRowHeights
109
+ ]);
110
+ var checkIfTableIsOutOfView = (0, _react.useCallback)(function() {
111
+ if (!tableContainerRef.current || insideModal) return;
112
+ var rect = tableContainerRef.current.getBoundingClientRect();
113
+ var isOutOfView = rect.bottom <= becomeStickyAt + 36 || rect.top >= window.innerHeight;
114
+ setIsHeaderSticky(stickyHeader && !isOutOfView && rect.top <= becomeStickyAt);
115
+ }, [
116
+ tableContainerRef,
117
+ setIsHeaderSticky
118
+ ]);
119
+ var debouncedUpdateScrollState = (0, _usedebounce.useDebouncedCallback)(updateScrollState, 30);
120
+ (0, _react.useEffect)(function() {
121
+ if (!tableContainerRef.current) return;
122
+ var container = tableContainerRef.current;
123
+ container.addEventListener("scroll", debouncedUpdateScrollState);
124
+ window.addEventListener("resize", debouncedUpdateScrollState);
125
+ window.addEventListener("scroll", checkIfTableIsOutOfView);
126
+ updateScrollState();
127
+ return function() {
128
+ container.removeEventListener("scroll", debouncedUpdateScrollState);
129
+ window.removeEventListener("resize", debouncedUpdateScrollState);
130
+ window.removeEventListener("scroll", checkIfTableIsOutOfView);
131
+ };
132
+ }, [
133
+ debouncedUpdateScrollState,
134
+ updateScrollState,
135
+ children,
136
+ loading,
137
+ tableContainerRef.current,
138
+ becomeStickyAt
139
+ ]);
140
+ return updateScrollState;
141
+ };
142
+ var _default = useTableScrollState;
@@ -0,0 +1,216 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import React, { useEffect, useRef } from "react";
4
+ import { tv } from "tailwind-variants";
5
+ import { Icon, Text, Tooltip } from "../index.js";
6
+ import { MobileHorizontalDotsMajor } from "@shopify/polaris-icons";
7
+ var styles = tv({
8
+ base: "Litho-ActionList",
9
+ variants: {
10
+ fullWidth: {
11
+ true: "w-full",
12
+ false: ""
13
+ }
14
+ },
15
+ defaultVariants: {
16
+ fullWidth: false
17
+ }
18
+ });
19
+ var sectionStyles = tv({
20
+ base: "Litho-ActionList__Section border-b border-edge-default last:border-b-0",
21
+ variants: {
22
+ padded: {
23
+ true: "p-2",
24
+ false: ""
25
+ }
26
+ }
27
+ });
28
+ var itemStyles = tv({
29
+ 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",
30
+ variants: {
31
+ disabled: {
32
+ true: "cursor-not-allowed hover:bg-transparent",
33
+ false: "cursor-pointer"
34
+ },
35
+ destructive: {
36
+ true: "hover:bg-form-bg-error-low",
37
+ false: "hover:bg-tint-2 active:bg-tint-3"
38
+ }
39
+ },
40
+ defaultVariants: {
41
+ disabled: false,
42
+ destructive: false
43
+ }
44
+ });
45
+ /**
46
+ * ActionList component renders a list of actionable items with optional sections.
47
+ * Supports keyboard navigation and action triggers on item selection.
48
+ *
49
+ * @component
50
+ * @param {Object} props - Component properties.
51
+ * @param {Array} [props.sections] - Sections containing items for the action list.
52
+ * Each section has a title and a list of items.
53
+ * @param {Array} [props.items] - List of items to render in the action list when no sections are provided.
54
+ * @param {string} [props.iconColor="subdued"] - Default color for icons in the action items.
55
+ * @param {function} [props.onActionAnyItem] - Callback function invoked whenever any action item is selected.
56
+ * @param {boolean} [props.fullWidth=false] - Whether to apply full width styling to the action list.
57
+ * @param {boolean} [props.showSecondaryAction=false] - Whether to show the secondary action icon.
58
+ * @example
59
+ * const items = [{ content: 'Item 1', onAction: () => {} }];
60
+ * <ActionList items={items} />
61
+ *
62
+ * @returns {JSX.Element} The rendered ActionList component.
63
+ */ function ActionList() {
64
+ var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
65
+ 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;
66
+ var sectionTitleAsKeys = true;
67
+ var items = initialItems || (sections ? sections.flatMap(function(section) {
68
+ return section.items;
69
+ }) : []);
70
+ var actionListRef = useRef(null);
71
+ var itemRefs = useRef([]);
72
+ var handleKeyDown = function(e) {
73
+ if (!actionListRef.current.contains(e.target)) return;
74
+ var enabledItems = itemRefs.current.filter(function(ref) {
75
+ return ref && ref.getAttribute("tabIndex") !== "-1";
76
+ });
77
+ var focusedIndex = enabledItems.findIndex(function(ref) {
78
+ return ref === document.activeElement;
79
+ });
80
+ if (e.key === "ArrowDown") {
81
+ var nextIndex = (focusedIndex + 1) % enabledItems.length;
82
+ enabledItems[nextIndex].focus();
83
+ e.preventDefault();
84
+ } else if (e.key === "ArrowUp") {
85
+ var prevIndex = (focusedIndex - 1 + enabledItems.length) % enabledItems.length;
86
+ enabledItems[prevIndex].focus();
87
+ e.preventDefault();
88
+ } else if (e.key === "Enter") {
89
+ var focusedItem = enabledItems[focusedIndex];
90
+ if (focusedItem) {
91
+ focusedItem.click();
92
+ e.preventDefault();
93
+ }
94
+ }
95
+ };
96
+ useEffect(function() {
97
+ window.addEventListener("keydown", handleKeyDown);
98
+ return function() {
99
+ window.removeEventListener("keydown", handleKeyDown);
100
+ };
101
+ }, []);
102
+ var classes = styles({
103
+ fullWidth: fullWidth
104
+ });
105
+ var sectionClasses = sectionStyles({
106
+ padded: padded
107
+ });
108
+ var isSectioned = sections && sections.length > 0;
109
+ if (isSectioned) {
110
+ sectionTitleAsKeys = sections.every(function(section) {
111
+ return Object.prototype.hasOwnProperty.call(section, "title");
112
+ });
113
+ }
114
+ var ActionListItem = function(param) {
115
+ var item = param.item, index = param.index;
116
+ 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;
117
+ var iconColor = disabled ? "disabled" : destructive ? "critical" : _iconColor;
118
+ var textColor = disabled ? "disabled" : destructive ? "critical" : "default";
119
+ var itemClasses = itemStyles({
120
+ disabled: disabled,
121
+ destructive: destructive
122
+ });
123
+ var secondaryActionContent = secondaryAction ? /*#__PURE__*/ _jsx("div", {
124
+ className: "Litho-ActionList__Item__SecondaryAction rounded-sm px-1 hover:bg-tint-2 active:bg-tint-3",
125
+ onClick: function(e) {
126
+ e.stopPropagation();
127
+ secondaryAction.onAction();
128
+ },
129
+ children: /*#__PURE__*/ _jsx(Icon, {
130
+ source: (secondaryAction === null || secondaryAction === void 0 ? void 0 : secondaryAction.icon) || MobileHorizontalDotsMajor,
131
+ color: "subdued"
132
+ })
133
+ }) : null;
134
+ return /*#__PURE__*/ _jsxs("a", {
135
+ ref: function(el) {
136
+ return itemRefs.current[index] = el;
137
+ },
138
+ className: itemClasses,
139
+ tabIndex: disabled ? -1 : 0,
140
+ onClick: function(e) {
141
+ e.stopPropagation();
142
+ if (disabled) return;
143
+ if (onAction) onAction();
144
+ if (url) window.open(url, "_blank");
145
+ if (onActionAnyItem) onActionAnyItem();
146
+ },
147
+ children: [
148
+ prefix ? /*#__PURE__*/ _jsx("div", {
149
+ className: "Litho-ActionList__Item__Prefix w-5 h-5 flex items-center justify-center shrink-0",
150
+ children: prefix
151
+ }) : icon ? /*#__PURE__*/ _jsx("div", {
152
+ className: "Litho-ActionList__Item__Icon shrink-0",
153
+ children: /*#__PURE__*/ _jsx(Icon, {
154
+ source: icon,
155
+ color: iconColor,
156
+ stroke: item === null || item === void 0 ? void 0 : item.iconStroke,
157
+ display: item === null || item === void 0 ? void 0 : item.iconDisplay
158
+ })
159
+ }) : imageUrl ? /*#__PURE__*/ _jsx("div", {
160
+ className: "Litho-ActionList__Item__Image shrink-0",
161
+ children: /*#__PURE__*/ _jsx("img", {
162
+ src: imageUrl,
163
+ alt: content,
164
+ className: "w-5 h-5 rounded-sm"
165
+ })
166
+ }) : null,
167
+ /*#__PURE__*/ _jsx("div", {
168
+ className: "flex-1",
169
+ children: /*#__PURE__*/ _jsx(Text, {
170
+ color: textColor,
171
+ truncate: true,
172
+ children: content
173
+ })
174
+ }),
175
+ (secondaryAction === null || secondaryAction === void 0 ? void 0 : secondaryAction.tooltip) ? /*#__PURE__*/ _jsx(Tooltip, {
176
+ content: secondaryAction.tooltip,
177
+ children: secondaryActionContent
178
+ }) : secondaryActionContent
179
+ ]
180
+ });
181
+ };
182
+ return /*#__PURE__*/ _jsx("div", {
183
+ ref: actionListRef,
184
+ className: "".concat(classes).concat(className ? " ".concat(className) : ""),
185
+ tabIndex: -1,
186
+ children: isSectioned ? sections.map(function(section, sectionIndex) {
187
+ return /*#__PURE__*/ _jsxs("div", {
188
+ className: sectionClasses,
189
+ children: [
190
+ section.title && /*#__PURE__*/ _jsx("div", {
191
+ className: "Litho-ActionList__SectionTitle px-2 py-1",
192
+ children: /*#__PURE__*/ _jsx(Text, {
193
+ variant: "headingSm",
194
+ children: section.title
195
+ })
196
+ }),
197
+ section.items.map(function(item, itemIndex) {
198
+ return /*#__PURE__*/ _jsx(ActionListItem, {
199
+ item: item,
200
+ index: sectionIndex * section.items.length + itemIndex
201
+ }, "item-".concat(sectionIndex, "-").concat(itemIndex));
202
+ })
203
+ ]
204
+ }, sectionTitleAsKeys ? section.title : sectionIndex);
205
+ }) : /*#__PURE__*/ _jsx("div", {
206
+ className: sectionClasses,
207
+ children: items.map(function(item, itemIndex) {
208
+ return /*#__PURE__*/ _jsx(ActionListItem, {
209
+ item: item,
210
+ index: itemIndex
211
+ }, "item-".concat(itemIndex));
212
+ })
213
+ })
214
+ });
215
+ }
216
+ export default ActionList;
@@ -0,0 +1,63 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { tv } from "tailwind-variants";
3
+ import { Text, Icon } from "../index.js";
4
+ var styles = tv({
5
+ base: "Litho-AnnouncementBar text-center p-2 min-h-10 flex items-center justify-center bg-brand",
6
+ variants: {
7
+ fixed: {
8
+ true: "fixed top-0 left-0 right-0"
9
+ },
10
+ interactive: {
11
+ true: "cursor-pointer hover:bg-brand-low active:bg-brand-lower",
12
+ false: ""
13
+ }
14
+ }
15
+ });
16
+ var iconContainerStyles = tv({
17
+ base: "Litho-AnnouncementBar__IconContainer",
18
+ variants: {
19
+ animateIcon: {
20
+ bounce: "animate-bounce"
21
+ }
22
+ }
23
+ });
24
+ /**
25
+ * AnnouncementBar Component
26
+ *
27
+ * @param {Object} props - Component properties.
28
+ * @param {Function} [props.onClick] - Click handler function.
29
+ * @param {string} props.content - Text content to be displayed.
30
+ * @param {string} [props.icon] - Icon source name.
31
+ * @param {"bounce"} [props.animateIcon] - Animation type for the icon.
32
+ *
33
+ * @returns {JSX.Element} AnnouncementBar component.
34
+ */ function AnnouncementBar() {
35
+ var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
36
+ 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;
37
+ return /*#__PURE__*/ _jsx("div", {
38
+ className: styles({
39
+ fixed: fixed,
40
+ interactive: !!onClick
41
+ }),
42
+ onClick: onClick,
43
+ children: /*#__PURE__*/ _jsxs("div", {
44
+ className: "flex items-center justify-center gap-4",
45
+ children: [
46
+ /*#__PURE__*/ _jsx(Text, {
47
+ fontWeight: "medium",
48
+ className: "text-md",
49
+ children: content
50
+ }),
51
+ icon && /*#__PURE__*/ _jsx("div", {
52
+ className: iconContainerStyles({
53
+ animateIcon: animateIcon
54
+ }),
55
+ children: /*#__PURE__*/ _jsx(Icon, {
56
+ source: icon
57
+ })
58
+ })
59
+ ]
60
+ })
61
+ });
62
+ }
63
+ export default AnnouncementBar;
@@ -0,0 +1,185 @@
1
+ "use client";
2
+ function _array_like_to_array(arr, len) {
3
+ if (len == null || len > arr.length) len = arr.length;
4
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5
+ return arr2;
6
+ }
7
+ function _array_with_holes(arr) {
8
+ if (Array.isArray(arr)) return arr;
9
+ }
10
+ function _iterable_to_array_limit(arr, i) {
11
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
12
+ if (_i == null) return;
13
+ var _arr = [];
14
+ var _n = true;
15
+ var _d = false;
16
+ var _s, _e;
17
+ try {
18
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
19
+ _arr.push(_s.value);
20
+ if (i && _arr.length === i) break;
21
+ }
22
+ } catch (err) {
23
+ _d = true;
24
+ _e = err;
25
+ } finally{
26
+ try {
27
+ if (!_n && _i["return"] != null) _i["return"]();
28
+ } finally{
29
+ if (_d) throw _e;
30
+ }
31
+ }
32
+ return _arr;
33
+ }
34
+ function _non_iterable_rest() {
35
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
36
+ }
37
+ function _sliced_to_array(arr, i) {
38
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
39
+ }
40
+ function _unsupported_iterable_to_array(o, minLen) {
41
+ if (!o) return;
42
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
43
+ var n = Object.prototype.toString.call(o).slice(8, -1);
44
+ if (n === "Object" && o.constructor) n = o.constructor.name;
45
+ if (n === "Map" || n === "Set") return Array.from(n);
46
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
47
+ }
48
+ import { jsx as _jsx } from "react/jsx-runtime";
49
+ import React, { createContext, useState, useEffect, useContext } from "react";
50
+ /**
51
+ * @typedef {Object} DarkModeContextType
52
+ * @property {boolean} darkModeAvailable - Whether dark mode is available.
53
+ * @property {boolean} darkMode - Whether dark mode is enabled.
54
+ * @property {(darkMode: boolean) => void} toggleDarkMode - Toggle dark mode.
55
+ * @property {(darkModeAvailable: boolean) => void} setDarkModeAvailable - Set dark mode availability.
56
+ */ export var DarkModeContext = /*#__PURE__*/ createContext(null);
57
+ /**
58
+ * @returns {DarkModeContextType}
59
+ */ export var useDarkMode = function() {
60
+ return useContext(DarkModeContext);
61
+ };
62
+ export var FrameContext = /*#__PURE__*/ createContext({
63
+ embedded: false,
64
+ paneIsOpen: false,
65
+ setPaneIsOpen: function() {},
66
+ modalIsOpen: false,
67
+ setModalIsOpen: function() {},
68
+ showMobileNavigation: false,
69
+ contentIsInIframe: false,
70
+ contentIsFullPage: false,
71
+ setShowMobileNavigation: function() {},
72
+ setContentIsInIframe: function() {},
73
+ setContentIsFullPage: function() {}
74
+ });
75
+ export var FormContext = /*#__PURE__*/ createContext(null);
76
+ var screenSizes = typeof window !== "undefined" ? {
77
+ sm: parseInt(getComputedStyle(document.documentElement).getPropertyValue("--breakpoint-sm"), 10),
78
+ md: parseInt(getComputedStyle(document.documentElement).getPropertyValue("--breakpoint-md"), 10),
79
+ lg: parseInt(getComputedStyle(document.documentElement).getPropertyValue("--breakpoint-lg"), 10),
80
+ xl: parseInt(getComputedStyle(document.documentElement).getPropertyValue("--breakpoint-xl"), 10),
81
+ "2xl": parseInt(getComputedStyle(document.documentElement).getPropertyValue("--breakpoint-2xl"), 10)
82
+ } : {};
83
+ /**
84
+ * Provider component for managing global application state.
85
+ * @param {Object} props
86
+ * @param {React.ReactNode} props.children - The child components.
87
+ * @param {boolean} props.embedded - Whether the app is embedded.
88
+ * @param {boolean} props.darkModeAvailable - Whether dark mode is enabled.
89
+ * @param {string} props.darkModeStorageKey - Local storage key for dark mode preference.
90
+ * @param {(darkMode: boolean) => void} props.onDarkModeChange - Callback when dark mode changes.
91
+ * @returns {JSX.Element}
92
+ */ function AppProvider(param) {
93
+ var children = param.children, _param_embedded = param.embedded, embedded = _param_embedded === void 0 ? false : _param_embedded, tmp = param.darkModeAvailable, _darkModeAvailable = tmp === void 0 ? false : tmp, darkModeStorageKey = param.darkModeStorageKey, onDarkModeChange = param.onDarkModeChange;
94
+ var _useState = _sliced_to_array(useState(false), 2), showMobileNavigation = _useState[0], setShowMobileNavigation = _useState[1];
95
+ var _useState1 = _sliced_to_array(useState(_darkModeAvailable), 2), darkModeAvailable = _useState1[0], setDarkModeAvailable = _useState1[1];
96
+ var _useState2 = _sliced_to_array(useState(false), 2), contentIsInIframe = _useState2[0], setContentIsInIframe = _useState2[1];
97
+ var _useState3 = _sliced_to_array(useState(false), 2), contentIsFullPage = _useState3[0], setContentIsFullPage = _useState3[1];
98
+ var _useState4 = _sliced_to_array(useState(false), 2), modalIsOpen = _useState4[0], setModalIsOpen = _useState4[1];
99
+ var _useState5 = _sliced_to_array(useState(false), 2), paneIsOpen = _useState5[0], setPaneIsOpen = _useState5[1];
100
+ var _useState6 = _sliced_to_array(useState(false), 2), showGlobalContextualSaveBar = _useState6[0], setShowGlobalContextualSaveBar = _useState6[1];
101
+ var _useState7 = _sliced_to_array(useState(null), 2), message = _useState7[0], setMessage = _useState7[1];
102
+ var _useState8 = _sliced_to_array(useState(null), 2), saveAction = _useState8[0], setSaveAction = _useState8[1];
103
+ var _useState9 = _sliced_to_array(useState(null), 2), discardAction = _useState9[0], setDiscardAction = _useState9[1];
104
+ var _useState10 = _sliced_to_array(useState(false), 2), darkMode = _useState10[0], setDarkMode = _useState10[1];
105
+ var _useState11 = _sliced_to_array(useState(false), 2), isClient = _useState11[0], setIsClient = _useState11[1];
106
+ useEffect(function() {
107
+ setIsClient(true);
108
+ if (darkModeAvailable) {
109
+ var storedPreference = localStorage.getItem(darkModeStorageKey);
110
+ if (storedPreference !== null) {
111
+ setDarkMode(JSON.parse(storedPreference));
112
+ } else {
113
+ setDarkMode(window.matchMedia("(prefers-color-scheme: dark)").matches);
114
+ }
115
+ }
116
+ }, [
117
+ darkModeAvailable,
118
+ darkModeStorageKey
119
+ ]);
120
+ useEffect(function() {
121
+ if (!darkModeAvailable || !isClient) return;
122
+ if (darkMode) {
123
+ document.documentElement.setAttribute("data-theme", "dark");
124
+ } else {
125
+ document.documentElement.removeAttribute("data-theme");
126
+ }
127
+ if (onDarkModeChange) {
128
+ onDarkModeChange(darkMode);
129
+ }
130
+ }, [
131
+ darkMode,
132
+ onDarkModeChange,
133
+ darkModeAvailable,
134
+ isClient
135
+ ]);
136
+ var toggleDarkMode = function() {
137
+ return setDarkMode(function(prevMode) {
138
+ if (!darkModeAvailable) return false;
139
+ var newMode = !prevMode;
140
+ localStorage.setItem(darkModeStorageKey, JSON.stringify(newMode));
141
+ return newMode;
142
+ });
143
+ };
144
+ return /*#__PURE__*/ _jsx(DarkModeContext.Provider, {
145
+ value: {
146
+ darkModeAvailable: darkModeAvailable,
147
+ darkMode: darkMode,
148
+ toggleDarkMode: toggleDarkMode,
149
+ setDarkModeAvailable: setDarkModeAvailable
150
+ },
151
+ children: /*#__PURE__*/ _jsx(FrameContext.Provider, {
152
+ value: {
153
+ embedded: embedded,
154
+ contentIsInIframe: contentIsInIframe,
155
+ setContentIsInIframe: setContentIsInIframe,
156
+ showMobileNavigation: showMobileNavigation,
157
+ setShowMobileNavigation: setShowMobileNavigation,
158
+ contentIsFullPage: contentIsFullPage,
159
+ setContentIsFullPage: setContentIsFullPage,
160
+ modalIsOpen: modalIsOpen,
161
+ setModalIsOpen: setModalIsOpen,
162
+ paneIsOpen: paneIsOpen,
163
+ setPaneIsOpen: setPaneIsOpen,
164
+ screenSizes: screenSizes
165
+ },
166
+ children: /*#__PURE__*/ _jsx(FormContext.Provider, {
167
+ value: {
168
+ showGlobalContextualSaveBar: showGlobalContextualSaveBar,
169
+ setShowGlobalContextualSaveBar: setShowGlobalContextualSaveBar,
170
+ message: message,
171
+ setMessage: setMessage,
172
+ saveAction: saveAction,
173
+ setSaveAction: setSaveAction,
174
+ discardAction: discardAction,
175
+ setDiscardAction: setDiscardAction
176
+ },
177
+ children: /*#__PURE__*/ _jsx("div", {
178
+ className: "app-wrapper ".concat(embedded ? "@container" : ""),
179
+ children: children
180
+ })
181
+ })
182
+ })
183
+ });
184
+ }
185
+ export default AppProvider;