lapikit 0.0.0-insiders.dcdfb82 → 0.0.0-insiders.de70c0c

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 (210) hide show
  1. package/LICENSE +21 -0
  2. package/bin/configuration.js +304 -0
  3. package/bin/helper.js +64 -32
  4. package/bin/index.js +41 -0
  5. package/bin/lapikit.js +42 -10
  6. package/bin/legacy.js +34 -0
  7. package/bin/modules/adapter.js +5 -5
  8. package/bin/modules/plugin.js +223 -0
  9. package/bin/presets.js +26 -0
  10. package/bin/prompts.js +100 -0
  11. package/dist/actions/index.d.ts +1 -0
  12. package/dist/actions/index.js +1 -0
  13. package/dist/assets/icons/arrow-down.svelte +12 -0
  14. package/dist/assets/icons/arrow-down.svelte.d.ts +18 -0
  15. package/dist/assets/icons/arrow-up.svelte +12 -0
  16. package/dist/assets/icons/arrow-up.svelte.d.ts +18 -0
  17. package/dist/assets/icons/close-fill.svelte +12 -0
  18. package/dist/assets/icons/close-fill.svelte.d.ts +18 -0
  19. package/dist/assets/icons/loading-fill.svelte +31 -0
  20. package/dist/assets/icons/loading-fill.svelte.d.ts +18 -0
  21. package/dist/colors.css +0 -0
  22. package/dist/components/accordion/accordion.css +113 -0
  23. package/dist/components/accordion/accordion.svelte +37 -0
  24. package/dist/components/accordion/accordion.svelte.d.ts +4 -0
  25. package/dist/components/accordion/accordion.svelte.js +24 -0
  26. package/dist/components/accordion/modules/accordion-item.svelte +94 -0
  27. package/dist/components/accordion/modules/accordion-item.svelte.d.ts +4 -0
  28. package/dist/components/accordion/types.d.ts +33 -0
  29. package/dist/components/accordion/types.js +1 -0
  30. package/dist/components/alert/alert.css +137 -0
  31. package/dist/components/alert/alert.svelte +89 -0
  32. package/dist/components/alert/alert.svelte.d.ts +4 -0
  33. package/dist/components/alert/types.d.ts +28 -0
  34. package/dist/components/alert/types.js +1 -0
  35. package/dist/components/app/app.css +16 -0
  36. package/dist/components/app/app.svelte +48 -0
  37. package/dist/components/app/app.svelte.d.ts +7 -0
  38. package/dist/components/app/types.d.ts +4 -0
  39. package/dist/components/app/types.js +1 -0
  40. package/dist/components/appbar/appbar.css +48 -0
  41. package/dist/components/appbar/appbar.svelte +40 -0
  42. package/dist/components/appbar/appbar.svelte.d.ts +4 -0
  43. package/dist/components/appbar/types.d.ts +15 -0
  44. package/dist/components/appbar/types.js +1 -0
  45. package/dist/components/aspect-ratio/aspect-ratio.css +19 -0
  46. package/dist/components/aspect-ratio/aspect-ratio.svelte +47 -0
  47. package/dist/components/aspect-ratio/aspect-ratio.svelte.d.ts +4 -0
  48. package/dist/components/aspect-ratio/types.d.ts +5 -0
  49. package/dist/components/aspect-ratio/types.js +1 -0
  50. package/dist/components/avatar/avatar.css +109 -0
  51. package/dist/components/avatar/avatar.svelte +46 -0
  52. package/dist/components/avatar/avatar.svelte.d.ts +4 -0
  53. package/dist/components/avatar/types.d.ts +22 -0
  54. package/dist/components/avatar/types.js +1 -0
  55. package/dist/components/button/button.css +247 -0
  56. package/dist/components/button/button.svelte +102 -0
  57. package/dist/components/button/button.svelte.d.ts +4 -0
  58. package/dist/components/button/types.d.ts +29 -0
  59. package/dist/components/button/types.js +1 -0
  60. package/dist/components/card/card.css +115 -0
  61. package/dist/components/card/card.svelte +63 -0
  62. package/dist/components/card/card.svelte.d.ts +4 -0
  63. package/dist/components/card/types.d.ts +18 -0
  64. package/dist/components/card/types.js +1 -0
  65. package/dist/components/chip/chip.css +231 -0
  66. package/dist/components/chip/chip.svelte +131 -0
  67. package/dist/components/chip/chip.svelte.d.ts +4 -0
  68. package/dist/components/chip/types.d.ts +32 -0
  69. package/dist/components/chip/types.js +1 -0
  70. package/dist/components/dialog/dialog.css +136 -0
  71. package/dist/components/dialog/dialog.svelte +67 -0
  72. package/dist/components/dialog/dialog.svelte.d.ts +4 -0
  73. package/dist/components/dialog/types.d.ts +24 -0
  74. package/dist/components/dialog/types.js +1 -0
  75. package/dist/components/dropdown/dropdown.css +22 -0
  76. package/dist/components/dropdown/dropdown.svelte +116 -0
  77. package/dist/components/dropdown/dropdown.svelte.d.ts +4 -0
  78. package/dist/components/dropdown/dropdown.svelte.js +148 -0
  79. package/dist/components/dropdown/types.d.ts +26 -0
  80. package/dist/components/dropdown/types.js +1 -0
  81. package/dist/components/icon/icon.css +79 -0
  82. package/dist/components/icon/icon.svelte +49 -0
  83. package/dist/components/icon/icon.svelte.d.ts +4 -0
  84. package/dist/components/icon/types.d.ts +16 -0
  85. package/dist/components/icon/types.js +1 -0
  86. package/dist/components/index.d.ts +22 -0
  87. package/dist/components/index.js +23 -0
  88. package/dist/components/list/list.css +221 -0
  89. package/dist/components/list/list.svelte +44 -0
  90. package/dist/components/list/list.svelte.d.ts +4 -0
  91. package/dist/components/list/modules/list-item.svelte +76 -0
  92. package/dist/components/list/modules/list-item.svelte.d.ts +4 -0
  93. package/dist/components/list/types.d.ts +33 -0
  94. package/dist/components/list/types.js +1 -0
  95. package/dist/components/modal/modal.css +145 -0
  96. package/dist/components/modal/modal.svelte +113 -0
  97. package/dist/components/modal/modal.svelte.d.ts +4 -0
  98. package/dist/components/modal/types.d.ts +26 -0
  99. package/dist/components/modal/types.js +1 -0
  100. package/dist/components/popover/popover.css +22 -0
  101. package/dist/components/popover/popover.svelte +73 -0
  102. package/dist/components/popover/popover.svelte.d.ts +4 -0
  103. package/dist/components/popover/popover.svelte.js +134 -0
  104. package/dist/components/popover/types.d.ts +20 -0
  105. package/dist/components/popover/types.js +1 -0
  106. package/dist/components/separator/separator.css +46 -0
  107. package/dist/components/separator/separator.svelte +37 -0
  108. package/dist/components/separator/separator.svelte.d.ts +4 -0
  109. package/dist/components/separator/types.d.ts +11 -0
  110. package/dist/components/separator/types.js +1 -0
  111. package/dist/components/spacer/spacer.css +3 -0
  112. package/dist/components/spacer/spacer.svelte +7 -0
  113. package/dist/components/spacer/spacer.svelte.d.ts +4 -0
  114. package/dist/components/spacer/types.d.ts +4 -0
  115. package/dist/components/spacer/types.js +1 -0
  116. package/dist/components/textfield/textfield.css +305 -0
  117. package/dist/components/textfield/textfield.svelte +193 -0
  118. package/dist/components/textfield/textfield.svelte.d.ts +4 -0
  119. package/dist/components/textfield/types.d.ts +37 -0
  120. package/dist/components/textfield/types.js +1 -0
  121. package/dist/components/toolbar/toolbar.css +129 -0
  122. package/dist/components/toolbar/toolbar.svelte +47 -0
  123. package/dist/components/toolbar/toolbar.svelte.d.ts +4 -0
  124. package/dist/components/toolbar/types.d.ts +27 -0
  125. package/dist/components/toolbar/types.js +1 -0
  126. package/dist/components/tooltip/tooltip.css +124 -0
  127. package/dist/components/tooltip/tooltip.svelte +113 -0
  128. package/dist/components/tooltip/tooltip.svelte.d.ts +4 -0
  129. package/dist/components/tooltip/tooltip.svelte.js +131 -0
  130. package/dist/components/tooltip/types.d.ts +23 -0
  131. package/dist/components/tooltip/types.js +1 -0
  132. package/dist/index.d.ts +27 -1
  133. package/dist/index.js +27 -3
  134. package/dist/internal/assets.svelte.d.ts +8 -0
  135. package/dist/internal/assets.svelte.js +54 -0
  136. package/dist/internal/clickOutside.d.ts +9 -0
  137. package/dist/internal/clickOutside.js +34 -0
  138. package/dist/internal/config/presets.d.ts +108 -0
  139. package/dist/internal/config/presets.js +121 -0
  140. package/dist/internal/config/variables.d.ts +6 -0
  141. package/dist/internal/config/variables.js +6 -0
  142. package/dist/internal/core/formatter/component.d.ts +5 -0
  143. package/dist/internal/core/formatter/component.js +56 -0
  144. package/dist/internal/core/formatter/index.d.ts +4 -0
  145. package/dist/internal/core/formatter/index.js +26 -0
  146. package/dist/internal/core/formatter/styles.d.ts +4 -0
  147. package/dist/internal/core/formatter/styles.js +15 -0
  148. package/dist/internal/core/formatter/theme.d.ts +5 -0
  149. package/dist/internal/core/formatter/theme.js +20 -0
  150. package/dist/internal/core/formatter/typography.d.ts +5 -0
  151. package/dist/internal/core/formatter/typography.js +12 -0
  152. package/dist/internal/core/parser-config.d.ts +1 -0
  153. package/dist/internal/core/parser-config.js +24 -0
  154. package/dist/internal/deepMerge.d.ts +44 -0
  155. package/dist/internal/deepMerge.js +80 -0
  156. package/dist/internal/helpers/parser.d.ts +9 -0
  157. package/dist/internal/helpers/parser.js +70 -0
  158. package/dist/internal/index.d.ts +2 -0
  159. package/dist/internal/index.js +2 -0
  160. package/dist/internal/ripple.d.ts +12 -0
  161. package/dist/internal/ripple.js +93 -0
  162. package/dist/internal/scroll.d.ts +1 -0
  163. package/dist/internal/scroll.js +6 -0
  164. package/dist/internal/types/configuration.d.ts +40 -0
  165. package/dist/internal/types/configuration.js +1 -0
  166. package/dist/internal/types/index.d.ts +1 -0
  167. package/dist/internal/types/index.js +1 -0
  168. package/dist/internal/types.d.ts +13 -0
  169. package/dist/internal/unit.d.ts +1 -0
  170. package/dist/internal/unit.js +11 -0
  171. package/dist/labs/index.d.ts +4 -0
  172. package/dist/labs/index.js +5 -0
  173. package/dist/labs/my-component-style-global.svelte +6 -0
  174. package/dist/labs/my-component-style-global.svelte.d.ts +18 -0
  175. package/dist/labs/my-component-style-import.svelte +15 -0
  176. package/dist/labs/my-component-style-import.svelte.d.ts +18 -0
  177. package/dist/labs/my-component-style-mixed.svelte +23 -0
  178. package/dist/labs/my-component-style-mixed.svelte.d.ts +18 -0
  179. package/dist/labs/my-component.svelte +16 -0
  180. package/dist/labs/my-component.svelte.d.ts +18 -0
  181. package/dist/labs/style-mixed.css +7 -0
  182. package/dist/labs/style.css +7 -0
  183. package/dist/labs.css +25 -0
  184. package/dist/plugin/css.d.ts +1 -0
  185. package/dist/plugin/css.js +73 -0
  186. package/dist/plugin/preset-v2.d.ts +108 -0
  187. package/dist/plugin/preset-v2.js +126 -0
  188. package/dist/plugin/vitejs.d.ts +5 -1
  189. package/dist/plugin/vitejs.js +32 -3
  190. package/dist/preset.js +16 -4
  191. package/dist/stores/breakpoints.d.ts +6 -0
  192. package/dist/stores/breakpoints.js +14 -0
  193. package/dist/stores/components.d.ts +8 -0
  194. package/dist/stores/components.js +26 -0
  195. package/dist/stores/devices.d.ts +6 -0
  196. package/dist/stores/devices.js +9 -0
  197. package/dist/stores/index.d.ts +4 -0
  198. package/dist/stores/index.js +4 -0
  199. package/dist/stores/themes.d.ts +8 -0
  200. package/dist/stores/themes.js +34 -0
  201. package/dist/style/animation.css +62 -0
  202. package/dist/style/css.js +6 -3
  203. package/dist/style/normalize.css +2 -0
  204. package/dist/style/parser/color.js +15 -4
  205. package/dist/style/parser/device.js +31 -19
  206. package/dist/style/variable.css +12 -0
  207. package/dist/utils/convert.d.ts +1 -0
  208. package/dist/utils/convert.js +17 -0
  209. package/dist/utils/x11.d.ts +1 -1
  210. package/package.json +26 -4
@@ -0,0 +1,131 @@
1
+ import { innerWidth, innerHeight } from 'svelte/reactivity/window';
2
+ export function getPositionsTooltip() {
3
+ // state
4
+ const axis = $state({
5
+ x: 0,
6
+ y: 0,
7
+ location: null
8
+ });
9
+ return {
10
+ get values() {
11
+ return axis;
12
+ },
13
+ update(activator, element, location, centered, avoidCollisions) {
14
+ if (!activator || !element)
15
+ return;
16
+ const elementRect = element.getBoundingClientRect();
17
+ const activatorRect = activator.getBoundingClientRect();
18
+ const spacing = 6;
19
+ if (location === 'top' || location === 'bottom') {
20
+ if (avoidCollisions) {
21
+ if (location === 'top') {
22
+ if (activatorRect.y - (elementRect.height + spacing) < 0) {
23
+ axis.y = activatorRect.bottom + spacing;
24
+ axis.location = 'bottom';
25
+ }
26
+ else {
27
+ axis.y = activatorRect.top - (elementRect.height + spacing);
28
+ axis.location = 'top';
29
+ }
30
+ }
31
+ else {
32
+ if (activatorRect.y + activatorRect.height + (elementRect.height + spacing) >
33
+ innerHeight.current) {
34
+ axis.y = activatorRect.top - (elementRect.height + spacing);
35
+ axis.location = 'top';
36
+ }
37
+ else {
38
+ axis.y = activatorRect.bottom + spacing;
39
+ axis.location = 'bottom';
40
+ }
41
+ }
42
+ }
43
+ else {
44
+ if (location === 'top') {
45
+ axis.y = activatorRect.top - (elementRect.height + spacing);
46
+ axis.location = 'top';
47
+ }
48
+ else {
49
+ axis.y = activatorRect.bottom + spacing;
50
+ axis.location = 'bottom';
51
+ }
52
+ }
53
+ if (centered &&
54
+ activatorRect.left - (elementRect.width - activatorRect.width) / 2 > 0 &&
55
+ activatorRect.left + elementRect.width < innerWidth.current) {
56
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width) / 2;
57
+ }
58
+ else if (activatorRect.left + elementRect.width > innerWidth.current) {
59
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width);
60
+ }
61
+ else {
62
+ axis.x = activatorRect.left;
63
+ }
64
+ }
65
+ else if (location === 'left' || location === 'right') {
66
+ if (avoidCollisions) {
67
+ if (location === 'left' && !(activatorRect.left - elementRect.width < 0)) {
68
+ axis.x = activatorRect.left - (elementRect.width + spacing);
69
+ axis.location = 'left';
70
+ }
71
+ else {
72
+ if (activatorRect.left + activatorRect.width + elementRect.width + spacing >
73
+ innerWidth.current) {
74
+ axis.x = activatorRect.left - (elementRect.width + spacing);
75
+ axis.location = 'left';
76
+ }
77
+ else {
78
+ axis.x = activatorRect.left + activatorRect.width + spacing;
79
+ axis.location = 'right';
80
+ }
81
+ }
82
+ }
83
+ else {
84
+ if (location === 'left') {
85
+ axis.x = activatorRect.left - (elementRect.width + spacing);
86
+ axis.location = 'left';
87
+ }
88
+ else {
89
+ axis.x = activatorRect.left + activatorRect.width + spacing;
90
+ axis.location = 'right';
91
+ }
92
+ }
93
+ if (centered &&
94
+ activatorRect.top - (elementRect.height - activatorRect.height) / 2 > 0 &&
95
+ activatorRect.top + elementRect.height < innerHeight.current) {
96
+ axis.y = activatorRect.top - (elementRect.height - activatorRect.height) / 2;
97
+ }
98
+ else if (activatorRect.y + elementRect.height > innerHeight.current) {
99
+ axis.y = activatorRect.y - elementRect.height + activatorRect.height;
100
+ }
101
+ else {
102
+ axis.y = activatorRect.y;
103
+ }
104
+ }
105
+ else {
106
+ if (centered &&
107
+ activatorRect.left - (elementRect.width - activatorRect.width) / 2 > 0 &&
108
+ activatorRect.left + elementRect.width < innerWidth.current) {
109
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width) / 2;
110
+ }
111
+ else if (activatorRect.left + elementRect.width > innerWidth.current) {
112
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width);
113
+ }
114
+ else {
115
+ axis.x = activatorRect.left;
116
+ }
117
+ if (centered &&
118
+ activatorRect.top - (elementRect.height - activatorRect.height) / 2 > 0 &&
119
+ activatorRect.top + elementRect.height < innerHeight.current) {
120
+ axis.y = activatorRect.top - (elementRect.height - activatorRect.height) / 2;
121
+ }
122
+ else if (activatorRect.bottom + elementRect.height > innerHeight.current) {
123
+ axis.y = activatorRect.top - elementRect.height;
124
+ }
125
+ else {
126
+ axis.y = activatorRect.bottom;
127
+ }
128
+ }
129
+ }
130
+ };
131
+ }
@@ -0,0 +1,23 @@
1
+ import type { Component } from '../../internal/types.js';
2
+ import type { Snippet } from 'svelte';
3
+ export interface TooltipProps extends Component {
4
+ open?: boolean;
5
+ dark?: boolean;
6
+ light?: boolean;
7
+ rounded?: string;
8
+ label?: string;
9
+ location?: 'top' | 'bottom' | 'left' | 'right';
10
+ color?: string;
11
+ background?: string;
12
+ delayDuration?: number;
13
+ variant?: 'arrow';
14
+ density?: 'compact' | 'comfortable' | 'default';
15
+ disabled?: boolean;
16
+ avoidCollisions?: boolean;
17
+ tooltip?: Snippet;
18
+ }
19
+ export type PositionElement = {
20
+ x: number;
21
+ y: number;
22
+ location: string | null;
23
+ };
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -1 +1,27 @@
1
- export declare function helloWorld(): void;
1
+ interface Lapikit {
2
+ adapterCSS: string;
3
+ breakpoints: {
4
+ devices: {
5
+ [key: string]: string;
6
+ };
7
+ thresholds: {
8
+ [key: string]: number | string;
9
+ };
10
+ };
11
+ theme: {
12
+ defaultTheme: string;
13
+ themes: {
14
+ [key: string]: {
15
+ dark: boolean;
16
+ colors: {
17
+ [key: string]: string;
18
+ };
19
+ variables: {
20
+ [key: string]: string;
21
+ };
22
+ };
23
+ };
24
+ };
25
+ }
26
+ declare function createLapikit(lapikit: Lapikit): void;
27
+ export default createLapikit;
package/dist/index.js CHANGED
@@ -1,4 +1,28 @@
1
- // Reexport your entry components here
2
- export function helloWorld() {
3
- console.log('Hello world, this is lapikit!');
1
+ import { deepMerge } from './internal/deepMerge.js';
2
+ import { breakpoints } from './stores/breakpoints.js';
3
+ import { get } from 'svelte/store';
4
+ import { valueToPx } from './utils/convert.js';
5
+ import { devices } from './stores/devices.js';
6
+ function createLapikit(lapikit) {
7
+ console.log('Creating a new Lapikit instance...');
8
+ console.log('Options loaded:', lapikit);
9
+ if (lapikit?.breakpoints?.thresholds) {
10
+ const currentBreakpoints = get(breakpoints);
11
+ const breakpointMerged = deepMerge(currentBreakpoints, lapikit.breakpoints.thresholds);
12
+ const formattedBreakpoints = Object.fromEntries(Object.entries(breakpointMerged).map(([key, value]) => [key, valueToPx(value)]));
13
+ breakpoints.set(formattedBreakpoints);
14
+ console.log('Breakpoints found:', formattedBreakpoints);
15
+ }
16
+ if (lapikit?.breakpoints?.devices) {
17
+ const currentDevices = get(devices);
18
+ const currentBreakpoints = get(breakpoints);
19
+ const deviceMerged = deepMerge(currentDevices, lapikit.breakpoints.devices);
20
+ const formattedDevices = Object.fromEntries(Object.entries(deviceMerged).map(([key, deviceKey]) => {
21
+ const breakpointValue = currentBreakpoints[deviceKey];
22
+ return [key, valueToPx(breakpointValue)];
23
+ }));
24
+ devices.set(formattedDevices);
25
+ console.log('Devices found:', formattedDevices);
26
+ }
4
27
  }
28
+ export default createLapikit;
@@ -0,0 +1,8 @@
1
+ export declare function getAssets(): {
2
+ shape(params?: string): string | undefined;
3
+ className(key: string, type: string, value: string | boolean | Array<string> | {
4
+ [key: string]: string;
5
+ }): string | undefined;
6
+ color(color?: string): string | undefined;
7
+ unit(value?: string | number): string | undefined;
8
+ };
@@ -0,0 +1,54 @@
1
+ import { x11ColorNames } from '../utils/x11.js';
2
+ export function getAssets() {
3
+ return {
4
+ shape(params) {
5
+ if (params) {
6
+ if (params === 'none' || params == '0')
7
+ return '0';
8
+ return `var(--kit-radius-${params})`;
9
+ }
10
+ },
11
+ className(key, type, value) {
12
+ if (typeof value === 'string')
13
+ return `kit-${key}--${type}-${value}`;
14
+ else if (typeof value === 'boolean' && value)
15
+ return `kit-${key}--${type}`;
16
+ else if (typeof value === 'object') {
17
+ if (Array.isArray(value)) {
18
+ return value
19
+ .map((media) => `${media === '_default' ? '' : `${media}:`}kit--${type}`)
20
+ .join(' ');
21
+ }
22
+ else {
23
+ return Object.entries(value)
24
+ .map(([media, value]) => `${media === '_default' ? '' : `${media}:`}kit-${key}--${type}-${value}`)
25
+ .join(' ');
26
+ }
27
+ }
28
+ },
29
+ color(color) {
30
+ if (color) {
31
+ if (color.includes('#') ||
32
+ color.includes('rgb') ||
33
+ color.includes('rgba') ||
34
+ color.includes('oklch') ||
35
+ x11ColorNames.includes(color.toLowerCase()))
36
+ return color;
37
+ if (color.includes('transparent') || color.includes('inherit') || color.includes('initial'))
38
+ return color;
39
+ return `var(--kit-${color})`;
40
+ }
41
+ },
42
+ unit(value) {
43
+ if (typeof value === 'number')
44
+ return `${value}px`;
45
+ if (typeof value === 'string') {
46
+ const cleaned = value.trim();
47
+ const isOnlyNumericLike = /^[\d.,]+$/.test(cleaned);
48
+ if (isOnlyNumericLike)
49
+ return `${value}px`;
50
+ }
51
+ return value;
52
+ }
53
+ };
54
+ }
@@ -0,0 +1,9 @@
1
+ type ClickOutsideOptions = {
2
+ exclude?: (HTMLElement | PointerEvent | null)[];
3
+ onClose: () => void;
4
+ };
5
+ export declare function clickOutside(node: HTMLElement, options: ClickOutsideOptions): {
6
+ update(newOptions: ClickOutsideOptions): void;
7
+ destroy(): void;
8
+ };
9
+ export {};
@@ -0,0 +1,34 @@
1
+ export function clickOutside(node, options) {
2
+ let { exclude = [], onClose } = options;
3
+ function isTargetExcluded(target) {
4
+ return exclude.some((ex) => {
5
+ if (!ex)
6
+ return false;
7
+ if (ex instanceof HTMLElement) {
8
+ return ex.contains(target);
9
+ }
10
+ if (ex instanceof PointerEvent && ex.target instanceof Node) {
11
+ return ex.target.contains(target);
12
+ }
13
+ return false;
14
+ });
15
+ }
16
+ const handleClick = (event) => {
17
+ const target = event.target;
18
+ const isExcluded = isTargetExcluded(target);
19
+ const isInside = node.contains(target);
20
+ if (!isInside && !isExcluded) {
21
+ onClose();
22
+ }
23
+ };
24
+ document.addEventListener('click', handleClick, true);
25
+ return {
26
+ update(newOptions) {
27
+ exclude = newOptions.exclude || [];
28
+ onClose = newOptions.onClose;
29
+ },
30
+ destroy() {
31
+ document.removeEventListener('click', handleClick, true);
32
+ }
33
+ };
34
+ }
@@ -0,0 +1,108 @@
1
+ export declare const preset: {
2
+ breakpoints: {
3
+ devices: {
4
+ desktop: number;
5
+ tablet: number;
6
+ mobile: number;
7
+ };
8
+ thresholds: {
9
+ base: number;
10
+ xs: number;
11
+ sm: number;
12
+ md: number;
13
+ lg: number;
14
+ xl: number;
15
+ '2xl': number;
16
+ '3xl': number;
17
+ };
18
+ };
19
+ theme: {
20
+ defaultTheme: string;
21
+ themes: {
22
+ light: {
23
+ dark: boolean;
24
+ colors: {
25
+ blue: string;
26
+ green: string;
27
+ red: string;
28
+ yellow: string;
29
+ orange: string;
30
+ purple: string;
31
+ pink: string;
32
+ indigo: string;
33
+ cyan: string;
34
+ gray: string;
35
+ 'gray-2': string;
36
+ 'gray-3': string;
37
+ 'gray-4': string;
38
+ 'gray-5': string;
39
+ 'gray-6': string;
40
+ background: string;
41
+ 'secondary-background': string;
42
+ 'tertiary-background': string;
43
+ label: string;
44
+ 'secondary-label': string;
45
+ };
46
+ variables: {
47
+ info: string;
48
+ success: string;
49
+ error: string;
50
+ warning: string;
51
+ };
52
+ };
53
+ dark: {
54
+ dark: boolean;
55
+ colors: {
56
+ blue: string;
57
+ green: string;
58
+ red: string;
59
+ yellow: string;
60
+ orange: string;
61
+ purple: string;
62
+ pink: string;
63
+ indigo: string;
64
+ cyan: string;
65
+ gray: string;
66
+ 'gray-2': string;
67
+ 'gray-3': string;
68
+ 'gray-4': string;
69
+ 'gray-5': string;
70
+ 'gray-6': string;
71
+ background: string;
72
+ 'secondary-background': string;
73
+ 'tertiary-background': string;
74
+ label: string;
75
+ 'secondary-label': string;
76
+ };
77
+ variables: {
78
+ info: string;
79
+ success: string;
80
+ error: string;
81
+ warning: string;
82
+ };
83
+ };
84
+ };
85
+ };
86
+ typography: {
87
+ defaultTypography: string;
88
+ fonts: {
89
+ default: {
90
+ sans: string[];
91
+ mono: string[];
92
+ serif: string[];
93
+ };
94
+ };
95
+ };
96
+ styles: {
97
+ spacing: string;
98
+ shape: {
99
+ sm: string;
100
+ md: string;
101
+ lg: string;
102
+ xl: string;
103
+ '2xl': string;
104
+ '3xl': string;
105
+ full: string;
106
+ };
107
+ };
108
+ };
@@ -0,0 +1,121 @@
1
+ import { variables } from './variables.js';
2
+ export const preset = {
3
+ breakpoints: {
4
+ devices: {
5
+ desktop: 1024, //64rem (lg)
6
+ tablet: 768, //48rem (md)
7
+ mobile: 375 //28rem (sm)
8
+ },
9
+ thresholds: {
10
+ base: 0, // 0px
11
+ xs: 448, //28rem
12
+ sm: 640, //40rem
13
+ md: 768, //48rem
14
+ lg: 1024, //64rem
15
+ xl: 1280, //80rem
16
+ '2xl': 1536, //96rem
17
+ '3xl': 1792 //112rem
18
+ }
19
+ },
20
+ theme: {
21
+ defaultTheme: 'light',
22
+ themes: {
23
+ light: {
24
+ dark: false,
25
+ colors: {
26
+ blue: '#007AFF',
27
+ green: '#34C759',
28
+ red: '#FF3B30',
29
+ yellow: '#FFCC00',
30
+ orange: '#FF9500',
31
+ purple: '#AF52DE',
32
+ pink: '#FF2D55',
33
+ indigo: '#5856D6',
34
+ cyan: '#5AC8FA',
35
+ gray: '#8E8E93',
36
+ 'gray-2': '#AEAEB2',
37
+ 'gray-3': '#C7C7CC',
38
+ 'gray-4': '#D1D1D6',
39
+ 'gray-5': '#E5E5EA',
40
+ 'gray-6': '#F2F2F7',
41
+ background: '#FFFFFF',
42
+ 'secondary-background': '#F2F2F7',
43
+ 'tertiary-background': '#EFEFF4',
44
+ label: '#000000',
45
+ 'secondary-label': 'rgba(60,60,67,0.6)'
46
+ },
47
+ variables: variables
48
+ },
49
+ dark: {
50
+ dark: true,
51
+ colors: {
52
+ blue: '#0A84FF',
53
+ green: '#30D158',
54
+ red: '#FF453A',
55
+ yellow: '#FFD60A',
56
+ orange: '#FF9F0A',
57
+ purple: '#BF5AF2',
58
+ pink: '#FF375F',
59
+ indigo: '#5E5CE6',
60
+ cyan: '#64D2FF',
61
+ gray: '#8E8E93',
62
+ 'gray-2': '#636366',
63
+ 'gray-3': '#48484A',
64
+ 'gray-4': '#3A3A3C',
65
+ 'gray-5': '#2C2C2E',
66
+ 'gray-6': '#1C1C1E',
67
+ background: '#000000',
68
+ 'secondary-background': '#1C1C1E',
69
+ 'tertiary-background': '#2C2C2E',
70
+ label: '#FFFFFF',
71
+ 'secondary-label': 'rgba(235,235,245,0.6)'
72
+ },
73
+ variables: variables
74
+ }
75
+ }
76
+ },
77
+ typography: {
78
+ defaultTypography: 'default',
79
+ fonts: {
80
+ default: {
81
+ sans: [
82
+ 'system-ui',
83
+ '-apple-system',
84
+ 'BlinkMacSystemFont',
85
+ 'Segoe UI',
86
+ 'Roboto',
87
+ 'Helvetica Neue',
88
+ 'Arial',
89
+ 'sans-serif',
90
+ 'Apple Color Emoji',
91
+ 'Segoe UI Emoji',
92
+ 'Segoe UI Symbol'
93
+ ],
94
+ mono: [
95
+ 'SFMono-Regular',
96
+ 'ui-monospace',
97
+ 'SF Mono',
98
+ 'Menlo',
99
+ 'Monaco',
100
+ 'Consolas',
101
+ 'Liberation Mono',
102
+ 'Courier New',
103
+ 'monospace'
104
+ ],
105
+ serif: ['Merriweather', 'Georgia', 'Cambria', 'Times New Roman', 'Times', 'serif']
106
+ }
107
+ }
108
+ },
109
+ styles: {
110
+ spacing: '0.125rem', // 2px
111
+ shape: {
112
+ sm: '0.125rem', // 2px
113
+ md: '0.25rem', // 4px
114
+ lg: '0.5rem', // 8px
115
+ xl: '0.75rem', // 12px
116
+ '2xl': '1rem', // 16px
117
+ '3xl': '1.5rem', // 24px
118
+ full: '9999px' // 9999px
119
+ }
120
+ }
121
+ };
@@ -0,0 +1,6 @@
1
+ export declare const variables: {
2
+ info: string;
3
+ success: string;
4
+ error: string;
5
+ warning: string;
6
+ };
@@ -0,0 +1,6 @@
1
+ export const variables = {
2
+ info: 'var(--system-blue)',
3
+ success: 'var(--system-green)',
4
+ error: 'var(--system-red)',
5
+ warning: 'var(--system-yellow)'
6
+ };
@@ -0,0 +1,5 @@
1
+ export declare function componentFormatter({ breakpoints }: {
2
+ breakpoints: {
3
+ [key: string]: number | string;
4
+ };
5
+ }): void;
@@ -0,0 +1,56 @@
1
+ import { fileURLToPath } from 'url';
2
+ import { dirname } from 'path';
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import { parserCSSBreakpoints } from '../../helpers/parser.js';
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
8
+ export function componentFormatter({ breakpoints }) {
9
+ // load css component files (includes on components folders)
10
+ function loadCSSFiles(directory) {
11
+ fs.readdirSync(directory).forEach((File) => {
12
+ const absolutePath = path.join(directory, File);
13
+ if (fs.statSync(absolutePath).isDirectory())
14
+ return loadCSSFiles(absolutePath);
15
+ else if (absolutePath.endsWith('.css') && !absolutePath.includes('/_')) {
16
+ console.log(absolutePath);
17
+ let css = '';
18
+ const content = parserCSSBreakpoints(fs.readFileSync(absolutePath, 'utf8'));
19
+ for (const property in breakpoints) {
20
+ if (property !== 'base') {
21
+ const name = `.${/^\d/.test(property) ? `\\3${property}` : property}\\:`;
22
+ const value = typeof breakpoints[property] === 'number'
23
+ ? `${breakpoints[property]}px`
24
+ : breakpoints[property];
25
+ if (content.base !== '' || content.minmax !== '' || content.min !== '') {
26
+ css += `@media screen and (min-width: ${value}) {\n`;
27
+ if (content.base !== '')
28
+ css += content.base.replaceAll('[breakpoint]', name);
29
+ if (content.minmax !== '')
30
+ css += content.minmax.replaceAll('[breakpoint]', name);
31
+ if (content.min !== '')
32
+ css += content.min.replaceAll('[breakpoint]', name);
33
+ css += `}\n`;
34
+ }
35
+ if (content.max !== '' || content.all !== '') {
36
+ css += `@media screen and (max-width: ${value}) {\n`;
37
+ if (content.max !== '')
38
+ css += content.max.replaceAll('[breakpoint]', name);
39
+ if (content.all !== '')
40
+ css += content.all.replaceAll('[breakpoint]', name);
41
+ css += `}\n`;
42
+ }
43
+ }
44
+ else {
45
+ css += content.all.replaceAll('[breakpoint]', '.');
46
+ }
47
+ }
48
+ let formattedCSS = css;
49
+ formattedCSS = formattedCSS.trim().replace(/\n{3,}/g, '\n\n');
50
+ console.log(formattedCSS);
51
+ fs.writeFileSync(absolutePath, formattedCSS, 'utf8');
52
+ }
53
+ });
54
+ }
55
+ loadCSSFiles(path.resolve(__dirname, '../../../components'));
56
+ }
@@ -0,0 +1,4 @@
1
+ import type { DevConfiguration } from '../../types/index.js';
2
+ export declare function css(config: DevConfiguration): Promise<{
3
+ styles: string[];
4
+ }>;
@@ -0,0 +1,26 @@
1
+ import { preset } from '../../config/presets.js';
2
+ import { deepMerge } from '../../deepMerge.js';
3
+ import { componentFormatter } from './component.js';
4
+ import { themesFormatter } from './theme.js';
5
+ import { typographyFormatter } from './typography.js';
6
+ export async function css(config) {
7
+ // states
8
+ const defaultTheme = config?.theme?.defaultTheme || preset.theme.defaultTheme;
9
+ const defaultTypography = config?.typography?.defaultTypography || preset.typography.defaultTypography;
10
+ // formatter
11
+ const themes = themesFormatter({
12
+ themes: deepMerge(preset.theme.themes, config?.theme?.themes || {}),
13
+ defaultTheme
14
+ });
15
+ const typography = typographyFormatter({
16
+ typography: deepMerge(preset.typography.fonts, config?.typography?.fonts || {}),
17
+ defaultTypography
18
+ });
19
+ // components
20
+ componentFormatter({
21
+ breakpoints: deepMerge(preset.breakpoints.thresholds, config?.breakpoints?.thresholds || {})
22
+ });
23
+ return {
24
+ styles: [themes, typography]
25
+ };
26
+ }