dalila 1.8.2 → 1.8.4

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 (89) hide show
  1. package/dist/cli/routes-generator.js +1 -2
  2. package/dist/components/ui/dialog/index.d.ts +0 -8
  3. package/dist/components/ui/dialog/index.js +2 -41
  4. package/dist/components/ui/dialog/internal.d.ts +5 -0
  5. package/dist/{componentes/ui/dialog/index.js → components/ui/dialog/internal.js} +1 -23
  6. package/dist/components/ui/drawer/index.js +2 -2
  7. package/dist/components/ui/index.d.ts +1 -1
  8. package/dist/components/ui/index.js +1 -1
  9. package/dist/core/index.d.ts +1 -1
  10. package/dist/core/index.js +1 -1
  11. package/dist/core/query.js +9 -7
  12. package/dist/core/resource.d.ts +23 -171
  13. package/dist/core/resource.js +178 -15
  14. package/dist/form/index.d.ts +1 -1
  15. package/dist/form/index.js +1 -1
  16. package/dist/router/index.d.ts +1 -1
  17. package/dist/router/index.js +1 -1
  18. package/dist/runtime/bind.d.ts +10 -0
  19. package/dist/runtime/bind.js +382 -53
  20. package/package.json +1 -1
  21. package/dist/componentes/ui/accordion/index.d.ts +0 -2
  22. package/dist/componentes/ui/accordion/index.js +0 -114
  23. package/dist/componentes/ui/calendar/index.d.ts +0 -2
  24. package/dist/componentes/ui/calendar/index.js +0 -132
  25. package/dist/componentes/ui/combobox/index.d.ts +0 -2
  26. package/dist/componentes/ui/combobox/index.js +0 -161
  27. package/dist/componentes/ui/dialog/index.d.ts +0 -10
  28. package/dist/componentes/ui/drawer/index.d.ts +0 -2
  29. package/dist/componentes/ui/drawer/index.js +0 -41
  30. package/dist/componentes/ui/dropdown/index.d.ts +0 -2
  31. package/dist/componentes/ui/dropdown/index.js +0 -48
  32. package/dist/componentes/ui/dropzone/index.d.ts +0 -2
  33. package/dist/componentes/ui/dropzone/index.js +0 -92
  34. package/dist/componentes/ui/env.d.ts +0 -1
  35. package/dist/componentes/ui/env.js +0 -2
  36. package/dist/componentes/ui/index.d.ts +0 -13
  37. package/dist/componentes/ui/index.js +0 -12
  38. package/dist/componentes/ui/popover/index.d.ts +0 -2
  39. package/dist/componentes/ui/popover/index.js +0 -156
  40. package/dist/componentes/ui/runtime.d.ts +0 -20
  41. package/dist/componentes/ui/runtime.js +0 -421
  42. package/dist/componentes/ui/tabs/index.d.ts +0 -3
  43. package/dist/componentes/ui/tabs/index.js +0 -101
  44. package/dist/componentes/ui/toast/index.d.ts +0 -3
  45. package/dist/componentes/ui/toast/index.js +0 -115
  46. package/dist/componentes/ui/ui-types.d.ts +0 -175
  47. package/dist/componentes/ui/ui-types.js +0 -1
  48. package/dist/componentes/ui/validate.d.ts +0 -7
  49. package/dist/componentes/ui/validate.js +0 -71
  50. package/dist/core/store.d.ts +0 -130
  51. package/dist/core/store.js +0 -234
  52. package/dist/core/virtual.d.ts +0 -26
  53. package/dist/core/virtual.js +0 -277
  54. package/dist/core/watch-testing.d.ts +0 -13
  55. package/dist/core/watch-testing.js +0 -16
  56. package/dist/router/route.d.ts +0 -23
  57. package/dist/router/route.js +0 -48
  58. package/dist/simple.d.ts +0 -11
  59. package/dist/simple.js +0 -11
  60. package/dist/ui/accordion.d.ts +0 -2
  61. package/dist/ui/accordion.js +0 -114
  62. package/dist/ui/calendar.d.ts +0 -2
  63. package/dist/ui/calendar.js +0 -132
  64. package/dist/ui/combobox.d.ts +0 -2
  65. package/dist/ui/combobox.js +0 -161
  66. package/dist/ui/dialog.d.ts +0 -10
  67. package/dist/ui/dialog.js +0 -54
  68. package/dist/ui/drawer.d.ts +0 -2
  69. package/dist/ui/drawer.js +0 -41
  70. package/dist/ui/dropdown.d.ts +0 -2
  71. package/dist/ui/dropdown.js +0 -48
  72. package/dist/ui/dropzone.d.ts +0 -2
  73. package/dist/ui/dropzone.js +0 -92
  74. package/dist/ui/env.d.ts +0 -1
  75. package/dist/ui/env.js +0 -2
  76. package/dist/ui/index.d.ts +0 -13
  77. package/dist/ui/index.js +0 -12
  78. package/dist/ui/popover.d.ts +0 -2
  79. package/dist/ui/popover.js +0 -156
  80. package/dist/ui/runtime.d.ts +0 -20
  81. package/dist/ui/runtime.js +0 -421
  82. package/dist/ui/tabs.d.ts +0 -3
  83. package/dist/ui/tabs.js +0 -101
  84. package/dist/ui/toast.d.ts +0 -3
  85. package/dist/ui/toast.js +0 -115
  86. package/dist/ui/ui-types.d.ts +0 -175
  87. package/dist/ui/ui-types.js +0 -1
  88. package/dist/ui/validate.d.ts +0 -7
  89. package/dist/ui/validate.js +0 -71
@@ -1,234 +0,0 @@
1
- /**
2
- * Global Store - Matar necessidade de Zustand
3
- *
4
- * createStore() cria um objeto reativo global que:
5
- * - Não precisa de scope
6
- * - É singleton por padrão
7
- * - Suporta computed properties
8
- * - Suporta actions
9
- * - Totalmente type-safe
10
- */
11
- import { signal, computed } from './signal.js';
12
- import { batch } from './scheduler.js';
13
- /**
14
- * Create a global reactive store (Zustand-like but better)
15
- *
16
- * @example
17
- * ```typescript
18
- * const useCounter = createStore({
19
- * count: 0,
20
- * increment() {
21
- * this.count++;
22
- * },
23
- * decrement() {
24
- * this.count--;
25
- * }
26
- * });
27
- *
28
- * // Use anywhere (no scope needed!)
29
- * console.log(useCounter.count()); // 0
30
- * useCounter.increment();
31
- * console.log(useCounter.count()); // 1
32
- *
33
- * // Reactive
34
- * effect(() => {
35
- * console.log('Count:', useCounter.count());
36
- * });
37
- * ```
38
- */
39
- export function createStore(initialState) {
40
- const stateSignals = new Map();
41
- const initialStateCopy = { ...initialState };
42
- const subscribers = new Set();
43
- // Separate actions from state
44
- const actions = {};
45
- const stateKeys = [];
46
- for (const [key, value] of Object.entries(initialState)) {
47
- if (typeof value === 'function') {
48
- actions[key] = value;
49
- }
50
- else {
51
- stateKeys.push(key);
52
- stateSignals.set(key, signal(value));
53
- }
54
- }
55
- // Notify subscribers on any state change
56
- const notifySubscribers = () => {
57
- const currentState = getState();
58
- subscribers.forEach((fn) => fn(currentState));
59
- };
60
- // Proxy to intercept state access in actions
61
- const stateProxy = new Proxy({}, {
62
- get(_target, prop) {
63
- const sig = stateSignals.get(prop);
64
- if (sig)
65
- return sig();
66
- if (prop in actions)
67
- return actions[prop];
68
- return undefined;
69
- },
70
- set(_target, prop, value) {
71
- const sig = stateSignals.get(prop);
72
- if (sig) {
73
- sig.set(value);
74
- notifySubscribers();
75
- return true;
76
- }
77
- return false;
78
- },
79
- });
80
- // Bind actions to proxy (so `this` works)
81
- const boundActions = {};
82
- for (const [key, fn] of Object.entries(actions)) {
83
- boundActions[key] = fn.bind(stateProxy);
84
- }
85
- function getState() {
86
- const state = {};
87
- for (const key of stateKeys) {
88
- state[key] = stateSignals.get(key)();
89
- }
90
- return state;
91
- }
92
- function setState(partial) {
93
- const updates = typeof partial === 'function' ? partial(getState()) : partial;
94
- batch(() => {
95
- for (const [key, value] of Object.entries(updates)) {
96
- const sig = stateSignals.get(key);
97
- if (sig) {
98
- sig.set(value);
99
- }
100
- }
101
- notifySubscribers();
102
- });
103
- }
104
- function reset() {
105
- batch(() => {
106
- for (const [key, value] of Object.entries(initialStateCopy)) {
107
- if (typeof value !== 'function') {
108
- const sig = stateSignals.get(key);
109
- if (sig) {
110
- sig.set(value);
111
- }
112
- }
113
- }
114
- notifySubscribers();
115
- });
116
- }
117
- function subscribe(fn) {
118
- subscribers.add(fn);
119
- return () => subscribers.delete(fn);
120
- }
121
- // Build store object
122
- const store = {
123
- ...boundActions,
124
- subscribe,
125
- getState,
126
- setState,
127
- reset,
128
- };
129
- // Add getters for state
130
- for (const key of stateKeys) {
131
- store[key] = () => stateSignals.get(key)();
132
- }
133
- return store;
134
- }
135
- /**
136
- * Create a computed store (derived from other stores)
137
- *
138
- * @example
139
- * ```typescript
140
- * const todos = createStore({
141
- * items: [{ done: false }, { done: true }]
142
- * });
143
- *
144
- * const stats = createComputedStore(() => ({
145
- * total: todos.items().length,
146
- * completed: todos.items().filter(t => t.done).length
147
- * }));
148
- *
149
- * console.log(stats.total()); // 2
150
- * console.log(stats.completed()); // 1
151
- * ```
152
- */
153
- export function createComputedStore(compute) {
154
- const computedValues = new Map();
155
- // Run once to get keys
156
- const initial = compute();
157
- for (const key of Object.keys(initial)) {
158
- computedValues.set(key, computed(() => compute()[key]));
159
- }
160
- const store = {};
161
- for (const [key, sig] of computedValues) {
162
- store[key] = () => sig();
163
- }
164
- return store;
165
- }
166
- /**
167
- * Persist store to localStorage
168
- *
169
- * @example
170
- * ```typescript
171
- * const settings = createStore({
172
- * theme: 'dark',
173
- * language: 'en'
174
- * });
175
- *
176
- * persistStore(settings, 'app-settings');
177
- * // Auto-saves on change, auto-loads on init
178
- * ```
179
- */
180
- export function persistStore(store, key, options = {}) {
181
- const storage = options.storage || localStorage;
182
- const serialize = options.serialize || JSON.stringify;
183
- const deserialize = options.deserialize || JSON.parse;
184
- // Load initial state
185
- try {
186
- const saved = storage.getItem(key);
187
- if (saved) {
188
- const parsed = deserialize(saved);
189
- store.setState(parsed);
190
- }
191
- }
192
- catch (err) {
193
- console.warn(`Failed to load persisted store "${key}":`, err);
194
- }
195
- // Save on change
196
- const unsubscribe = store.subscribe((state) => {
197
- try {
198
- storage.setItem(key, serialize(state));
199
- }
200
- catch (err) {
201
- console.warn(`Failed to persist store "${key}":`, err);
202
- }
203
- });
204
- return unsubscribe;
205
- }
206
- /**
207
- * Create a store slice (like Redux Toolkit)
208
- *
209
- * @example
210
- * ```typescript
211
- * const auth = createStoreSlice('auth', {
212
- * user: null,
213
- * login(user) {
214
- * this.user = user;
215
- * },
216
- * logout() {
217
- * this.user = null;
218
- * }
219
- * });
220
- *
221
- * const app = combineStores({ auth, theme, router });
222
- * ```
223
- */
224
- export function createStoreSlice(name, initialState) {
225
- const store = createStore(initialState);
226
- store._name = name;
227
- return store;
228
- }
229
- /**
230
- * Combine multiple store slices into one
231
- */
232
- export function combineStores(slices) {
233
- return slices;
234
- }
@@ -1,26 +0,0 @@
1
- export declare function createVirtualList<T>(items: () => T[], itemHeight: number | ((item: T, index: number) => number), renderItem: (item: T, index: number) => HTMLElement, options: {
2
- container: HTMLElement;
3
- bufferSize?: number;
4
- keyFn?: (item: T) => string;
5
- }): void;
6
- export declare function createSimpleVirtualList<T>(items: () => T[], itemHeight: number, renderItem: (item: T, index: number) => HTMLElement, container: HTMLElement, bufferSize?: number): void;
7
- export declare function createVirtualTable<T>(data: () => T[], columns: {
8
- key: keyof T;
9
- header: string;
10
- width: string;
11
- }[], renderCell: (item: T, column: {
12
- key: keyof T;
13
- header: string;
14
- width: string;
15
- }, index: number) => HTMLElement, container: HTMLElement, rowHeight?: number, bufferSize?: number): void;
16
- export declare function createInfiniteScroll<T>(fetchFn: (offset: number, limit: number) => Promise<T[]>, renderItem: (item: T, index: number) => HTMLElement, container: HTMLElement, options?: {
17
- itemHeight?: number;
18
- bufferSize?: number;
19
- initialLoad?: number;
20
- loadMoreThreshold?: number;
21
- }): {
22
- items: () => T[];
23
- loading: () => boolean;
24
- error: () => Error | null;
25
- refresh: () => Promise<void>;
26
- };
@@ -1,277 +0,0 @@
1
- import { effect, signal } from './signal.js';
2
- import { measure, mutate } from './scheduler.js';
3
- import { getCurrentScope } from './scope.js';
4
- // Experimental: virtualized list rendering API.
5
- export function createVirtualList(items, itemHeight, renderItem, options) {
6
- const container = options.container;
7
- const bufferSize = options.bufferSize || 3;
8
- const keyFn = options.keyFn || ((item, index) => index.toString());
9
- let visibleItems = [];
10
- let allItems = [];
11
- let scrollTop = 0;
12
- let containerHeight = 0;
13
- let totalHeight = 0;
14
- let itemHeights = [];
15
- const contentContainer = document.createElement('div');
16
- container.appendChild(contentContainer);
17
- // Calculate item height
18
- const getItemHeight = (item, index) => {
19
- if (typeof itemHeight === 'function') {
20
- return itemHeight(item, index);
21
- }
22
- return itemHeight;
23
- };
24
- // Update item heights and total height
25
- const updateItemHeights = () => {
26
- itemHeights = allItems.map((item, index) => getItemHeight(item, index));
27
- totalHeight = itemHeights.reduce((sum, height) => sum + height, 0);
28
- };
29
- // Calculate visible range
30
- const calculateVisibleRange = () => {
31
- const startIndex = Math.max(0, Math.floor(scrollTop / averageItemHeight()) - bufferSize);
32
- const endIndex = Math.min(allItems.length - 1, Math.ceil((scrollTop + containerHeight) / averageItemHeight()) + bufferSize);
33
- return { startIndex, endIndex };
34
- };
35
- // Calculate average item height for estimation
36
- const averageItemHeight = () => {
37
- if (itemHeights.length === 0)
38
- return itemHeight instanceof Function ? 50 : itemHeight;
39
- return itemHeights.reduce((sum, height) => sum + height, 0) / itemHeights.length;
40
- };
41
- // Render visible items
42
- const renderVisibleItems = () => {
43
- measure(() => {
44
- const { startIndex, endIndex } = calculateVisibleRange();
45
- // Remove items that are no longer visible
46
- visibleItems.forEach(item => {
47
- if (item.index < startIndex || item.index > endIndex) {
48
- if (item.element.parentNode) {
49
- item.element.parentNode.removeChild(item.element);
50
- }
51
- }
52
- });
53
- // Filter visible items
54
- visibleItems = visibleItems.filter(item => item.index >= startIndex && item.index <= endIndex);
55
- // Add new visible items
56
- for (let i = startIndex; i <= endIndex; i++) {
57
- const existingItem = visibleItems.find(item => item.index === i);
58
- if (!existingItem) {
59
- const item = allItems[i];
60
- const element = renderItem(item, i);
61
- const height = getItemHeight(item, i);
62
- // Calculate position
63
- const top = itemHeights.slice(0, i).reduce((sum, h) => sum + h, 0);
64
- // Style the element
65
- element.style.position = 'absolute';
66
- element.style.top = `${top}px`;
67
- element.style.height = `${height}px`;
68
- element.style.width = '100%';
69
- element.setAttribute('data-key', keyFn(item, i));
70
- contentContainer.appendChild(element);
71
- visibleItems.push({
72
- index: i,
73
- item,
74
- top,
75
- height,
76
- element
77
- });
78
- }
79
- }
80
- });
81
- };
82
- // Update container and scroll position
83
- const updateContainer = () => {
84
- mutate(() => {
85
- if (!container.style.position || container.style.position === 'static') {
86
- container.style.position = 'relative';
87
- }
88
- container.style.overflow = 'auto';
89
- contentContainer.style.position = 'relative';
90
- contentContainer.style.height = `${totalHeight}px`;
91
- contentContainer.style.width = '100%';
92
- });
93
- };
94
- // Handle scroll events (rAF throttled)
95
- let scrollRafId = null;
96
- const handleScroll = () => {
97
- if (scrollRafId !== null)
98
- return;
99
- scrollRafId = requestAnimationFrame(() => {
100
- scrollRafId = null;
101
- scrollTop = container.scrollTop;
102
- containerHeight = container.clientHeight;
103
- renderVisibleItems();
104
- });
105
- };
106
- // Initialize
107
- effect(() => {
108
- allItems = items();
109
- updateItemHeights();
110
- updateContainer();
111
- renderVisibleItems();
112
- });
113
- // Set up scroll listener
114
- container.addEventListener('scroll', handleScroll);
115
- // Initial render
116
- containerHeight = container.clientHeight;
117
- renderVisibleItems();
118
- // Cleanup
119
- const scope = getCurrentScope();
120
- if (scope) {
121
- scope.onCleanup(() => {
122
- container.removeEventListener('scroll', handleScroll);
123
- if (scrollRafId !== null)
124
- cancelAnimationFrame(scrollRafId);
125
- contentContainer.innerHTML = '';
126
- if (contentContainer.parentNode) {
127
- contentContainer.parentNode.removeChild(contentContainer);
128
- }
129
- });
130
- }
131
- }
132
- // Simplified virtual list for fixed height items
133
- export function createSimpleVirtualList(items, itemHeight, renderItem, container, bufferSize = 3) {
134
- createVirtualList(items, itemHeight, renderItem, { container, bufferSize });
135
- }
136
- // Virtual table implementation
137
- export function createVirtualTable(data, columns, renderCell, container, rowHeight = 50, bufferSize = 3) {
138
- const headerHeight = 40;
139
- const totalWidth = columns.reduce((sum, col) => sum + parseInt(col.width), 0);
140
- // Create header
141
- const header = document.createElement('div');
142
- header.style.position = 'absolute';
143
- header.style.top = '0';
144
- header.style.left = '0';
145
- header.style.width = `${totalWidth}px`;
146
- header.style.height = `${headerHeight}px`;
147
- header.style.display = 'flex';
148
- header.style.backgroundColor = '#f5f5f5';
149
- header.style.zIndex = '10';
150
- columns.forEach(col => {
151
- const headerCell = document.createElement('div');
152
- headerCell.textContent = col.header;
153
- headerCell.style.width = col.width;
154
- headerCell.style.height = `${headerHeight}px`;
155
- headerCell.style.display = 'flex';
156
- headerCell.style.alignItems = 'center';
157
- headerCell.style.padding = '0 8px';
158
- headerCell.style.boxSizing = 'border-box';
159
- headerCell.style.borderRight = '1px solid #ddd';
160
- header.appendChild(headerCell);
161
- });
162
- container.appendChild(header);
163
- // Create scrollable content area
164
- const contentContainer = document.createElement('div');
165
- contentContainer.style.position = 'absolute';
166
- contentContainer.style.top = `${headerHeight}px`;
167
- contentContainer.style.left = '0';
168
- contentContainer.style.width = `${totalWidth}px`;
169
- contentContainer.style.height = `calc(100% - ${headerHeight}px)`;
170
- contentContainer.style.overflow = 'auto';
171
- container.appendChild(contentContainer);
172
- container.style.position = 'relative';
173
- container.style.height = '100%';
174
- container.style.width = `${totalWidth}px`;
175
- // Render rows
176
- createVirtualList(data, rowHeight, (item, index) => {
177
- const row = document.createElement('div');
178
- row.style.display = 'flex';
179
- row.style.width = '100%';
180
- row.style.height = `${rowHeight}px`;
181
- row.style.borderBottom = '1px solid #eee';
182
- columns.forEach(col => {
183
- const cell = renderCell(item, col, index);
184
- cell.style.width = col.width;
185
- cell.style.height = `${rowHeight}px`;
186
- cell.style.display = 'flex';
187
- cell.style.alignItems = 'center';
188
- cell.style.padding = '0 8px';
189
- cell.style.boxSizing = 'border-box';
190
- cell.style.borderRight = '1px solid #ddd';
191
- row.appendChild(cell);
192
- });
193
- return row;
194
- }, {
195
- container: contentContainer,
196
- bufferSize,
197
- keyFn: (item) => JSON.stringify(item)
198
- });
199
- }
200
- // Infinite scroll implementation
201
- export function createInfiniteScroll(fetchFn, renderItem, container, options = {}) {
202
- const itemHeight = options.itemHeight || 100;
203
- const bufferSize = options.bufferSize || 3;
204
- const initialLoad = options.initialLoad || 20;
205
- const loadMoreThreshold = options.loadMoreThreshold || 5;
206
- const items = signal([]);
207
- const loading = signal(false);
208
- const error = signal(null);
209
- const offset = signal(0);
210
- const hasMore = signal(true);
211
- let isLoading = false;
212
- let allItems = [];
213
- async function loadMore() {
214
- if (isLoading || !hasMore())
215
- return;
216
- isLoading = true;
217
- loading.set(true);
218
- error.set(null);
219
- try {
220
- const newItems = await fetchFn(offset(), initialLoad);
221
- if (newItems.length === 0) {
222
- hasMore.set(false);
223
- }
224
- else {
225
- allItems = [...allItems, ...newItems];
226
- items.set(allItems);
227
- offset.set(offset() + newItems.length);
228
- }
229
- }
230
- catch (err) {
231
- error.set(err instanceof Error ? err : new Error(String(err)));
232
- }
233
- finally {
234
- isLoading = false;
235
- loading.set(false);
236
- }
237
- }
238
- async function refresh() {
239
- offset.set(0);
240
- hasMore.set(true);
241
- allItems = [];
242
- items.set([]);
243
- await loadMore();
244
- }
245
- // Initial load
246
- effect(() => {
247
- loadMore();
248
- });
249
- // Set up scroll listener for infinite scroll
250
- container.addEventListener('scroll', () => {
251
- const scrollTop = container.scrollTop;
252
- const scrollHeight = container.scrollHeight;
253
- const clientHeight = container.clientHeight;
254
- if (scrollHeight - (scrollTop + clientHeight) < loadMoreThreshold * itemHeight) {
255
- loadMore();
256
- }
257
- });
258
- // Render items
259
- createVirtualList(items, itemHeight, renderItem, {
260
- container,
261
- bufferSize,
262
- keyFn: (item) => `${JSON.stringify(item)}`
263
- });
264
- // Cleanup
265
- const scope = getCurrentScope();
266
- if (scope) {
267
- scope.onCleanup(() => {
268
- container.innerHTML = '';
269
- });
270
- }
271
- return {
272
- items: () => items(),
273
- loading: () => loading(),
274
- error: () => error(),
275
- refresh
276
- };
277
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * Testing utilities for watch.ts
3
- *
4
- * This file is NOT exported in the public API (src/index.ts).
5
- * It should only be imported directly by test files.
6
- *
7
- * @internal
8
- */
9
- /**
10
- * Reset all warning flags to their initial state.
11
- * Use this in tests to ensure deterministic warning behavior.
12
- */
13
- export declare function resetWarnings(): void;
@@ -1,16 +0,0 @@
1
- /**
2
- * Testing utilities for watch.ts
3
- *
4
- * This file is NOT exported in the public API (src/index.ts).
5
- * It should only be imported directly by test files.
6
- *
7
- * @internal
8
- */
9
- import { __resetWarningsForTests } from './watch.js';
10
- /**
11
- * Reset all warning flags to their initial state.
12
- * Use this in tests to ensure deterministic warning behavior.
13
- */
14
- export function resetWarnings() {
15
- __resetWarningsForTests();
16
- }
@@ -1,23 +0,0 @@
1
- export interface RouteDef {
2
- path: string;
3
- view: () => Node | Node[];
4
- children?: RouteDef[];
5
- loader?: (route: RouteState) => Promise<any>;
6
- beforeEnter?: (to: RouteState, from: RouteState) => boolean | Promise<boolean>;
7
- afterLeave?: (from: RouteState, to: RouteState) => void | Promise<void>;
8
- }
9
- export interface RouteState {
10
- path: string;
11
- params: Record<string, string>;
12
- query: URLSearchParams;
13
- hash: string;
14
- signal?: AbortSignal;
15
- }
16
- export interface RouteMatch {
17
- route: RouteDef;
18
- params: Record<string, string>;
19
- query: URLSearchParams;
20
- hash: string;
21
- }
22
- export declare function matchRoute(path: string, routeDef: RouteDef): RouteMatch | null;
23
- export declare function findRoute(path: string, routes: RouteDef[]): RouteMatch | null;
@@ -1,48 +0,0 @@
1
- function parsePath(path) {
2
- const paramNames = [];
3
- const pattern = path
4
- .replace(/:([^\/]+)/g, (_, paramName) => {
5
- paramNames.push(paramName);
6
- return '([^/]+)';
7
- })
8
- .replace(/\*/g, '.*');
9
- return {
10
- pattern: new RegExp(`^${pattern}$`),
11
- paramNames
12
- };
13
- }
14
- export function matchRoute(path, routeDef) {
15
- const { pattern, paramNames } = parsePath(routeDef.path);
16
- const match = path.match(pattern);
17
- if (!match) {
18
- return null;
19
- }
20
- const params = {};
21
- paramNames.forEach((name, index) => {
22
- params[name] = match[index + 1];
23
- });
24
- const url = new URL(path, 'http://localhost');
25
- const query = url.searchParams;
26
- const hash = url.hash.slice(1); // Remove the #
27
- return {
28
- route: routeDef,
29
- params,
30
- query,
31
- hash
32
- };
33
- }
34
- export function findRoute(path, routes) {
35
- for (const route of routes) {
36
- const match = matchRoute(path, route);
37
- if (match) {
38
- return match;
39
- }
40
- if (route.children) {
41
- const childMatch = findRoute(path, route.children);
42
- if (childMatch) {
43
- return childMatch;
44
- }
45
- }
46
- }
47
- return null;
48
- }
package/dist/simple.d.ts DELETED
@@ -1,11 +0,0 @@
1
- /**
2
- * dalila/simple - Simplified API
3
- *
4
- * Just the essentials:
5
- * - Global store (no Zustand needed)
6
- * - Auto-scope context (menos verboso)
7
- * - Core reactivity primitives
8
- *
9
- * Philosophy: Use HTML templates (via dev-server), not hyperscript.
10
- */
11
- export * from './core/index.js';
package/dist/simple.js DELETED
@@ -1,11 +0,0 @@
1
- /**
2
- * dalila/simple - Simplified API
3
- *
4
- * Just the essentials:
5
- * - Global store (no Zustand needed)
6
- * - Auto-scope context (menos verboso)
7
- * - Core reactivity primitives
8
- *
9
- * Philosophy: Use HTML templates (via dev-server), not hyperscript.
10
- */
11
- export * from './core/index.js';
@@ -1,2 +0,0 @@
1
- import type { Accordion, AccordionOptions } from "./ui-types.js";
2
- export declare function createAccordion(options?: AccordionOptions): Accordion;