@apple-pie/slice 0.0.1 → 0.0.3

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 (225) hide show
  1. package/dist/cjs/chunks/Avatar-8-wPWe0V.js +68 -0
  2. package/dist/cjs/chunks/AvatarGroup-CVKmgBbD.js +39 -0
  3. package/dist/cjs/chunks/Badge-CMapJCij.js +41 -0
  4. package/dist/cjs/chunks/CheckBox-7AACxrdZ.js +76 -0
  5. package/dist/cjs/chunks/DivInput-BKKJTFeV.js +204 -0
  6. package/dist/cjs/chunks/DocIcons-BRWOzK96.js +41 -0
  7. package/dist/cjs/chunks/Dot-Dnr9M9na.js +80 -0
  8. package/dist/cjs/chunks/DrggablePanel-C6TPsDB-.js +302 -0
  9. package/dist/cjs/chunks/DropDown-D9sf_m2I.js +154 -0
  10. package/dist/cjs/chunks/EditorButtonBar-CUNDgRQd.js +244 -0
  11. package/dist/cjs/chunks/ErrorSummary-Dv44onsV.js +42 -0
  12. package/dist/cjs/chunks/FlexDiv-DZBpswHV.js +103 -0
  13. package/dist/cjs/chunks/Grouper-_kd2nU78.js +50 -0
  14. package/dist/cjs/chunks/IconButton-BfsPlKTb.js +84 -0
  15. package/dist/cjs/chunks/Logos-DSlAUz8l.js +119 -0
  16. package/dist/cjs/chunks/MessageInput-CiHFo2j8.js +399 -0
  17. package/dist/cjs/chunks/Overlay-DwCPvGB5.js +45 -0
  18. package/dist/cjs/chunks/Pager-CFtZ0IIW.js +42 -0
  19. package/dist/cjs/chunks/ProgressIndicator-C5oB7Mky.js +121 -0
  20. package/dist/cjs/chunks/RadioButton-e_y2qiPE.js +65 -0
  21. package/dist/cjs/chunks/RadioButtonList-I81UwHmM.js +116 -0
  22. package/dist/cjs/chunks/Slider-C-gn7Sby.js +285 -0
  23. package/dist/cjs/chunks/Spacer-BEY2-_PB.js +16 -0
  24. package/dist/cjs/chunks/Switch-CtkFtogd.js +43 -0
  25. package/dist/cjs/chunks/TabBar-D3bj4pjj.js +176 -0
  26. package/dist/cjs/chunks/TextArea-B1oKK3_b.js +153 -0
  27. package/dist/cjs/chunks/TextField-CiQdPP5E.js +248 -0
  28. package/dist/cjs/chunks/Tip-C2pzExut.js +91 -0
  29. package/dist/cjs/chunks/Toast-DrijUwoL.js +141 -0
  30. package/dist/cjs/chunks/UIButton-CH4p-8yq.js +317 -0
  31. package/dist/cjs/chunks/UIButtonBar-0fHPB0ww.js +58 -0
  32. package/dist/cjs/chunks/UICard-DBDSyT7E.js +36 -0
  33. package/dist/cjs/chunks/UIChip-kjhvRrOV.js +93 -0
  34. package/dist/cjs/chunks/UIFileIcon-ZrbDIeYz.js +54 -0
  35. package/dist/cjs/chunks/UILabel-DkBE2AIt.js +116 -0
  36. package/dist/cjs/chunks/_types-CoWzQFsT.js +714 -0
  37. package/dist/cjs/chunks/sharedTypes-BvTjh6M5.js +9 -0
  38. package/dist/cjs/chunks/style-inject.es-XZHJH68X.js +30 -0
  39. package/dist/cjs/chunks/tipStore-C9oV9SIh.js +23 -0
  40. package/dist/cjs/chunks/toastStore-C-ETP9H6.js +23 -0
  41. package/dist/cjs/chunks/tslib.es6-4H29ixHs.js +48 -0
  42. package/dist/cjs/chunks/utils-CbayehuI.js +126 -0
  43. package/dist/cjs/hooks/useDoubleClick.js +26 -0
  44. package/dist/cjs/hooks/useKeyboardShortcuts.js +42 -0
  45. package/dist/cjs/hooks/useLastUpdated.js +53 -0
  46. package/dist/cjs/hooks/useLocalStore.js +52 -0
  47. package/dist/cjs/hooks/useObserveResize.js +56 -0
  48. package/dist/cjs/hooks/useObserveTheme.js +37 -0
  49. package/dist/cjs/hooks/useTheme.js +86 -0
  50. package/dist/cjs/hooks/useToolTip.js +36 -0
  51. package/dist/cjs/hooks/useTrackRenders.js +38 -0
  52. package/dist/cjs/hooks/useWindow.js +64 -0
  53. package/dist/cjs/hooks.js +33 -0
  54. package/dist/cjs/index.js +124 -0
  55. package/dist/cjs/providers/ThemeProvider.js +55 -0
  56. package/dist/cjs/providers.js +14 -0
  57. package/dist/cjs/stores/tip.js +12 -0
  58. package/dist/cjs/stores/toast.js +12 -0
  59. package/dist/cjs/stores.js +18 -0
  60. package/dist/cjs/theme/colors.js +383 -0
  61. package/dist/cjs/theme/corners.js +14 -0
  62. package/dist/cjs/theme/elevations.js +17 -0
  63. package/dist/cjs/theme/themes.js +26 -0
  64. package/dist/cjs/theme/type.js +316 -0
  65. package/dist/cjs/theme.js +16 -0
  66. package/dist/cjs/uikit/Avatar.js +11 -0
  67. package/dist/cjs/uikit/AvatarGroup.js +12 -0
  68. package/dist/cjs/uikit/Badge.js +11 -0
  69. package/dist/cjs/uikit/CheckBox.js +22 -0
  70. package/dist/cjs/uikit/DivInput.js +13 -0
  71. package/dist/cjs/uikit/DocIcon.js +18 -0
  72. package/dist/cjs/uikit/Dot.js +12 -0
  73. package/dist/cjs/uikit/DraggablePanel.js +21 -0
  74. package/dist/cjs/uikit/DropDown.js +21 -0
  75. package/dist/cjs/uikit/EditorButtonBar.js +28 -0
  76. package/dist/cjs/uikit/ErrorSummary.js +12 -0
  77. package/dist/cjs/uikit/FlexDiv.js +12 -0
  78. package/dist/cjs/uikit/Grouper.js +23 -0
  79. package/dist/cjs/uikit/Icon.js +23 -0
  80. package/dist/cjs/uikit/IconButton.js +25 -0
  81. package/dist/cjs/uikit/Logos.js +18 -0
  82. package/dist/cjs/uikit/MessageInput.js +30 -0
  83. package/dist/cjs/uikit/Overlay.js +12 -0
  84. package/dist/cjs/uikit/Pager.js +12 -0
  85. package/dist/cjs/uikit/Progress.js +21 -0
  86. package/dist/cjs/uikit/RadioButton.js +26 -0
  87. package/dist/cjs/uikit/RadioButtonList.js +27 -0
  88. package/dist/cjs/uikit/Slider.js +13 -0
  89. package/dist/cjs/uikit/Spacer.js +10 -0
  90. package/dist/cjs/uikit/Switch.js +12 -0
  91. package/dist/cjs/uikit/TabBar.js +26 -0
  92. package/dist/cjs/uikit/TextArea.js +27 -0
  93. package/dist/cjs/uikit/Textfield.js +28 -0
  94. package/dist/cjs/uikit/Tip.js +13 -0
  95. package/dist/cjs/uikit/Toast.js +26 -0
  96. package/dist/cjs/uikit/UIButton.js +26 -0
  97. package/dist/cjs/uikit/UIButtonBar.js +26 -0
  98. package/dist/cjs/uikit/UICard.js +21 -0
  99. package/dist/cjs/uikit/UIChip.js +22 -0
  100. package/dist/cjs/uikit/UIFileIcon.js +18 -0
  101. package/dist/cjs/uikit/UILabel.js +19 -0
  102. package/dist/esm/chunks/Avatar-D_muqPrW.js +66 -0
  103. package/dist/esm/chunks/AvatarGroup-D8Xmrn52.js +37 -0
  104. package/dist/esm/chunks/Badge-PPf5Uvw3.js +39 -0
  105. package/dist/esm/chunks/CheckBox-CswFI0Xc.js +74 -0
  106. package/dist/esm/chunks/DivInput-iKFkeU2F.js +202 -0
  107. package/dist/esm/chunks/DocIcons-CbOX4n8Y.js +39 -0
  108. package/dist/esm/chunks/Dot-B84UVs2e.js +78 -0
  109. package/dist/esm/chunks/DrggablePanel-CYYwTmFd.js +300 -0
  110. package/dist/esm/chunks/DropDown-D4t6EhKL.js +152 -0
  111. package/dist/esm/chunks/EditorButtonBar-FnMa8Zv2.js +242 -0
  112. package/dist/esm/chunks/ErrorSummary-DhU5SKPt.js +40 -0
  113. package/dist/esm/chunks/FlexDiv-CmMpORgn.js +101 -0
  114. package/dist/esm/chunks/Grouper-BbreOXI9.js +48 -0
  115. package/dist/esm/chunks/IconButton-CguHGkBM.js +82 -0
  116. package/dist/esm/chunks/Logos-DwZP-TR2.js +117 -0
  117. package/dist/esm/chunks/MessageInput-DMHzCwjO.js +397 -0
  118. package/dist/esm/chunks/Overlay-CCBy7n7H.js +43 -0
  119. package/dist/esm/chunks/Pager-BsSti93V.js +40 -0
  120. package/dist/esm/chunks/ProgressIndicator-BVukxMU6.js +118 -0
  121. package/dist/esm/chunks/RadioButton-B5BxQI0R.js +63 -0
  122. package/dist/esm/chunks/RadioButtonList-C2z8McAD.js +114 -0
  123. package/dist/esm/chunks/Slider-C-PcWqTz.js +283 -0
  124. package/dist/esm/chunks/Spacer-DbZSG5x3.js +14 -0
  125. package/dist/esm/chunks/Switch-DjfrSiQz.js +41 -0
  126. package/dist/esm/chunks/TabBar-BSBcgTbd.js +174 -0
  127. package/dist/esm/chunks/TextArea-COM0UPo2.js +151 -0
  128. package/dist/esm/chunks/TextField-Bh24bRWs.js +246 -0
  129. package/dist/esm/chunks/Tip-Ct19Ljul.js +89 -0
  130. package/dist/esm/chunks/Toast-BR0oMX6z.js +139 -0
  131. package/dist/esm/chunks/UIButton-DKx-_O8h.js +315 -0
  132. package/dist/esm/chunks/UIButtonBar-BNdA5eVq.js +56 -0
  133. package/dist/esm/chunks/UICard-Dn5f3wg8.js +34 -0
  134. package/dist/esm/chunks/UIChip-DqnGeVyR.js +91 -0
  135. package/dist/esm/chunks/UIFileIcon-qGxIPsJJ.js +52 -0
  136. package/dist/esm/chunks/UILabel-RnbodPCS.js +114 -0
  137. package/dist/esm/chunks/_types-BaYeLEWK.js +712 -0
  138. package/dist/esm/chunks/sharedTypes-BfZzG1KX.js +9 -0
  139. package/dist/esm/chunks/style-inject.es-tgCJW-Cu.js +28 -0
  140. package/dist/esm/chunks/tipStore-nBYJ6tmE.js +17 -0
  141. package/dist/esm/chunks/toastStore-r3pvNa28.js +17 -0
  142. package/dist/esm/chunks/tslib.es6-0pkUdtrF.js +45 -0
  143. package/dist/esm/chunks/utils-BRZK2Drn.js +119 -0
  144. package/dist/esm/hooks/useDoubleClick.js +24 -0
  145. package/dist/esm/hooks/useKeyboardShortcuts.js +40 -0
  146. package/dist/esm/hooks/useLastUpdated.js +51 -0
  147. package/dist/esm/hooks/useLocalStore.js +50 -0
  148. package/dist/esm/hooks/useObserveResize.js +54 -0
  149. package/dist/esm/hooks/useObserveTheme.js +35 -0
  150. package/dist/esm/hooks/useTheme.js +84 -0
  151. package/dist/esm/hooks/useToolTip.js +34 -0
  152. package/dist/esm/hooks/useTrackRenders.js +36 -0
  153. package/dist/esm/hooks/useWindow.js +62 -0
  154. package/dist/esm/hooks.js +15 -0
  155. package/dist/esm/index.js +58 -0
  156. package/dist/esm/providers/ThemeProvider.js +53 -0
  157. package/dist/esm/providers.js +8 -0
  158. package/dist/esm/stores/tip.js +2 -0
  159. package/dist/esm/stores/toast.js +2 -0
  160. package/dist/esm/stores.js +3 -0
  161. package/dist/esm/theme/colors.js +377 -0
  162. package/dist/esm/theme/corners.js +12 -0
  163. package/dist/esm/theme/elevations.js +15 -0
  164. package/dist/esm/theme/themes.js +23 -0
  165. package/dist/esm/theme/type.js +312 -0
  166. package/dist/esm/theme.js +5 -0
  167. package/dist/esm/uikit/Avatar.js +5 -0
  168. package/dist/esm/uikit/AvatarGroup.js +6 -0
  169. package/dist/esm/uikit/Badge.js +5 -0
  170. package/dist/esm/uikit/CheckBox.js +16 -0
  171. package/dist/esm/uikit/DivInput.js +7 -0
  172. package/dist/esm/uikit/DocIcon.js +12 -0
  173. package/dist/esm/uikit/Dot.js +6 -0
  174. package/dist/esm/uikit/DraggablePanel.js +15 -0
  175. package/dist/esm/uikit/DropDown.js +15 -0
  176. package/dist/esm/uikit/EditorButtonBar.js +22 -0
  177. package/dist/esm/uikit/ErrorSummary.js +6 -0
  178. package/dist/esm/uikit/FlexDiv.js +6 -0
  179. package/dist/esm/uikit/Grouper.js +17 -0
  180. package/dist/esm/uikit/Icon.js +13 -0
  181. package/dist/esm/uikit/IconButton.js +19 -0
  182. package/dist/esm/uikit/Logos.js +12 -0
  183. package/dist/esm/uikit/MessageInput.js +24 -0
  184. package/dist/esm/uikit/Overlay.js +6 -0
  185. package/dist/esm/uikit/Pager.js +6 -0
  186. package/dist/esm/uikit/Progress.js +14 -0
  187. package/dist/esm/uikit/RadioButton.js +20 -0
  188. package/dist/esm/uikit/RadioButtonList.js +21 -0
  189. package/dist/esm/uikit/Slider.js +7 -0
  190. package/dist/esm/uikit/Spacer.js +4 -0
  191. package/dist/esm/uikit/Switch.js +6 -0
  192. package/dist/esm/uikit/TabBar.js +20 -0
  193. package/dist/esm/uikit/TextArea.js +21 -0
  194. package/dist/esm/uikit/Textfield.js +22 -0
  195. package/dist/esm/uikit/Tip.js +7 -0
  196. package/dist/esm/uikit/Toast.js +16 -0
  197. package/dist/esm/uikit/UIButton.js +20 -0
  198. package/dist/esm/uikit/UIButtonBar.js +20 -0
  199. package/dist/esm/uikit/UICard.js +15 -0
  200. package/dist/esm/uikit/UIChip.js +16 -0
  201. package/dist/esm/uikit/UIFileIcon.js +12 -0
  202. package/dist/esm/uikit/UILabel.js +13 -0
  203. package/dist/types/index.d.ts +3 -3
  204. package/dist/types/providers/ThemeProvider.d.ts +1 -0
  205. package/dist/types/stores/index.d.ts +2 -0
  206. package/dist/types/stores/tip/_types.d.ts +8 -0
  207. package/dist/types/stores/tip/index.d.ts +2 -0
  208. package/dist/types/stores/tip/tipStore.d.ts +12 -0
  209. package/dist/types/stores/toast/_types.d.ts +14 -0
  210. package/dist/types/stores/toast/index.d.ts +2 -0
  211. package/dist/types/stores/toast/toastStore.d.ts +12 -0
  212. package/dist/types/theme/elevations/_types.d.ts +10 -0
  213. package/dist/types/theme/elevations/elevations.d.ts +5 -0
  214. package/dist/types/theme/index.d.ts +2 -0
  215. package/dist/types/theme/themes.d.ts +2 -0
  216. package/dist/types/uikit/FlexDiv/FlexDiv.d.ts +2 -0
  217. package/dist/types/uikit/FlexDiv/_types.d.ts +1 -0
  218. package/dist/types/uikit/Toast/Toast.d.ts +1 -1
  219. package/dist/types/uikit/Toast/_types.d.ts +7 -1
  220. package/dist/types/uikit/Toast/index.d.ts +1 -1
  221. package/package.json +84 -5
  222. package/dist/index.esm.js +0 -5859
  223. package/dist/index.esm.js.map +0 -1
  224. package/dist/index.js +0 -5911
  225. package/dist/index.js.map +0 -1
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ exports.ToolTipType = void 0;
4
+ (function (ToolTipType) {
5
+ ToolTipType["menu"] = "menu";
6
+ ToolTipType["button"] = "button";
7
+ ToolTipType["general"] = "general";
8
+ ToolTipType["other"] = "other";
9
+ })(exports.ToolTipType || (exports.ToolTipType = {}));
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ function styleInject(css, ref) {
4
+ if ( ref === void 0 ) ref = {};
5
+ var insertAt = ref.insertAt;
6
+
7
+ if (!css || typeof document === 'undefined') { return; }
8
+
9
+ var head = document.head || document.getElementsByTagName('head')[0];
10
+ var style = document.createElement('style');
11
+ style.type = 'text/css';
12
+
13
+ if (insertAt === 'top') {
14
+ if (head.firstChild) {
15
+ head.insertBefore(style, head.firstChild);
16
+ } else {
17
+ head.appendChild(style);
18
+ }
19
+ } else {
20
+ head.appendChild(style);
21
+ }
22
+
23
+ if (style.styleSheet) {
24
+ style.styleSheet.cssText = css;
25
+ } else {
26
+ style.appendChild(document.createTextNode(css));
27
+ }
28
+ }
29
+
30
+ exports.styleInject = styleInject;
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var zustand = require('zustand');
4
+
5
+ const useTipStore = zustand.create((set) => ({
6
+ tip: null,
7
+ actions: {
8
+ push: (tip) => set({ tip }),
9
+ clear: () => set({ tip: null }),
10
+ },
11
+ }));
12
+ // atomic hook exports for use in React components
13
+ const useTip = () => useTipStore((state) => state.tip);
14
+ const useTipActions = () => useTipStore((state) => state.actions);
15
+ // non-reactive imperative exports for use outside the React context
16
+ const tipActions = useTipStore.getState().actions;
17
+ const getTip = () => useTipStore.getState().tip;
18
+
19
+ exports.getTip = getTip;
20
+ exports.tipActions = tipActions;
21
+ exports.useTip = useTip;
22
+ exports.useTipActions = useTipActions;
23
+ exports.useTipStore = useTipStore;
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var zustand = require('zustand');
4
+
5
+ const useToastStore = zustand.create((set) => ({
6
+ toast: null,
7
+ actions: {
8
+ push: (toast) => set({ toast }),
9
+ clear: () => set({ toast: null }),
10
+ },
11
+ }));
12
+ // atomic hook exports for use in React components
13
+ const useToast = () => useToastStore((state) => state.toast);
14
+ const useToastActions = () => useToastStore((state) => state.actions);
15
+ // non-reactive imperative exports for use outside the React context
16
+ const toastActions = useToastStore.getState().actions;
17
+ const getToast = () => useToastStore.getState().toast;
18
+
19
+ exports.getToast = getToast;
20
+ exports.toastActions = toastActions;
21
+ exports.useToast = useToast;
22
+ exports.useToastActions = useToastActions;
23
+ exports.useToastStore = useToastStore;
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ /******************************************************************************
4
+ Copyright (c) Microsoft Corporation.
5
+
6
+ Permission to use, copy, modify, and/or distribute this software for any
7
+ purpose with or without fee is hereby granted.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
16
+ ***************************************************************************** */
17
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
18
+
19
+
20
+ function __rest(s, e) {
21
+ var t = {};
22
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
23
+ t[p] = s[p];
24
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
25
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
26
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
27
+ t[p[i]] = s[p[i]];
28
+ }
29
+ return t;
30
+ }
31
+
32
+ function __awaiter(thisArg, _arguments, P, generator) {
33
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
34
+ return new (P || (P = Promise))(function (resolve, reject) {
35
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
36
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
37
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
38
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
39
+ });
40
+ }
41
+
42
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
43
+ var e = new Error(message);
44
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
45
+ };
46
+
47
+ exports.__awaiter = __awaiter;
48
+ exports.__rest = __rest;
@@ -0,0 +1,126 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Clean up string with html
5
+ */
6
+ function cleanString(input, removeInvisible = true, removeHtml = true) {
7
+ let clean = input;
8
+ const scriptsRegEx = /\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;
9
+ clean = clean.replaceAll(scriptsRegEx, '');
10
+ if (removeInvisible) {
11
+ const invisibleRegEx = /[\r\n\t]/gi;
12
+ clean = clean.replaceAll(invisibleRegEx, '');
13
+ }
14
+ if (removeHtml) {
15
+ const htmlRegEx = /<\/?[a-z][^>]*>/gi;
16
+ clean = clean.replaceAll(htmlRegEx, '');
17
+ }
18
+ return clean;
19
+ }
20
+ /**
21
+ * Debug component rendering
22
+ * Code removed when built / deployed
23
+ */
24
+ function debug(previous, updated, name = 'component') {
25
+ if (process.env.NODE_ENV === 'test')
26
+ return; // exit if running tests
27
+ const props = previous.current.props;
28
+ const mount = previous.current.mount;
29
+ const unmount = previous.current.unmount;
30
+ if (mount) {
31
+ console.log({
32
+ component: name,
33
+ '(re)render': true,
34
+ event: 'Component Mount',
35
+ });
36
+ }
37
+ else if (unmount) {
38
+ console.log({
39
+ component: name,
40
+ '(re)render': false,
41
+ event: 'Component Unmount',
42
+ });
43
+ }
44
+ else {
45
+ const reasons = createPropChangeArray(props, updated);
46
+ console.log({
47
+ component: name,
48
+ '(re)render': true,
49
+ event: 'Props Change',
50
+ props: reasons,
51
+ });
52
+ }
53
+ return { props: updated, mount: false, unmount: false };
54
+ }
55
+ function createPropChangeArray(props, updated) {
56
+ const reasons = [];
57
+ for (const key of Object.keys(updated)) {
58
+ if (updated[key] !== props[key]) {
59
+ try {
60
+ const propName = `${key}:`;
61
+ const prev = JSON.stringify(props[key]);
62
+ const next = JSON.stringify(updated[key]);
63
+ const valueChanged = `${prev} > ${next}`;
64
+ reasons.push(`${propName} ${valueChanged}`);
65
+ }
66
+ catch (error) {
67
+ let message = 'Unknown error';
68
+ if (error instanceof Error)
69
+ message = error.message;
70
+ if (typeof error === 'string')
71
+ message = error;
72
+ reasons.push(`${key} ${message}`);
73
+ }
74
+ }
75
+ }
76
+ return reasons;
77
+ }
78
+ /**
79
+ * Utility to accessibility - mimics click event with designated keys event
80
+ */
81
+ function accessibleKeyDown(e, clickFunction, keys) {
82
+ const activateWith = ['Enter', ' '];
83
+ const match = activateWith.includes(e.key);
84
+ if (match) {
85
+ e.preventDefault();
86
+ clickFunction();
87
+ }
88
+ }
89
+ /**
90
+ * Get the pointer position from a DOM touch or mouse event
91
+ */
92
+ function pointerPosition(e) {
93
+ if (e.type.startsWith('touch')) {
94
+ const touchEvent = e;
95
+ return touchEvent.touches[0].clientX;
96
+ }
97
+ const mouseEvent = e;
98
+ return mouseEvent.clientX;
99
+ }
100
+ /**
101
+ * Filter and trim class name array
102
+ */
103
+ function filterClasses(classNames) {
104
+ return classNames
105
+ .filter((item) => item !== '')
106
+ .join(' ')
107
+ .trim();
108
+ }
109
+ /**
110
+ * Takes a style string or number and returns a valid CSS style string
111
+ */
112
+ function setStyle(value, defaultVal = undefined) {
113
+ const useValue = value !== null && value !== void 0 ? value : defaultVal;
114
+ if (!useValue)
115
+ return 'unset';
116
+ if (typeof useValue === 'string')
117
+ return useValue;
118
+ return `${useValue}px`;
119
+ }
120
+
121
+ exports.accessibleKeyDown = accessibleKeyDown;
122
+ exports.cleanString = cleanString;
123
+ exports.debug = debug;
124
+ exports.filterClasses = filterClasses;
125
+ exports.pointerPosition = pointerPosition;
126
+ exports.setStyle = setStyle;
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ function useDoubleClick(onClick, onDblClick, delay = 200) {
6
+ const timer = React.useRef(null);
7
+ const didClick = (payload) => {
8
+ if (timer.current)
9
+ clearTimeout(timer.current);
10
+ timer.current = setTimeout(() => {
11
+ onClick(payload);
12
+ }, delay);
13
+ return () => {
14
+ if (timer.current)
15
+ clearTimeout(timer.current);
16
+ };
17
+ };
18
+ const didDblClick = (payload) => {
19
+ if (timer.current)
20
+ clearTimeout(timer.current);
21
+ onDblClick(payload);
22
+ };
23
+ return [didClick, didDblClick];
24
+ }
25
+
26
+ exports.useDoubleClick = useDoubleClick;
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ function useKeyboardShortcuts(shortcuts, shortCutHandler, isAppleDevice) {
6
+ // don't process shortcuts on editable elements, like inputs, editable divs, etc.
7
+ const isEditable = React.useCallback((e) => {
8
+ const target = e.target;
9
+ if (target) {
10
+ const tag = target.tagName;
11
+ return (target.isContentEditable ||
12
+ tag === 'INPUT' ||
13
+ tag === 'TEXTAREA' ||
14
+ tag === 'SELECT');
15
+ }
16
+ return false;
17
+ }, []);
18
+ // get keyboard event check if it's a shortcut
19
+ const handleKeyPress = React.useCallback((e) => {
20
+ if (isEditable(e))
21
+ return;
22
+ const isMeta = (isAppleDevice && e.metaKey) || (!isAppleDevice && e.ctrlKey);
23
+ for (const s of shortcuts) {
24
+ if (s.key.toLowerCase() === e.key.toLowerCase() && isMeta) {
25
+ e.preventDefault();
26
+ shortCutHandler(s);
27
+ break;
28
+ }
29
+ }
30
+ }, [isAppleDevice, shortcuts, shortCutHandler, isEditable]);
31
+ // set keyboard listener
32
+ React.useEffect(() => {
33
+ if (shortcuts.length === 0)
34
+ return;
35
+ globalThis.addEventListener('keydown', handleKeyPress, false);
36
+ return () => {
37
+ globalThis.removeEventListener('keydown', handleKeyPress, false);
38
+ };
39
+ }, [shortcuts, handleKeyPress]);
40
+ }
41
+
42
+ exports.useKeyboardShortcuts = useKeyboardShortcuts;
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ function getTimeDifference(date, labelPrefix) {
6
+ const compareDate = date instanceof Date ? date : new Date(date);
7
+ if (Number.isNaN(compareDate.getTime()))
8
+ return `${labelPrefix}Invalid date`;
9
+ // getTime = milliseconds since Jan 1 1970 UTC
10
+ const secondsDiff = Math.max(0, Math.floor((Date.now() - compareDate.getTime()) / 1000));
11
+ const minutes = Math.floor(secondsDiff / 60);
12
+ const hours = Math.floor(minutes / 60);
13
+ const days = Math.floor(hours / 24);
14
+ if (minutes < 1)
15
+ return `${labelPrefix}Just now`;
16
+ if (minutes === 1)
17
+ return `${labelPrefix}1 min. ago`;
18
+ if (minutes < 60)
19
+ return `${labelPrefix}${minutes} mins. ago`;
20
+ if (hours === 1)
21
+ return `${labelPrefix}1 hour ago`;
22
+ if (hours < 24)
23
+ return `${labelPrefix}${hours} hours ago`;
24
+ if (days === 1)
25
+ return `${labelPrefix}1 day ago`;
26
+ if (days < 15)
27
+ return `${labelPrefix}${days} days ago`;
28
+ return compareDate.toLocaleDateString('en-US', {
29
+ day: '2-digit',
30
+ month: 'short',
31
+ year: 'numeric',
32
+ });
33
+ }
34
+ function useLastUpdated(timestamp, prefix = '', interval = 1) {
35
+ const [lastUpdated, setLastUpdated] = React.useState(timestamp ? getTimeDifference(timestamp, prefix) : '');
36
+ React.useEffect(() => {
37
+ if (!timestamp) {
38
+ setLastUpdated('');
39
+ return;
40
+ }
41
+ setLastUpdated(getTimeDifference(timestamp, prefix));
42
+ const refreshMinutes = Math.max(interval, 1);
43
+ const intervalTimer = setInterval(() => {
44
+ setLastUpdated(getTimeDifference(timestamp, prefix));
45
+ }, refreshMinutes * 60 * 1000);
46
+ return () => {
47
+ clearInterval(intervalTimer);
48
+ };
49
+ }, [interval, prefix, timestamp]);
50
+ return { lastUpdated, timer: interval };
51
+ }
52
+
53
+ exports.useLastUpdated = useLastUpdated;
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ function canUseLocalStorage() {
6
+ return (typeof globalThis !== 'undefined' &&
7
+ 'localStorage' in globalThis &&
8
+ globalThis.localStorage !== undefined &&
9
+ globalThis.localStorage !== null);
10
+ }
11
+ function readLocalStorageValue(key, fallback) {
12
+ if (!canUseLocalStorage())
13
+ return fallback;
14
+ try {
15
+ const raw = globalThis.localStorage.getItem(key);
16
+ if (raw === null) {
17
+ // If not set, initialize with fallback.
18
+ globalThis.localStorage.setItem(key, JSON.stringify(fallback));
19
+ return fallback;
20
+ }
21
+ return JSON.parse(raw);
22
+ }
23
+ catch (error) {
24
+ console.error(`Error parsing local storage item for key ${key}:`, {
25
+ error,
26
+ });
27
+ return fallback;
28
+ }
29
+ }
30
+ function useLocalStore(key, value) {
31
+ const [item, setItem] = React.useState(() => readLocalStorageValue(key, value));
32
+ // rehydrate on prop changes
33
+ React.useEffect(() => {
34
+ setItem(readLocalStorageValue(key, value));
35
+ }, [key, value]);
36
+ function updateItem(data) {
37
+ if (canUseLocalStorage()) {
38
+ try {
39
+ globalThis.localStorage.setItem(key, JSON.stringify(data));
40
+ }
41
+ catch (error) {
42
+ console.error(`Error setting local storage item for key ${key}:`, {
43
+ error,
44
+ });
45
+ }
46
+ }
47
+ setItem(data);
48
+ }
49
+ return [item, updateItem];
50
+ }
51
+
52
+ exports.useLocalStore = useLocalStore;
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ function useObserveResize(element, options) {
6
+ const [size, setSize] = React.useState({ width: 0, height: 0 });
7
+ const ignore = options === null || options === void 0 ? void 0 : options.ignore;
8
+ const handleResize = React.useCallback((entries) => {
9
+ var _a, _b;
10
+ if (!entries[0])
11
+ return;
12
+ const width = ((_a = element === null || element === void 0 ? void 0 : element.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0;
13
+ const height = ((_b = element === null || element === void 0 ? void 0 : element.current) === null || _b === void 0 ? void 0 : _b.offsetHeight) || 0;
14
+ setSize((prev) => {
15
+ const next = {
16
+ width: ignore === 'width' ? prev.width : width,
17
+ height: ignore === 'height' ? prev.height : height,
18
+ };
19
+ if (prev.width === next.width && prev.height === next.height) {
20
+ return prev;
21
+ }
22
+ return next;
23
+ });
24
+ }, [element, ignore]);
25
+ React.useEffect(() => {
26
+ if (element === undefined)
27
+ return;
28
+ const el = element.current;
29
+ if (!el)
30
+ return;
31
+ // Get initial size
32
+ const newWidth = el.offsetWidth || 0;
33
+ const newHeight = el.offsetHeight || 0;
34
+ // set the new size of different to previous
35
+ setSize((prev) => {
36
+ const next = {
37
+ width: ignore === 'width' ? prev.width : newWidth,
38
+ height: ignore === 'height' ? prev.height : newHeight,
39
+ };
40
+ if (prev.width === next.width && prev.height === next.height) {
41
+ return prev; // same so no need to trigger re-renders
42
+ }
43
+ return next;
44
+ });
45
+ // Observe size changes
46
+ const resizeObserver = new ResizeObserver(handleResize);
47
+ resizeObserver.observe(el);
48
+ return () => {
49
+ resizeObserver.unobserve(el);
50
+ resizeObserver.disconnect();
51
+ };
52
+ }, [element, handleResize, ignore]);
53
+ return size;
54
+ }
55
+
56
+ exports.useObserveResize = useObserveResize;
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var theme_themes = require('../theme/themes.js');
5
+ require('../theme/colors.js');
6
+ require('../theme/corners.js');
7
+ require('../theme/elevations.js');
8
+ require('../theme/type.js');
9
+
10
+ function useObserveTheme() {
11
+ const [theme, setTheme] = React.useState(theme_themes.lightTheme);
12
+ React.useEffect(() => {
13
+ const observer = new MutationObserver((mutations) => {
14
+ for (const mutation of mutations) {
15
+ if (mutation.type === 'attributes' &&
16
+ mutation.attributeName === 'data-theme') {
17
+ const newTheme = document.documentElement.dataset.theme;
18
+ if (!newTheme ||
19
+ newTheme === '' ||
20
+ newTheme.includes(theme_themes.lightTheme.name))
21
+ setTheme(theme_themes.lightTheme);
22
+ else {
23
+ setTheme(theme_themes.darkTheme);
24
+ }
25
+ }
26
+ }
27
+ });
28
+ observer.observe(document.documentElement, {
29
+ attributes: true,
30
+ attributeFilter: ['data-theme'],
31
+ });
32
+ return () => observer.disconnect();
33
+ }, []);
34
+ return theme;
35
+ }
36
+
37
+ exports.useObserveTheme = useObserveTheme;
@@ -0,0 +1,86 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var theme_themes = require('../theme/themes.js');
5
+ var theme_colors = require('../theme/colors.js');
6
+ var theme_type = require('../theme/type.js');
7
+ var hooks_useObserveTheme = require('./useObserveTheme.js');
8
+ require('../theme/corners.js');
9
+ require('../theme/elevations.js');
10
+
11
+ /**
12
+ * Hook to manage Slice theming
13
+ */
14
+ function useTheme() {
15
+ const current = hooks_useObserveTheme.useObserveTheme();
16
+ const set = React.useCallback((newTheme) => {
17
+ console.log('set theme', newTheme);
18
+ let theme;
19
+ if (typeof newTheme === 'string') {
20
+ if (newTheme === 'system') {
21
+ const darkModeMediaQuery = globalThis.matchMedia('(prefers-color-scheme: dark)');
22
+ const isDark = darkModeMediaQuery.matches;
23
+ theme = isDark ? theme_themes.darkTheme : theme_themes.lightTheme;
24
+ }
25
+ else {
26
+ theme = newTheme === theme_themes.darkTheme.name ? theme_themes.darkTheme : theme_themes.lightTheme;
27
+ }
28
+ }
29
+ else
30
+ theme = newTheme;
31
+ document.documentElement.dataset.theme = theme.name;
32
+ }, []);
33
+ const toggle = () => {
34
+ const lightMode = current.name === theme_themes.lightTheme.name;
35
+ const newTheme = lightMode ? theme_themes.darkTheme : theme_themes.lightTheme;
36
+ document.documentElement.dataset.theme = newTheme.name;
37
+ };
38
+ const isDark = React.useMemo(() => {
39
+ return current.name === theme_themes.darkTheme.name;
40
+ }, [current]);
41
+ return {
42
+ /**
43
+ * Slice's default dark theme
44
+ */
45
+ darkTheme: theme_themes.darkTheme,
46
+ /**
47
+ * Slice's default light theme
48
+ */
49
+ lightTheme: theme_themes.lightTheme,
50
+ /**
51
+ * The currently active SliceTheme
52
+ */
53
+ current,
54
+ /**
55
+ * CSS variables for theme colors
56
+ */
57
+ colors: theme_colors.colorCssVars,
58
+ /**
59
+ * CSS Class names for the theme colors
60
+ */
61
+ colorsClass: theme_colors.colorClass,
62
+ /**
63
+ * CSS class names for theme typefaces
64
+ */
65
+ typeClass: theme_type.typeCssClasses,
66
+ /**
67
+ * CSS typeface styles as inline style properties
68
+ */
69
+ typeStyle: theme_type.typeStyles,
70
+ /**
71
+ * Set a new theme by name or passing in a SliceTheme object
72
+ * @param newTheme
73
+ */
74
+ set,
75
+ /**
76
+ * Toggle between light and dark themes
77
+ */
78
+ toggle,
79
+ /**
80
+ * If the currently active theme is the Slice's default dark theme'
81
+ */
82
+ isDark,
83
+ };
84
+ }
85
+
86
+ exports.useTheme = useTheme;
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ const hiddenCoords = { x: 0, y: 0 };
6
+ function useToolTip(toolTip, tipElement) {
7
+ const [coords, setCoords] = React.useState(hiddenCoords);
8
+ React.useLayoutEffect(() => {
9
+ var _a;
10
+ // remove tooltip from view
11
+ if (!toolTip || !(tipElement === null || tipElement === void 0 ? void 0 : tipElement.current)) {
12
+ setCoords(hiddenCoords);
13
+ return;
14
+ }
15
+ // get the target ref
16
+ const target = (_a = toolTip.ref) === null || _a === void 0 ? void 0 : _a.current;
17
+ if (!target) {
18
+ setCoords(hiddenCoords);
19
+ return;
20
+ }
21
+ // get rectangles for parent and tooltip
22
+ const parentRect = target.getBoundingClientRect();
23
+ const tipRect = tipElement.current.getBoundingClientRect();
24
+ // get position and size details
25
+ const { x: parentX, y: parentY, width: parentWidth, height: parentHeight, } = parentRect;
26
+ const { width: tipWidth } = tipRect;
27
+ // calculate the tool tip coords suc that it's placed beneath the parent
28
+ const x = parentX + parentWidth / 2 - tipWidth / 2;
29
+ const y = parentY + parentHeight + 10;
30
+ // set the coords
31
+ setCoords({ x, y });
32
+ }, [toolTip, tipElement]);
33
+ return coords;
34
+ }
35
+
36
+ exports.useToolTip = useToolTip;