@helpdice/ui 1.6.9 → 1.7.0

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 (117) hide show
  1. package/dist/Placeholder/index.js +37 -16
  2. package/dist/auto-complete/index.js +37 -15
  3. package/dist/avatar/avatar.d.ts +2 -1
  4. package/dist/avatar/index.js +33 -13
  5. package/dist/badge/index.js +30 -11
  6. package/dist/breadcrumbs/index.js +30 -11
  7. package/dist/button/index.js +32 -12
  8. package/dist/button-dropdown/index.js +30 -11
  9. package/dist/button-group/index.js +30 -11
  10. package/dist/capacity/index.js +30 -11
  11. package/dist/card/index.js +30 -11
  12. package/dist/checkbox/index.js +30 -11
  13. package/dist/code/index.js +30 -11
  14. package/dist/col/index.js +21 -2
  15. package/dist/collapse/index.js +30 -11
  16. package/dist/css-baseline/index.js +24 -5
  17. package/dist/description/index.js +30 -11
  18. package/dist/display/index.js +30 -11
  19. package/dist/divider/index.js +30 -11
  20. package/dist/dot/index.js +30 -11
  21. package/dist/drawer/index.js +30 -11
  22. package/dist/fieldset/index.js +30 -11
  23. package/dist/grid/grid-container.d.ts +3 -3
  24. package/dist/grid/grid.d.ts +3 -3
  25. package/dist/grid/index.js +30 -11
  26. package/dist/image/index.js +30 -11
  27. package/dist/index.d.ts +3 -3
  28. package/dist/index.js +10950 -1486
  29. package/dist/input/index.js +34 -13
  30. package/dist/keyboard/index.js +30 -11
  31. package/dist/link/index.js +30 -11
  32. package/dist/list/index.d.ts +9 -0
  33. package/dist/list/index.js +1287 -0
  34. package/dist/list/list-item.d.ts +53 -0
  35. package/dist/list/list.d.ts +44 -0
  36. package/dist/loading/index.js +30 -11
  37. package/dist/menu/index.d.ts +2 -0
  38. package/dist/menu/index.js +10354 -0
  39. package/dist/menu/menu.d.ts +9 -0
  40. package/dist/modal/index.js +34 -13
  41. package/dist/note/index.js +30 -11
  42. package/dist/page/index.js +30 -11
  43. package/dist/pagination/index.js +30 -11
  44. package/dist/popover/index.js +30 -11
  45. package/dist/progress/index.js +30 -11
  46. package/dist/radio/index.js +30 -11
  47. package/dist/rating/index.js +30 -11
  48. package/dist/row/index.js +21 -2
  49. package/dist/search-bar/index.js +31 -12
  50. package/dist/select/index.js +30 -11
  51. package/dist/slider/index.js +30 -11
  52. package/dist/snippet/index.js +30 -11
  53. package/dist/spacer/index.js +30 -11
  54. package/dist/spinner/index.js +30 -11
  55. package/dist/table/index.d.ts +0 -1
  56. package/dist/table/index.js +1663 -2242
  57. package/dist/tabs/index.js +30 -11
  58. package/dist/tag/index.js +30 -11
  59. package/dist/text/index.js +37 -16
  60. package/dist/text/text.d.ts +1 -0
  61. package/dist/textarea/index.js +30 -11
  62. package/dist/toggle/index.js +30 -11
  63. package/dist/tooltip/index.js +30 -11
  64. package/dist/tree/index.js +21 -2
  65. package/dist/ui-provider/index.js +32 -12
  66. package/dist/use-scale/index.js +9 -9
  67. package/dist/user/index.js +33 -13
  68. package/esm/auto-complete/auto-complete.js +3 -2
  69. package/esm/avatar/avatar.d.ts +2 -1
  70. package/esm/avatar/avatar.js +3 -2
  71. package/esm/button/button.js +2 -1
  72. package/esm/code-block/index.js +17 -12
  73. package/esm/css-baseline/css-baseline.js +3 -3
  74. package/esm/form/FormWrapper.js +4 -4
  75. package/esm/grid/grid-container.d.ts +3 -3
  76. package/esm/grid/grid.d.ts +3 -3
  77. package/esm/index.d.ts +3 -3
  78. package/esm/index.js +3 -3
  79. package/esm/input/input.js +2 -1
  80. package/esm/input/password.js +2 -1
  81. package/esm/link/link.js +2 -2
  82. package/esm/list/index.d.ts +9 -0
  83. package/esm/list/index.js +8 -0
  84. package/esm/list/list-item.d.ts +53 -0
  85. package/esm/list/list-item.js +84 -0
  86. package/esm/list/list.d.ts +44 -0
  87. package/esm/list/list.js +29 -0
  88. package/esm/login-with/LoginSocialApple/index.js +17 -17
  89. package/esm/login-with/LoginSocialGithub/index.js +2 -2
  90. package/esm/login-with/LoginSocialInstagram/index.js +2 -2
  91. package/esm/login-with/LoginSocialLinkedin/index.js +2 -2
  92. package/esm/login-with/LoginSocialMicrosoft/index.js +2 -2
  93. package/esm/login-with/LoginSocialPinterest/index.js +9 -9
  94. package/esm/login-with/LoginSocialTiktok/index.js +2 -2
  95. package/esm/login-with/LoginSocialTwitter/index.js +11 -11
  96. package/esm/menu/index.d.ts +2 -0
  97. package/esm/menu/index.js +2 -0
  98. package/esm/menu/menu.d.ts +9 -0
  99. package/esm/menu/menu.js +92 -0
  100. package/esm/modal/modal-action.js +2 -1
  101. package/esm/table/index.d.ts +0 -1
  102. package/esm/table/index.js +0 -1
  103. package/esm/table/table-body.js +4 -23
  104. package/esm/text/child.js +3 -3
  105. package/esm/text/text.d.ts +1 -0
  106. package/esm/text/text.js +4 -2
  107. package/esm/tooltip/__test__/index.test.js +28 -28
  108. package/package.json +15 -11
  109. package/dist/cart/index.d.ts +0 -72
  110. package/dist/cart/useLocalStorage.d.ts +0 -1
  111. package/dist/table/data-table.d.ts +0 -44
  112. package/esm/cart/index.d.ts +0 -72
  113. package/esm/cart/index.js +0 -265
  114. package/esm/cart/useLocalStorage.d.ts +0 -1
  115. package/esm/cart/useLocalStorage.js +0 -29
  116. package/esm/table/data-table.d.ts +0 -44
  117. package/esm/table/data-table.js +0 -451
package/esm/cart/index.js DELETED
@@ -1,265 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import _extends from "@babel/runtime/helpers/esm/extends";
3
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
- /* eslint-disable @typescript-eslint/ban-types */
5
- /* "use client" */;
6
- import * as React from "react";
7
- import useLocalStorage from "./useLocalStorage";
8
- export var initialState = {
9
- items: [],
10
- isEmpty: true,
11
- totalItems: 0,
12
- totalUniqueItems: 0,
13
- cartTotal: 0,
14
- metadata: {}
15
- };
16
- var CartContext = /*#__PURE__*/React.createContext(initialState);
17
- export var createCartIdentifier = function createCartIdentifier() {
18
- var len = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 12;
19
- return _toConsumableArray(Array(len)).map(function () {
20
- return (~~(Math.random() * 36)).toString(36);
21
- }).join("");
22
- };
23
- export var useCart = function useCart() {
24
- var context = React.useContext(CartContext);
25
- if (!context) throw new Error("Expected to be wrapped in a CartProvider");
26
- return context;
27
- };
28
- function reducer(state, action) {
29
- switch (action.type) {
30
- case "SET_ITEMS":
31
- return generateCartState(state, action.payload);
32
- case "ADD_ITEM":
33
- {
34
- var items = [].concat(_toConsumableArray(state.items), [action.payload]);
35
- return generateCartState(state, items);
36
- }
37
- case "UPDATE_ITEM":
38
- {
39
- var _items = state.items.map(function (item) {
40
- if (item.id !== action.id) return item;
41
- return _extends({}, item, action.payload);
42
- });
43
- return generateCartState(state, _items);
44
- }
45
- case "REMOVE_ITEM":
46
- {
47
- var _items2 = state.items.filter(function (i) {
48
- return i.id !== action.id;
49
- });
50
- return generateCartState(state, _items2);
51
- }
52
- case "EMPTY_CART":
53
- return initialState;
54
- case "CLEAR_CART_META":
55
- return _extends({}, state, {
56
- metadata: {}
57
- });
58
- case "SET_CART_META":
59
- return _extends({}, state, {
60
- metadata: _extends({}, action.payload)
61
- });
62
- case "UPDATE_CART_META":
63
- return _extends({}, state, {
64
- metadata: _extends({}, state.metadata, action.payload)
65
- });
66
- default:
67
- throw new Error("No action specified");
68
- }
69
- }
70
- var generateCartState = function generateCartState() {
71
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
72
- var items = arguments.length > 1 ? arguments[1] : undefined;
73
- var totalUniqueItems = calculateUniqueItems(items);
74
- var isEmpty = totalUniqueItems === 0;
75
- return _extends({}, initialState, state, {
76
- items: calculateItemTotals(items),
77
- totalItems: calculateTotalItems(items),
78
- totalUniqueItems: totalUniqueItems,
79
- cartTotal: calculateTotal(items),
80
- isEmpty: isEmpty
81
- });
82
- };
83
- var calculateItemTotals = function calculateItemTotals(items) {
84
- return items.map(function (item) {
85
- return _extends({}, item, {
86
- itemTotal: item.price * item.quantity
87
- });
88
- });
89
- };
90
- var calculateTotal = function calculateTotal(items) {
91
- return items.reduce(function (total, item) {
92
- return total + item.quantity * item.price;
93
- }, 0);
94
- };
95
- var calculateTotalItems = function calculateTotalItems(items) {
96
- return items.reduce(function (sum, item) {
97
- return sum + item.quantity;
98
- }, 0);
99
- };
100
- var calculateUniqueItems = function calculateUniqueItems(items) {
101
- return items.length;
102
- };
103
- export var CartProvider = function CartProvider(_ref) {
104
- var children = _ref.children,
105
- cartId = _ref.id,
106
- _ref$defaultItems = _ref.defaultItems,
107
- defaultItems = _ref$defaultItems === void 0 ? [] : _ref$defaultItems,
108
- onSetItems = _ref.onSetItems,
109
- onItemAdd = _ref.onItemAdd,
110
- onItemUpdate = _ref.onItemUpdate,
111
- onItemRemove = _ref.onItemRemove,
112
- onEmptyCart = _ref.onEmptyCart,
113
- _ref$storage = _ref.storage,
114
- storage = _ref$storage === void 0 ? useLocalStorage : _ref$storage,
115
- metadata = _ref.metadata;
116
- var id = cartId ? cartId : createCartIdentifier();
117
- var _storage = storage(cartId ? "react-use-cart-".concat(id) : "react-use-cart", JSON.stringify(_extends({
118
- id: id
119
- }, initialState, {
120
- items: defaultItems,
121
- metadata: metadata
122
- }))),
123
- _storage2 = _slicedToArray(_storage, 2),
124
- savedCart = _storage2[0],
125
- saveCart = _storage2[1];
126
- var _React$useReducer = React.useReducer(reducer, JSON.parse(savedCart)),
127
- _React$useReducer2 = _slicedToArray(_React$useReducer, 2),
128
- state = _React$useReducer2[0],
129
- dispatch = _React$useReducer2[1];
130
- React.useEffect(function () {
131
- saveCart(JSON.stringify(state));
132
- }, [state, saveCart]);
133
- var setItems = function setItems(items) {
134
- dispatch({
135
- type: "SET_ITEMS",
136
- payload: items.map(function (item) {
137
- return _extends({}, item, {
138
- quantity: item.quantity || 1
139
- });
140
- })
141
- });
142
- onSetItems && onSetItems(items);
143
- };
144
- var addItem = function addItem(item) {
145
- var quantity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
146
- if (!item.id) throw new Error("You must provide an `id` for items");
147
- if (quantity <= 0) return;
148
- var currentItem = state.items.find(function (i) {
149
- return i.id === item.id;
150
- });
151
- if (!currentItem && !item.hasOwnProperty("price")) throw new Error("You must pass a `price` for new items");
152
- if (!currentItem) {
153
- var _payload = _extends({}, item, {
154
- quantity: quantity
155
- });
156
- dispatch({
157
- type: "ADD_ITEM",
158
- payload: _payload
159
- });
160
- onItemAdd && onItemAdd(_payload);
161
- return;
162
- }
163
- var payload = _extends({}, item, {
164
- quantity: currentItem.quantity + quantity
165
- });
166
- dispatch({
167
- type: "UPDATE_ITEM",
168
- id: item.id,
169
- payload: payload
170
- });
171
- onItemUpdate && onItemUpdate(payload);
172
- };
173
- var updateItem = function updateItem(id, payload) {
174
- if (!id || !payload) {
175
- return;
176
- }
177
- dispatch({
178
- type: "UPDATE_ITEM",
179
- id: id,
180
- payload: payload
181
- });
182
- onItemUpdate && onItemUpdate(payload);
183
- };
184
- var updateItemQuantity = function updateItemQuantity(id, quantity) {
185
- if (quantity <= 0) {
186
- onItemRemove && onItemRemove(id);
187
- dispatch({
188
- type: "REMOVE_ITEM",
189
- id: id
190
- });
191
- return;
192
- }
193
- var currentItem = state.items.find(function (item) {
194
- return item.id === id;
195
- });
196
- if (!currentItem) throw new Error("No such item to update");
197
- var payload = _extends({}, currentItem, {
198
- quantity: quantity
199
- });
200
- dispatch({
201
- type: "UPDATE_ITEM",
202
- id: id,
203
- payload: payload
204
- });
205
- onItemUpdate && onItemUpdate(payload);
206
- };
207
- var removeItem = function removeItem(id) {
208
- if (!id) return;
209
- dispatch({
210
- type: "REMOVE_ITEM",
211
- id: id
212
- });
213
- onItemRemove && onItemRemove(id);
214
- };
215
- var emptyCart = function emptyCart() {
216
- dispatch({
217
- type: "EMPTY_CART"
218
- });
219
- onEmptyCart && onEmptyCart();
220
- };
221
- var getItem = function getItem(id) {
222
- return state.items.find(function (i) {
223
- return i.id === id;
224
- });
225
- };
226
- var inCart = function inCart(id) {
227
- return state.items.some(function (i) {
228
- return i.id === id;
229
- });
230
- };
231
- var clearCartMetadata = function clearCartMetadata() {
232
- dispatch({
233
- type: "CLEAR_CART_META"
234
- });
235
- };
236
- var setCartMetadata = function setCartMetadata(metadata) {
237
- if (!metadata) return;
238
- dispatch({
239
- type: "SET_CART_META",
240
- payload: metadata
241
- });
242
- };
243
- var updateCartMetadata = function updateCartMetadata(metadata) {
244
- if (!metadata) return;
245
- dispatch({
246
- type: "UPDATE_CART_META",
247
- payload: metadata
248
- });
249
- };
250
- return /*#__PURE__*/React.createElement(CartContext.Provider, {
251
- value: _extends({}, state, {
252
- getItem: getItem,
253
- inCart: inCart,
254
- setItems: setItems,
255
- addItem: addItem,
256
- updateItem: updateItem,
257
- updateItemQuantity: updateItemQuantity,
258
- removeItem: removeItem,
259
- emptyCart: emptyCart,
260
- clearCartMetadata: clearCartMetadata,
261
- setCartMetadata: setCartMetadata,
262
- updateCartMetadata: updateCartMetadata
263
- })
264
- }, children);
265
- };
@@ -1 +0,0 @@
1
- export default function useLocalStorage(key: string, initialValue: string): [string, (value: Function | string) => void];
@@ -1,29 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- /* "use client" */;
3
-
4
- /* eslint-disable @typescript-eslint/ban-types */
5
-
6
- import * as React from "react";
7
- export default function useLocalStorage(key, initialValue) {
8
- var _React$useState = React.useState(function () {
9
- try {
10
- var item = typeof window !== "undefined" && window.localStorage.getItem(key);
11
- return item ? item : initialValue;
12
- } catch (error) {
13
- return initialValue;
14
- }
15
- }),
16
- _React$useState2 = _slicedToArray(_React$useState, 2),
17
- storedValue = _React$useState2[0],
18
- setStoredValue = _React$useState2[1];
19
- var setValue = function setValue(value) {
20
- try {
21
- var valueToStore = value instanceof Function ? value(storedValue) : value;
22
- setStoredValue(valueToStore);
23
- window.localStorage.setItem(key, valueToStore);
24
- } catch (error) {
25
- console.log(error);
26
- }
27
- };
28
- return [storedValue, setValue];
29
- }
@@ -1,44 +0,0 @@
1
- import React from 'react';
2
- type DataTableProps = {
3
- cols: any[];
4
- rows: any[];
5
- readOnly?: boolean;
6
- loading?: boolean;
7
- heading?: never[];
8
- filter?: boolean;
9
- menu?: never;
10
- sideMenu?: boolean;
11
- style?: object;
12
- children?: React.ReactNode;
13
- stickyHeader?: boolean;
14
- hasMore?: boolean;
15
- nextFn?: () => void;
16
- onBack?: () => void;
17
- infiniteLoader?: React.ReactNode;
18
- endMessage?: React.ReactNode;
19
- onRefresh?: () => void;
20
- onFilters?: (filters: object) => void;
21
- onSelectedDelete?: (selected: never[]) => void;
22
- onSelectedEdit?: (selected: never) => void;
23
- onSelected?: (selected: any) => void;
24
- disableViewColumn?: boolean;
25
- rowDraggable?: boolean;
26
- onDragOver?: () => void;
27
- onDragEnter?: () => void;
28
- onDragLeave?: () => void;
29
- onDrop?: () => void;
30
- onRowClick?: (row: any) => void;
31
- disableMenu?: boolean;
32
- dataLength?: number;
33
- viewLength?: number;
34
- onPageChange?: (page: number, start: number, end: number) => void;
35
- cursorPagination?: boolean;
36
- previousCursor?: string;
37
- nextCursor?: string;
38
- onNextPage?: (next?: string) => void;
39
- onPreviousPage?: (prev?: string) => void;
40
- };
41
- declare function DataTable({ cols, rows, readOnly, heading, filter, menu, sideMenu, style, children, onBack, onRefresh, // Function
42
- onFilters, onSelectedDelete, onSelectedEdit, onSelected, disableViewColumn, rowDraggable, onDragOver, onDragEnter, onDragLeave, onDrop, onRowClick, dataLength, viewLength, onPageChange, disableMenu, cursorPagination, previousCursor, nextCursor, hasMore, stickyHeader, onNextPage, onPreviousPage, }: DataTableProps): React.JSX.Element;
43
- declare const _default: React.MemoExoticComponent<typeof DataTable>;
44
- export default _default;