lutra 0.0.33 → 0.1.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 (242) hide show
  1. package/README.md +4 -24
  2. package/dist/components/AspectRatio.svelte +26 -0
  3. package/dist/components/AspectRatio.svelte.d.ts +8 -0
  4. package/dist/components/Dialog.svelte +78 -0
  5. package/dist/components/Dialog.svelte.d.ts +14 -0
  6. package/dist/components/Layout.svelte +32 -0
  7. package/dist/components/Layout.svelte.d.ts +11 -0
  8. package/dist/components/PageContent.svelte +108 -0
  9. package/dist/components/PageContent.svelte.d.ts +38 -0
  10. package/dist/components/Theme.svelte +87 -0
  11. package/dist/components/Theme.svelte.d.ts +17 -0
  12. package/dist/{display → components}/Tooltip.svelte +33 -8
  13. package/dist/components/Tooltip.svelte.d.ts +12 -0
  14. package/dist/config.d.ts +30 -0
  15. package/dist/config.js +18 -0
  16. package/dist/css/0-layers.css +1 -0
  17. package/dist/css/1-props.css +775 -0
  18. package/dist/css/2-base.css +209 -0
  19. package/dist/css/3-typo.css +65 -0
  20. package/dist/css/4-layout.css +5 -0
  21. package/dist/css/5-media.css +21 -0
  22. package/dist/css/lutra.css +6 -0
  23. package/dist/index.d.ts +5 -1
  24. package/dist/index.js +5 -2
  25. package/dist/types.d.ts +39 -0
  26. package/dist/types.js +25 -0
  27. package/package.json +29 -82
  28. package/dist/color.css +0 -0
  29. package/dist/display/Avatar.svelte +0 -61
  30. package/dist/display/Avatar.svelte.d.ts +0 -19
  31. package/dist/display/Badge.svelte +0 -91
  32. package/dist/display/Badge.svelte.d.ts +0 -30
  33. package/dist/display/Callout.svelte +0 -109
  34. package/dist/display/Callout.svelte.d.ts +0 -28
  35. package/dist/display/Close.svelte +0 -58
  36. package/dist/display/Close.svelte.d.ts +0 -18
  37. package/dist/display/Code.svelte +0 -190
  38. package/dist/display/Code.svelte.d.ts +0 -32
  39. package/dist/display/ContextTip.svelte +0 -23
  40. package/dist/display/ContextTip.svelte.d.ts +0 -18
  41. package/dist/display/DataList.svelte +0 -16
  42. package/dist/display/DataList.svelte.d.ts +0 -21
  43. package/dist/display/Details.svelte +0 -49
  44. package/dist/display/Details.svelte.d.ts +0 -27
  45. package/dist/display/Hero.svelte +0 -50
  46. package/dist/display/Hero.svelte.d.ts +0 -26
  47. package/dist/display/Icon.svelte +0 -39
  48. package/dist/display/Icon.svelte.d.ts +0 -19
  49. package/dist/display/IconButton.svelte +0 -91
  50. package/dist/display/IconButton.svelte.d.ts +0 -27
  51. package/dist/display/Image.svelte +0 -91
  52. package/dist/display/Image.svelte.d.ts +0 -26
  53. package/dist/display/Indicator.svelte +0 -352
  54. package/dist/display/Indicator.svelte.d.ts +0 -23
  55. package/dist/display/Inset.svelte +0 -18
  56. package/dist/display/Inset.svelte.d.ts +0 -18
  57. package/dist/display/LineChart.svelte +0 -385
  58. package/dist/display/LineChart.svelte.d.ts +0 -24
  59. package/dist/display/LoadingIndicator.svelte +0 -33
  60. package/dist/display/LoadingIndicator.svelte.d.ts +0 -15
  61. package/dist/display/Modal.svelte +0 -116
  62. package/dist/display/Modal.svelte.d.ts +0 -27
  63. package/dist/display/Notification.svelte +0 -104
  64. package/dist/display/Notification.svelte.d.ts +0 -23
  65. package/dist/display/Panel.svelte +0 -23
  66. package/dist/display/Panel.svelte.d.ts +0 -19
  67. package/dist/display/Popup.svelte +0 -111
  68. package/dist/display/Popup.svelte.d.ts +0 -25
  69. package/dist/display/Stat.svelte +0 -81
  70. package/dist/display/Stat.svelte.d.ts +0 -30
  71. package/dist/display/Table.svelte +0 -28
  72. package/dist/display/Table.svelte.d.ts +0 -24
  73. package/dist/display/TablePaginator.svelte +0 -51
  74. package/dist/display/TablePaginator.svelte.d.ts +0 -21
  75. package/dist/display/Tag.svelte +0 -90
  76. package/dist/display/Tag.svelte.d.ts +0 -32
  77. package/dist/display/Tooltip.svelte.d.ts +0 -23
  78. package/dist/display/chart.d.ts +0 -78
  79. package/dist/display/chart.js +0 -212
  80. package/dist/display/index.d.ts +0 -24
  81. package/dist/display/index.js +0 -24
  82. package/dist/display/notifications.svelte.d.ts +0 -21
  83. package/dist/display/notifications.svelte.js +0 -31
  84. package/dist/form/Button.svelte +0 -39
  85. package/dist/form/Button.svelte.d.ts +0 -26
  86. package/dist/form/FieldActions.svelte +0 -68
  87. package/dist/form/FieldActions.svelte.d.ts +0 -20
  88. package/dist/form/FieldContainer.svelte +0 -37
  89. package/dist/form/FieldContainer.svelte.d.ts +0 -19
  90. package/dist/form/FieldContent.svelte +0 -153
  91. package/dist/form/FieldContent.svelte.d.ts +0 -31
  92. package/dist/form/FieldError.svelte +0 -14
  93. package/dist/form/FieldError.svelte.d.ts +0 -18
  94. package/dist/form/FieldSection.svelte +0 -86
  95. package/dist/form/FieldSection.svelte.d.ts +0 -20
  96. package/dist/form/Fieldset.svelte +0 -68
  97. package/dist/form/Fieldset.svelte.d.ts +0 -31
  98. package/dist/form/Form.svelte +0 -136
  99. package/dist/form/Form.svelte.d.ts +0 -38
  100. package/dist/form/ImageUpload.svelte +0 -259
  101. package/dist/form/ImageUpload.svelte.d.ts +0 -31
  102. package/dist/form/Input.svelte +0 -326
  103. package/dist/form/Input.svelte.d.ts +0 -117
  104. package/dist/form/InputLength.svelte +0 -32
  105. package/dist/form/InputLength.svelte.d.ts +0 -20
  106. package/dist/form/Label.svelte +0 -44
  107. package/dist/form/Label.svelte.d.ts +0 -25
  108. package/dist/form/LogoUpload.svelte +0 -100
  109. package/dist/form/LogoUpload.svelte.d.ts +0 -29
  110. package/dist/form/Select.svelte +0 -136
  111. package/dist/form/Select.svelte.d.ts +0 -70
  112. package/dist/form/Textarea.svelte +0 -163
  113. package/dist/form/Textarea.svelte.d.ts +0 -108
  114. package/dist/form/Toggle.svelte +0 -2
  115. package/dist/form/Toggle.svelte.d.ts +0 -15
  116. package/dist/form/client.svelte.d.ts +0 -44
  117. package/dist/form/client.svelte.js +0 -98
  118. package/dist/form/form.d.ts +0 -54
  119. package/dist/form/form.js +0 -340
  120. package/dist/form/index.d.ts +0 -18
  121. package/dist/form/index.js +0 -18
  122. package/dist/form/types.d.ts +0 -62
  123. package/dist/form/types.js +0 -1
  124. package/dist/icons/IconAlert.svelte +0 -3
  125. package/dist/icons/IconAlert.svelte.d.ts +0 -23
  126. package/dist/icons/IconCopy.svelte +0 -3
  127. package/dist/icons/IconCopy.svelte.d.ts +0 -23
  128. package/dist/icons/IconDone.svelte +0 -3
  129. package/dist/icons/IconDone.svelte.d.ts +0 -23
  130. package/dist/icons/IconError.svelte +0 -3
  131. package/dist/icons/IconError.svelte.d.ts +0 -23
  132. package/dist/icons/IconHelp.svelte +0 -3
  133. package/dist/icons/IconHelp.svelte.d.ts +0 -23
  134. package/dist/icons/IconHide.svelte +0 -3
  135. package/dist/icons/IconHide.svelte.d.ts +0 -23
  136. package/dist/icons/IconInfo.svelte +0 -3
  137. package/dist/icons/IconInfo.svelte.d.ts +0 -23
  138. package/dist/icons/IconLink.svelte +0 -3
  139. package/dist/icons/IconLink.svelte.d.ts +0 -23
  140. package/dist/icons/IconMenuBurger.svelte +0 -3
  141. package/dist/icons/IconMenuBurger.svelte.d.ts +0 -23
  142. package/dist/icons/IconMenuDots.svelte +0 -3
  143. package/dist/icons/IconMenuDots.svelte.d.ts +0 -23
  144. package/dist/icons/IconSearch.svelte +0 -3
  145. package/dist/icons/IconSearch.svelte.d.ts +0 -23
  146. package/dist/icons/IconShow.svelte +0 -3
  147. package/dist/icons/IconShow.svelte.d.ts +0 -23
  148. package/dist/icons/IconSuccess.svelte +0 -3
  149. package/dist/icons/IconSuccess.svelte.d.ts +0 -23
  150. package/dist/icons/IconWarning.svelte +0 -3
  151. package/dist/icons/IconWarning.svelte.d.ts +0 -23
  152. package/dist/icons/index.d.ts +0 -14
  153. package/dist/icons/index.js +0 -14
  154. package/dist/layout/Layout.svelte +0 -47
  155. package/dist/layout/Layout.svelte.d.ts +0 -22
  156. package/dist/layout/LayoutFooter.svelte +0 -21
  157. package/dist/layout/LayoutFooter.svelte.d.ts +0 -18
  158. package/dist/layout/LayoutGrid.svelte +0 -51
  159. package/dist/layout/LayoutGrid.svelte.d.ts +0 -27
  160. package/dist/layout/LayoutHeader.svelte +0 -97
  161. package/dist/layout/LayoutHeader.svelte.d.ts +0 -34
  162. package/dist/layout/LayoutSideMenu.svelte +0 -55
  163. package/dist/layout/LayoutSideMenu.svelte.d.ts +0 -21
  164. package/dist/layout/LayoutTypes.d.ts +0 -15
  165. package/dist/layout/LayoutTypes.js +0 -9
  166. package/dist/layout/Overlay.svelte +0 -20
  167. package/dist/layout/Overlay.svelte.d.ts +0 -25
  168. package/dist/layout/OverlayContainer.svelte +0 -28
  169. package/dist/layout/OverlayContainer.svelte.d.ts +0 -15
  170. package/dist/layout/OverlayLayer.svelte +0 -140
  171. package/dist/layout/OverlayLayer.svelte.d.ts +0 -19
  172. package/dist/layout/PageContent.svelte +0 -82
  173. package/dist/layout/PageContent.svelte.d.ts +0 -25
  174. package/dist/layout/Theme.svelte +0 -243
  175. package/dist/layout/Theme.svelte.d.ts +0 -19
  176. package/dist/layout/UIContent.svelte +0 -15
  177. package/dist/layout/UIContent.svelte.d.ts +0 -18
  178. package/dist/layout/index.d.ts +0 -11
  179. package/dist/layout/index.js +0 -11
  180. package/dist/layout/overlays.svelte.d.ts +0 -34
  181. package/dist/layout/overlays.svelte.js +0 -44
  182. package/dist/nav/Breadcrumb.svelte +0 -82
  183. package/dist/nav/Breadcrumb.svelte.d.ts +0 -28
  184. package/dist/nav/Menu.svelte +0 -170
  185. package/dist/nav/Menu.svelte.d.ts +0 -27
  186. package/dist/nav/MenuItem.svelte +0 -147
  187. package/dist/nav/MenuItem.svelte.d.ts +0 -22
  188. package/dist/nav/MenuTypes.d.ts +0 -58
  189. package/dist/nav/MenuTypes.js +0 -1
  190. package/dist/nav/NavMenu.svelte +0 -181
  191. package/dist/nav/NavMenu.svelte.d.ts +0 -19
  192. package/dist/nav/TabbedContent.svelte +0 -43
  193. package/dist/nav/TabbedContent.svelte.d.ts +0 -23
  194. package/dist/nav/Tabs.svelte +0 -158
  195. package/dist/nav/Tabs.svelte.d.ts +0 -25
  196. package/dist/nav/index.d.ts +0 -7
  197. package/dist/nav/index.js +0 -6
  198. package/dist/style.css +0 -950
  199. package/dist/typo/Clamp.svelte +0 -25
  200. package/dist/typo/Clamp.svelte.d.ts +0 -24
  201. package/dist/typo/H.svelte +0 -52
  202. package/dist/typo/H.svelte.d.ts +0 -28
  203. package/dist/typo/H1.svelte +0 -14
  204. package/dist/typo/H1.svelte.d.ts +0 -26
  205. package/dist/typo/H2.svelte +0 -14
  206. package/dist/typo/H2.svelte.d.ts +0 -26
  207. package/dist/typo/H3.svelte +0 -14
  208. package/dist/typo/H3.svelte.d.ts +0 -26
  209. package/dist/typo/H4.svelte +0 -14
  210. package/dist/typo/H4.svelte.d.ts +0 -26
  211. package/dist/typo/H5.svelte +0 -14
  212. package/dist/typo/H5.svelte.d.ts +0 -26
  213. package/dist/typo/H6.svelte +0 -14
  214. package/dist/typo/H6.svelte.d.ts +0 -26
  215. package/dist/typo/P.svelte +0 -34
  216. package/dist/typo/P.svelte.d.ts +0 -26
  217. package/dist/typo/index.d.ts +0 -9
  218. package/dist/typo/index.js +0 -9
  219. package/dist/utils/StringOrComponent.svelte +0 -14
  220. package/dist/utils/StringOrComponent.svelte.d.ts +0 -19
  221. package/dist/utils/StringOrSnippet.svelte +0 -11
  222. package/dist/utils/StringOrSnippet.svelte.d.ts +0 -19
  223. package/dist/utils/attr.d.ts +0 -5
  224. package/dist/utils/attr.js +0 -21
  225. package/dist/utils/color.d.ts +0 -51
  226. package/dist/utils/color.js +0 -97
  227. package/dist/utils/defaults.d.ts +0 -4
  228. package/dist/utils/defaults.js +0 -1
  229. package/dist/utils/dom.d.ts +0 -15
  230. package/dist/utils/dom.js +0 -74
  231. package/dist/utils/hooks.server.d.ts +0 -2
  232. package/dist/utils/hooks.server.js +0 -16
  233. package/dist/utils/id.d.ts +0 -1
  234. package/dist/utils/id.js +0 -3
  235. package/dist/utils/index.d.ts +0 -9
  236. package/dist/utils/index.js +0 -6
  237. package/dist/utils/isSnippet.d.ts +0 -3
  238. package/dist/utils/isSnippet.js +0 -11
  239. package/dist/utils/keyboard.svelte.d.ts +0 -22
  240. package/dist/utils/keyboard.svelte.js +0 -161
  241. /package/dist/{utils → util}/transitions.d.ts +0 -0
  242. /package/dist/{utils → util}/transitions.js +0 -0
@@ -1,97 +0,0 @@
1
- /**
2
- * Convert a string to a color
3
- * @param {string} str - The string to convert
4
- * @returns {string} The color
5
- */
6
- export function stringToColor(str) {
7
- let hash = 0;
8
- for (let i = 0; i < str.length; i++) {
9
- hash = str.charCodeAt(i) + ((hash << 5) - hash);
10
- }
11
- let color = '#';
12
- for (let i = 0; i < 3; i++) {
13
- const value = (hash >> (i * 8)) & 0xFF;
14
- color += ('00' + value.toString(16)).substr(-2);
15
- }
16
- return color;
17
- }
18
- /**
19
- * Convert a hex color to rgb
20
- * @param {string} hex - The hex color
21
- * @returns {number[]} The rgb color
22
- */
23
- export function hexToRgb(hex) {
24
- // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
25
- var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
26
- hex = hex.replace(shorthandRegex, function (m, r, g, b) {
27
- return r + r + g + g + b + b;
28
- });
29
- const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
30
- if (!result) {
31
- throw new Error('Invalid hex color');
32
- }
33
- return [
34
- parseInt(result[1], 16),
35
- parseInt(result[2], 16),
36
- parseInt(result[3], 16)
37
- ];
38
- }
39
- /**
40
- * Get the relative luminance of a color from a hex color
41
- * @param {string} hex - The hex color
42
- * @returns {number} The relative luminance
43
- */
44
- export function hexRelativeLuminance(hex) {
45
- const rgb = hexToRgb(hex);
46
- return relativeLuminanceW3C(rgb[0], rgb[1], rgb[2]);
47
- }
48
- /**
49
- * Get the relative luminance of a color according to the W3C
50
- * @param {number} R8bit - The red value
51
- * @param {number} G8bit - The green value
52
- * @param {number} B8bit - The blue value
53
- * @returns
54
- */
55
- export function relativeLuminanceW3C(R8bit, G8bit, B8bit) {
56
- var RsRGB = R8bit / 255;
57
- var GsRGB = G8bit / 255;
58
- var BsRGB = B8bit / 255;
59
- var R = (RsRGB <= 0.03928) ? RsRGB / 12.92 : Math.pow((RsRGB + 0.055) / 1.055, 2.4);
60
- var G = (GsRGB <= 0.03928) ? GsRGB / 12.92 : Math.pow((GsRGB + 0.055) / 1.055, 2.4);
61
- var B = (BsRGB <= 0.03928) ? BsRGB / 12.92 : Math.pow((BsRGB + 0.055) / 1.055, 2.4);
62
- // For the sRGB colorspace, the relative luminance of a color is defined as:
63
- var L = 0.2126 * R + 0.7152 * G + 0.0722 * B;
64
- return L;
65
- }
66
- /**
67
- * Status colors
68
- */
69
- export const StatusColors = {
70
- default: "default",
71
- ok: "ok",
72
- alert: "alert",
73
- warn: "warn",
74
- info: "info",
75
- task: "task"
76
- };
77
- /**
78
- * Check if the value is a valid StatusColor
79
- * @param {string} value - The value to check
80
- * @returns {boolean} - If the value is a valid StatusColor
81
- */
82
- export const isStatusColor = (value) => {
83
- if (!value)
84
- return false;
85
- return Object.keys(StatusColors).includes(value);
86
- };
87
- /**
88
- * Get the CSS variable for a status color
89
- * @param {StatusColorOrString} color - The status color
90
- * @returns {string} - The CSS variable for the status color
91
- */
92
- export function getStatusColorVar(color, fallback) {
93
- if (isStatusColor(color)) {
94
- return `var(--status-${color})`;
95
- }
96
- return color || fallback || "var(--status-default)";
97
- }
@@ -1,4 +0,0 @@
1
- export type Defaults = {
2
- /** Default shape for elements */
3
- shape: "sharp" | "rounded";
4
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- /**
2
- * Find the containing block of a given element. The containing block is the nearest ancestor element that is a containing block for positioned elements.
3
- * @param {HTMLElement | null} element - The element to find the containing block for.
4
- * @returns {HTMLElement | null} - The containing block element, or null if none is found.
5
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block
6
- */
7
- export declare function findContainingBlock(element: HTMLElement | null, id?: string): HTMLElement | null;
8
- export declare function findAllContainingBlocks(element: HTMLElement | null): HTMLElement[];
9
- /**
10
- * Get the total offset of an element, including all its containing blocks.
11
- */
12
- export declare function getPossiblyContainedPosition(element: HTMLElement | null): {
13
- left: number;
14
- top: number;
15
- };
package/dist/utils/dom.js DELETED
@@ -1,74 +0,0 @@
1
- import { createId } from "./id.js";
2
- let initialElements = {};
3
- let initialStyles = {};
4
- /**
5
- * Find the containing block of a given element. The containing block is the nearest ancestor element that is a containing block for positioned elements.
6
- * @param {HTMLElement | null} element - The element to find the containing block for.
7
- * @returns {HTMLElement | null} - The containing block element, or null if none is found.
8
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block
9
- */
10
- export function findContainingBlock(element, id = createId()) {
11
- const elementToLookAt = element?.parentElement;
12
- // Base case for recursion: if the element is the body or null, return null as no containing block was found
13
- if (!elementToLookAt || !element || element.tagName === "BODY" || elementToLookAt.tagName === "BODY") {
14
- return null;
15
- }
16
- if (!initialElements[id]) {
17
- initialElements[id] = element;
18
- initialStyles[id] = getComputedStyle(element);
19
- }
20
- // Get computed styles of the current element
21
- const style = getComputedStyle(elementToLookAt);
22
- // Check for properties that make this element a containing block for positioned elements
23
- if ((style.position !== 'static' && (initialStyles[id].position === 'fixed' ||
24
- initialStyles[id].position === 'absolute' ||
25
- initialStyles[id].position === 'sticky')) ||
26
- (style.transform !== 'none' && style.transform !== undefined) ||
27
- style.perspective !== 'none' && style.perspective !== undefined ||
28
- style.filter !== 'none' && style.filter !== undefined ||
29
- style.willChange === 'transform' || style.willChange === 'perspective' ||
30
- style.willChange === 'filter' || // Firefox specific for filters
31
- (style.contain.includes('layout') || style.contain.includes('paint') || style.contain.includes('strict') || style.contain.includes('content')) ||
32
- style.containerType !== 'normal' ||
33
- (style.backdropFilter !== 'none' && style.backdropFilter !== undefined)) {
34
- delete initialElements[id];
35
- delete initialStyles[id];
36
- return element;
37
- }
38
- // Recurse up the DOM tree if no containing block found
39
- return findContainingBlock(elementToLookAt, id);
40
- }
41
- export function findAllContainingBlocks(element) {
42
- let currentElement = findContainingBlock(element);
43
- if (!currentElement)
44
- return [];
45
- const blocks = [currentElement];
46
- let i = 0;
47
- while (currentElement !== null && currentElement.tagName !== 'BODY' && i < 50) {
48
- const block = findContainingBlock(currentElement.parentElement);
49
- if (block) {
50
- blocks.push(block.parentElement);
51
- }
52
- currentElement = block;
53
- i++;
54
- }
55
- return blocks;
56
- }
57
- /**
58
- * Get the total offset of an element, including all its containing blocks.
59
- */
60
- export function getPossiblyContainedPosition(element) {
61
- const blocks = findAllContainingBlocks(element);
62
- let left = 0;
63
- let top = 0;
64
- for (const block of blocks) {
65
- const rect = block.getBoundingClientRect();
66
- console.log('block', block, rect);
67
- left += rect.left;
68
- top += rect.top;
69
- }
70
- return {
71
- left: left,
72
- top: top
73
- };
74
- }
@@ -1,2 +0,0 @@
1
- import type { RequestEvent } from "@sveltejs/kit";
2
- export declare const addAcceptCh: (event: RequestEvent) => void;
@@ -1,16 +0,0 @@
1
- const acceptCh = [
2
- 'Sec-CH-Prefers-Color-Scheme',
3
- 'Sec-CH-Prefers-Reduced-Transparency',
4
- 'Sec-CH-Prefers-Reduced-Motion',
5
- 'Sec-CH-UA-Arch',
6
- 'Sec-CH-UA-Bitness',
7
- 'Sec-CH-UA-Mobile',
8
- 'Sec-CH-UA-Model',
9
- 'Sec-CH-UA-Platform',
10
- 'Sec-CH-UA-Platform-Version',
11
- ];
12
- export const addAcceptCh = (event) => {
13
- event.setHeaders({
14
- 'Accept-CH': acceptCh.join(', ')
15
- });
16
- };
@@ -1 +0,0 @@
1
- export declare function createId(): string;
package/dist/utils/id.js DELETED
@@ -1,3 +0,0 @@
1
- export function createId() {
2
- return 'l-' + Math.random().toString(36).substr(2, 9);
3
- }
@@ -1,9 +0,0 @@
1
- export { attr } from './attr.js';
2
- export { stringToColor, hexToRgb, hexRelativeLuminance, relativeLuminanceW3C, StatusColors, isStatusColor, getStatusColorVar } from './color.js';
3
- export type { Defaults } from './defaults.js';
4
- export { createId } from './id.js';
5
- export type { StatusColor, StatusColorOrString } from './color.js';
6
- export { popBezier, popBezierInverse, slidefade, solve_spring, cubicBezier } from './transitions.js';
7
- export { default as StringOrComponent } from "./StringOrComponent.svelte";
8
- export { default as StringOrSnippet } from "./StringOrSnippet.svelte";
9
- export type { SpringParams } from './transitions.js';
@@ -1,6 +0,0 @@
1
- export { attr } from './attr.js';
2
- export { stringToColor, hexToRgb, hexRelativeLuminance, relativeLuminanceW3C, StatusColors, isStatusColor, getStatusColorVar } from './color.js';
3
- export { createId } from './id.js';
4
- export { popBezier, popBezierInverse, slidefade, solve_spring, cubicBezier } from './transitions.js';
5
- export { default as StringOrComponent } from "./StringOrComponent.svelte";
6
- export { default as StringOrSnippet } from "./StringOrSnippet.svelte";
@@ -1,3 +0,0 @@
1
- import type { Component, Snippet } from "svelte";
2
- export declare const isComponent: (object: unknown) => object is Component;
3
- export declare const isSnippet: (object: unknown) => object is Snippet;
@@ -1,11 +0,0 @@
1
- export const isComponent = (object) => {
2
- if (typeof object !== 'function')
3
- return false;
4
- const str = object.toString();
5
- console.log(object.name, str);
6
- return str.indexOf('$$payload, $$props)') !== -1;
7
- };
8
- export const isSnippet = (object) => {
9
- //console.log('isComponent', object!.toString(), object!.toString().length);
10
- return !isComponent(object);
11
- };
@@ -1,22 +0,0 @@
1
- /**
2
- * Get the next focusable element in the specified direction
3
- * @param {HTMLElement | null} startingElement - The element to start the search from.
4
- * @param {HTMLElement | null} triggerElement - The element that triggered the search.
5
- * @param {string} direction - The direction to search in, either 'next' or 'previous'.
6
- * @returns {HTMLElement | null} - The next focusable element, or null if none are found.
7
- */
8
- export declare function getNextFocusableElement(startingElement: HTMLElement | null, triggerElement: HTMLElement | null, direction: "next" | "previous"): HTMLElement | null;
9
- /**
10
- * Navigate through a list of elements using the arrow keys
11
- * @param {HTMLElement | null} el - The element containing the list of elements to navigate.
12
- * @param {string} direction - The direction to navigate in, either 'up' or 'down'.
13
- * @returns {void}
14
- */
15
- export declare function arrowNavigation(el: HTMLElement | null, direction: "up" | "down"): void;
16
- /**
17
- * Match the key pressed to the first letter of an element in the list
18
- * @param {HTMLElement | null} el - The element containing the list of elements to search through.
19
- * @param {KeyboardEvent} e - The keyboard event to match the key from.
20
- * @returns {void}
21
- */
22
- export declare function matchOnType(el: HTMLElement | null, e: KeyboardEvent): void;
@@ -1,161 +0,0 @@
1
- const ignoreKeys = ['backspace', 'tab', 'shift', 'control', 'alt', 'meta', 'arrowup', 'arrowdown', 'arrowleft', 'arrowright', 'home', 'end', 'pageup', 'pagedown', 'escape', 'capslock', 'numlock', 'scrolllock', 'pause', 'contextmenu', 'printscreen', 'help', 'clear', 'os', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f12', 'insert', 'delete', 'enter', 'space', 'escape'];
2
- let keyMemory = $state("");
3
- let timeout;
4
- /**
5
- * Get the next focusable element in the specified direction
6
- * @param {HTMLElement | null} startingElement - The element to start the search from.
7
- * @param {HTMLElement | null} triggerElement - The element that triggered the search.
8
- * @param {string} direction - The direction to search in, either 'next' or 'previous'.
9
- * @returns {HTMLElement | null} - The next focusable element, or null if none are found.
10
- */
11
- export function getNextFocusableElement(startingElement, triggerElement, direction) {
12
- if (!startingElement)
13
- return null;
14
- // Define selectors for focusable elements
15
- const focusableSelectors = 'a, button, textarea, input, select';
16
- // Get all focusable elements
17
- const allFocusableElements = Array.from(document.querySelectorAll(focusableSelectors)).filter(el => !el.disabled && el.tabIndex >= 0);
18
- console.log('allFocusableElements', allFocusableElements);
19
- // Filter out elements inside the startingElement
20
- const focusableElements = allFocusableElements.filter(el => !triggerElement.contains(el) && el !== startingElement);
21
- console.log('focusableElements', focusableElements);
22
- // Find the index of the starting element among all focusable elements
23
- let startingIndex = allFocusableElements.indexOf(triggerElement);
24
- console.log('startingIndex', startingIndex);
25
- if (startingIndex === -1) {
26
- // If the starting element is not focusable or not found, consider the document's active element if it's focusable.
27
- const activeElement = document.activeElement;
28
- if (activeElement && allFocusableElements.includes(activeElement)) {
29
- startingIndex = allFocusableElements.indexOf(activeElement);
30
- }
31
- else {
32
- // No valid starting point found
33
- return null;
34
- }
35
- }
36
- // Determine the next index based on the direction, skipping children of startingElement
37
- let nextIndex = -1;
38
- if (direction === 'next') {
39
- for (let i = startingIndex + 1; i < allFocusableElements.length; i++) {
40
- if (focusableElements.includes(allFocusableElements[i])) {
41
- nextIndex = focusableElements.indexOf(allFocusableElements[i]);
42
- break;
43
- }
44
- }
45
- }
46
- else {
47
- for (let i = startingIndex - 1; i >= 0; i--) {
48
- if (focusableElements.includes(allFocusableElements[i])) {
49
- nextIndex = focusableElements.indexOf(allFocusableElements[i]);
50
- break;
51
- }
52
- }
53
- }
54
- // If no next element is found in the direction, wrap around.
55
- if (nextIndex === -1) {
56
- if (direction === 'next') {
57
- // Wrap to the first element in the list
58
- nextIndex = 0;
59
- }
60
- else {
61
- // Wrap to the last element in the list
62
- nextIndex = focusableElements.length - 1;
63
- }
64
- }
65
- // Return the next focusable element, or null if none are found
66
- return focusableElements[nextIndex] || null;
67
- }
68
- /**
69
- * Navigate through a list of elements using the arrow keys
70
- * @param {HTMLElement | null} el - The element containing the list of elements to navigate.
71
- * @param {string} direction - The direction to navigate in, either 'up' or 'down'.
72
- * @returns {void}
73
- */
74
- export function arrowNavigation(el, direction) {
75
- const items = el?.querySelectorAll("a, button, input, textarea, select");
76
- if (!items)
77
- return;
78
- const index = Array.from(items).findIndex((el) => el === document.activeElement);
79
- if (index === -1) {
80
- items[0].focus();
81
- }
82
- else if (direction === "down" && index < items.length - 1) {
83
- items[index + 1].focus();
84
- }
85
- else if (direction === "up" && index > 0) {
86
- items[index - 1].focus();
87
- }
88
- }
89
- /**
90
- * Match the key pressed to the first letter of an element in the list
91
- * @param {HTMLElement | null} el - The element containing the list of elements to search through.
92
- * @param {KeyboardEvent} e - The keyboard event to match the key from.
93
- * @returns {void}
94
- */
95
- export function matchOnType(el, e) {
96
- const items = el?.querySelectorAll("a, button, label");
97
- if (!items)
98
- return;
99
- const index = Array.from(items).findIndex((el) => el === document.activeElement);
100
- const search = e.key.toLowerCase();
101
- if (timeout)
102
- clearTimeout(timeout);
103
- function removeUls() {
104
- items.forEach((el) => {
105
- const contentEl = el.querySelector("span.Content") ?? el.querySelector("label");
106
- if (contentEl) {
107
- contentEl.innerHTML = contentEl.textContent;
108
- }
109
- });
110
- }
111
- const currentlyFocusedElement = document.activeElement;
112
- // return if the key is not a letter or number
113
- if (ignoreKeys.includes(search) || currentlyFocusedElement.tagName === "INPUT" || currentlyFocusedElement.tagName === "TEXTAREA") {
114
- keyMemory = '';
115
- removeUls();
116
- return;
117
- }
118
- // clear the memory after 1 second
119
- timeout = setTimeout(() => {
120
- keyMemory = '';
121
- removeUls();
122
- }, 1000);
123
- // only add if the last key is not the same
124
- if (keyMemory[keyMemory.length - 1] !== search) {
125
- keyMemory += search;
126
- }
127
- const matches = Array.from(items).filter((el) => {
128
- const text = el.textContent?.trim().toLowerCase();
129
- return text?.startsWith(keyMemory);
130
- });
131
- if (matches.length) {
132
- // add underline to the matched text
133
- matches.forEach((el) => {
134
- const contentEl = el.querySelector("span.Content, label");
135
- const text = contentEl?.textContent?.trim();
136
- if (text) {
137
- const index = text.toLowerCase().indexOf(keyMemory);
138
- const first = text.slice(0, index);
139
- const last = text.slice(index + keyMemory.length);
140
- const middle = text.slice(index, index + keyMemory.length);
141
- contentEl.innerHTML = `${first}<u>${middle}</u>${last}`;
142
- }
143
- });
144
- if (keyMemory.length === 1) {
145
- // if this element is already focused, move to the next one if memory is at one character
146
- const nextMatches = Array.from(items).filter((el) => el.textContent?.trim().toLowerCase().startsWith(keyMemory));
147
- if (nextMatches) {
148
- const nextIndex = nextMatches.findIndex((el) => el === document.activeElement);
149
- if (nextIndex < nextMatches.length - 1) {
150
- nextMatches[nextIndex + 1].focus();
151
- }
152
- else {
153
- nextMatches[0].focus();
154
- }
155
- }
156
- }
157
- else {
158
- matches[0].focus();
159
- }
160
- }
161
- }
File without changes
File without changes