proto-daisy-ui 0.0.2
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.
- package/LICENSE +21 -0
- package/README.md +10 -0
- package/dist/cjs/dealers-a8306eb8.js +15 -0
- package/dist/cjs/index-b1631310.js +1219 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/cjs/proto-button-d349703f.js +9 -0
- package/dist/cjs/proto-daisy-ui.cjs.entry.js +25 -0
- package/dist/cjs/proto-daisy-ui.cjs.js +19 -0
- package/dist/cjs/proto-demo.cjs.entry.js +20 -0
- package/dist/cjs/proto-hero.cjs.entry.js +21 -0
- package/dist/cjs/proto-home.cjs.entry.js +24 -0
- package/dist/cjs/proto-list.cjs.entry.js +58 -0
- package/dist/cjs/proto-shell.cjs.entry.js +120 -0
- package/dist/cjs/store-74bb495b.js +332 -0
- package/dist/collection/collection-manifest.json +17 -0
- package/dist/collection/components/functional/index.js +1 -0
- package/dist/collection/components/functional/proto-button.js +6 -0
- package/dist/collection/components/proto-daisy-ui/proto-daisy-ui.css +2023 -0
- package/dist/collection/components/proto-daisy-ui/proto-daisy-ui.js +20 -0
- package/dist/collection/components/proto-demo/proto-demo.css +0 -0
- package/dist/collection/components/proto-demo/proto-demo.js +14 -0
- package/dist/collection/components/proto-hero/proto-hero.css +3 -0
- package/dist/collection/components/proto-hero/proto-hero.js +43 -0
- package/dist/collection/components/proto-home/proto-home.css +0 -0
- package/dist/collection/components/proto-home/proto-home.js +26 -0
- package/dist/collection/components/proto-list/proto-list.css +0 -0
- package/dist/collection/components/proto-list/proto-list.js +64 -0
- package/dist/collection/components/proto-shell/proto-footer.js +20 -0
- package/dist/collection/components/proto-shell/proto-header.js +81 -0
- package/dist/collection/components/proto-shell/proto-shell.css +3 -0
- package/dist/collection/components/proto-shell/proto-shell.js +47 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/bag.js +23 -0
- package/dist/collection/utils/dealers.js +13 -0
- package/dist/collection/utils/index.js +5 -0
- package/dist/collection/utils/store.js +115 -0
- package/dist/collection/utils/tw-version.js +4 -0
- package/dist/collection/utils/types.js +1 -0
- package/dist/components/dealers.js +13 -0
- package/dist/components/index.d.ts +27 -0
- package/dist/components/index.js +7 -0
- package/dist/components/proto-button.js +7 -0
- package/dist/components/proto-daisy-ui.d.ts +11 -0
- package/dist/components/proto-daisy-ui.js +39 -0
- package/dist/components/proto-demo.d.ts +11 -0
- package/dist/components/proto-demo.js +33 -0
- package/dist/components/proto-hero.d.ts +11 -0
- package/dist/components/proto-hero.js +36 -0
- package/dist/components/proto-home.d.ts +11 -0
- package/dist/components/proto-home.js +37 -0
- package/dist/components/proto-list.d.ts +11 -0
- package/dist/components/proto-list.js +71 -0
- package/dist/components/proto-shell.d.ts +11 -0
- package/dist/components/proto-shell.js +135 -0
- package/dist/components/store.js +329 -0
- package/dist/esm/dealers-752f9914.js +13 -0
- package/dist/esm/index-832d1e38.js +1192 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/proto-button-c929a8fb.js +7 -0
- package/dist/esm/proto-daisy-ui.entry.js +21 -0
- package/dist/esm/proto-daisy-ui.js +17 -0
- package/dist/esm/proto-demo.entry.js +16 -0
- package/dist/esm/proto-hero.entry.js +17 -0
- package/dist/esm/proto-home.entry.js +20 -0
- package/dist/esm/proto-list.entry.js +54 -0
- package/dist/esm/proto-shell.entry.js +116 -0
- package/dist/esm/store-6cbf6338.js +329 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/proto-daisy-ui/index.esm.js +0 -0
- package/dist/proto-daisy-ui/p-0cbc124a.js +1 -0
- package/dist/proto-daisy-ui/p-4c1c4093.entry.js +1 -0
- package/dist/proto-daisy-ui/p-78473e80.js +1 -0
- package/dist/proto-daisy-ui/p-82c6ae5e.entry.js +1 -0
- package/dist/proto-daisy-ui/p-98b063cb.js +1 -0
- package/dist/proto-daisy-ui/p-bba460f2.entry.js +1 -0
- package/dist/proto-daisy-ui/p-d7d5a047.entry.js +1 -0
- package/dist/proto-daisy-ui/p-e274e36c.entry.js +1 -0
- package/dist/proto-daisy-ui/p-eeb6284e.entry.js +1 -0
- package/dist/proto-daisy-ui/p-f445bcf9.js +2 -0
- package/dist/proto-daisy-ui/proto-daisy-ui.esm.js +1 -0
- package/dist/types/components/functional/index.d.ts +1 -0
- package/dist/types/components/functional/proto-button.d.ts +4 -0
- package/dist/types/components/proto-daisy-ui/proto-daisy-ui.d.ts +4 -0
- package/dist/types/components/proto-demo/proto-demo.d.ts +3 -0
- package/dist/types/components/proto-hero/proto-hero.d.ts +4 -0
- package/dist/types/components/proto-home/proto-home.d.ts +3 -0
- package/dist/types/components/proto-list/proto-list.d.ts +3 -0
- package/dist/types/components/proto-shell/proto-footer.d.ts +4 -0
- package/dist/types/components/proto-shell/proto-header.d.ts +4 -0
- package/dist/types/components/proto-shell/proto-shell.d.ts +4 -0
- package/dist/types/components.d.ts +106 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1565 -0
- package/dist/types/utils/bag.d.ts +10 -0
- package/dist/types/utils/dealers.d.ts +6 -0
- package/dist/types/utils/index.d.ts +5 -0
- package/dist/types/utils/store.d.ts +12 -0
- package/dist/types/utils/tw-version.d.ts +3 -0
- package/dist/types/utils/types.d.ts +8 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +10 -0
- package/package.json +53 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { getRenderingRef, forceUpdate } from '@stencil/core/internal/client';
|
|
2
|
+
|
|
3
|
+
const KEY = 'proto-daisy-ui';
|
|
4
|
+
const LOGIN = 'login';
|
|
5
|
+
const MFE = 'mfe';
|
|
6
|
+
const PICK = 'pick';
|
|
7
|
+
const THEME = 'theme';
|
|
8
|
+
// Examples:
|
|
9
|
+
// get(MFE)
|
|
10
|
+
// get(PICK)
|
|
11
|
+
//
|
|
12
|
+
const bag = {
|
|
13
|
+
get: (tag) => {
|
|
14
|
+
const key = tag ? `${KEY}-${tag}` : KEY;
|
|
15
|
+
const json = localStorage.getItem(key);
|
|
16
|
+
return json ? JSON.parse(json) : undefined;
|
|
17
|
+
},
|
|
18
|
+
store: (tag, value) => {
|
|
19
|
+
const key = tag ? `${KEY}-${tag}` : KEY;
|
|
20
|
+
const json = JSON.stringify(value === undefined ? null : value);
|
|
21
|
+
localStorage.setItem(key, json);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const appendToMap = (map, propName, value) => {
|
|
26
|
+
const items = map.get(propName);
|
|
27
|
+
if (!items) {
|
|
28
|
+
map.set(propName, [value]);
|
|
29
|
+
}
|
|
30
|
+
else if (!items.includes(value)) {
|
|
31
|
+
items.push(value);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const debounce = (fn, ms) => {
|
|
35
|
+
let timeoutId;
|
|
36
|
+
return (...args) => {
|
|
37
|
+
if (timeoutId) {
|
|
38
|
+
clearTimeout(timeoutId);
|
|
39
|
+
}
|
|
40
|
+
timeoutId = setTimeout(() => {
|
|
41
|
+
timeoutId = 0;
|
|
42
|
+
fn(...args);
|
|
43
|
+
}, ms);
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Check if a possible element isConnected.
|
|
49
|
+
* The property might not be there, so we check for it.
|
|
50
|
+
*
|
|
51
|
+
* We want it to return true if isConnected is not a property,
|
|
52
|
+
* otherwise we would remove these elements and would not update.
|
|
53
|
+
*
|
|
54
|
+
* Better leak in Edge than to be useless.
|
|
55
|
+
*/
|
|
56
|
+
const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
|
|
57
|
+
const cleanupElements = debounce((map) => {
|
|
58
|
+
for (let key of map.keys()) {
|
|
59
|
+
map.set(key, map.get(key).filter(isConnected));
|
|
60
|
+
}
|
|
61
|
+
}, 2000);
|
|
62
|
+
const stencilSubscription = () => {
|
|
63
|
+
if (typeof getRenderingRef !== 'function') {
|
|
64
|
+
// If we are not in a stencil project, we do nothing.
|
|
65
|
+
// This function is not really exported by @stencil/core.
|
|
66
|
+
return {};
|
|
67
|
+
}
|
|
68
|
+
const elmsToUpdate = new Map();
|
|
69
|
+
return {
|
|
70
|
+
dispose: () => elmsToUpdate.clear(),
|
|
71
|
+
get: (propName) => {
|
|
72
|
+
const elm = getRenderingRef();
|
|
73
|
+
if (elm) {
|
|
74
|
+
appendToMap(elmsToUpdate, propName, elm);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
set: (propName) => {
|
|
78
|
+
const elements = elmsToUpdate.get(propName);
|
|
79
|
+
if (elements) {
|
|
80
|
+
elmsToUpdate.set(propName, elements.filter(forceUpdate));
|
|
81
|
+
}
|
|
82
|
+
cleanupElements(elmsToUpdate);
|
|
83
|
+
},
|
|
84
|
+
reset: () => {
|
|
85
|
+
elmsToUpdate.forEach((elms) => elms.forEach(forceUpdate));
|
|
86
|
+
cleanupElements(elmsToUpdate);
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const unwrap = (val) => (typeof val === 'function' ? val() : val);
|
|
92
|
+
const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
|
|
93
|
+
const unwrappedState = unwrap(defaultState);
|
|
94
|
+
let states = new Map(Object.entries(unwrappedState !== null && unwrappedState !== void 0 ? unwrappedState : {}));
|
|
95
|
+
const handlers = {
|
|
96
|
+
dispose: [],
|
|
97
|
+
get: [],
|
|
98
|
+
set: [],
|
|
99
|
+
reset: [],
|
|
100
|
+
};
|
|
101
|
+
const reset = () => {
|
|
102
|
+
var _a;
|
|
103
|
+
// When resetting the state, the default state may be a function - unwrap it to invoke it.
|
|
104
|
+
// otherwise, the state won't be properly reset
|
|
105
|
+
states = new Map(Object.entries((_a = unwrap(defaultState)) !== null && _a !== void 0 ? _a : {}));
|
|
106
|
+
handlers.reset.forEach((cb) => cb());
|
|
107
|
+
};
|
|
108
|
+
const dispose = () => {
|
|
109
|
+
// Call first dispose as resetting the state would
|
|
110
|
+
// cause less updates ;)
|
|
111
|
+
handlers.dispose.forEach((cb) => cb());
|
|
112
|
+
reset();
|
|
113
|
+
};
|
|
114
|
+
const get = (propName) => {
|
|
115
|
+
handlers.get.forEach((cb) => cb(propName));
|
|
116
|
+
return states.get(propName);
|
|
117
|
+
};
|
|
118
|
+
const set = (propName, value) => {
|
|
119
|
+
const oldValue = states.get(propName);
|
|
120
|
+
if (shouldUpdate(value, oldValue, propName)) {
|
|
121
|
+
states.set(propName, value);
|
|
122
|
+
handlers.set.forEach((cb) => cb(propName, value, oldValue));
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const state = (typeof Proxy === 'undefined'
|
|
126
|
+
? {}
|
|
127
|
+
: new Proxy(unwrappedState, {
|
|
128
|
+
get(_, propName) {
|
|
129
|
+
return get(propName);
|
|
130
|
+
},
|
|
131
|
+
ownKeys(_) {
|
|
132
|
+
return Array.from(states.keys());
|
|
133
|
+
},
|
|
134
|
+
getOwnPropertyDescriptor() {
|
|
135
|
+
return {
|
|
136
|
+
enumerable: true,
|
|
137
|
+
configurable: true,
|
|
138
|
+
};
|
|
139
|
+
},
|
|
140
|
+
has(_, propName) {
|
|
141
|
+
return states.has(propName);
|
|
142
|
+
},
|
|
143
|
+
set(_, propName, value) {
|
|
144
|
+
set(propName, value);
|
|
145
|
+
return true;
|
|
146
|
+
},
|
|
147
|
+
}));
|
|
148
|
+
const on = (eventName, callback) => {
|
|
149
|
+
handlers[eventName].push(callback);
|
|
150
|
+
return () => {
|
|
151
|
+
removeFromArray(handlers[eventName], callback);
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
const onChange = (propName, cb) => {
|
|
155
|
+
const unSet = on('set', (key, newValue) => {
|
|
156
|
+
if (key === propName) {
|
|
157
|
+
cb(newValue);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
// We need to unwrap the defaultState because it might be a function.
|
|
161
|
+
// Otherwise we might not be sending the right reset value.
|
|
162
|
+
const unReset = on('reset', () => cb(unwrap(defaultState)[propName]));
|
|
163
|
+
return () => {
|
|
164
|
+
unSet();
|
|
165
|
+
unReset();
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
const use = (...subscriptions) => {
|
|
169
|
+
const unsubs = subscriptions.reduce((unsubs, subscription) => {
|
|
170
|
+
if (subscription.set) {
|
|
171
|
+
unsubs.push(on('set', subscription.set));
|
|
172
|
+
}
|
|
173
|
+
if (subscription.get) {
|
|
174
|
+
unsubs.push(on('get', subscription.get));
|
|
175
|
+
}
|
|
176
|
+
if (subscription.reset) {
|
|
177
|
+
unsubs.push(on('reset', subscription.reset));
|
|
178
|
+
}
|
|
179
|
+
if (subscription.dispose) {
|
|
180
|
+
unsubs.push(on('dispose', subscription.dispose));
|
|
181
|
+
}
|
|
182
|
+
return unsubs;
|
|
183
|
+
}, []);
|
|
184
|
+
return () => unsubs.forEach((unsub) => unsub());
|
|
185
|
+
};
|
|
186
|
+
const forceUpdate = (key) => {
|
|
187
|
+
const oldValue = states.get(key);
|
|
188
|
+
handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
|
|
189
|
+
};
|
|
190
|
+
return {
|
|
191
|
+
state,
|
|
192
|
+
get,
|
|
193
|
+
set,
|
|
194
|
+
on,
|
|
195
|
+
onChange,
|
|
196
|
+
use,
|
|
197
|
+
dispose,
|
|
198
|
+
reset,
|
|
199
|
+
forceUpdate,
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
const removeFromArray = (array, item) => {
|
|
203
|
+
const index = array.indexOf(item);
|
|
204
|
+
if (index >= 0) {
|
|
205
|
+
array[index] = array[array.length - 1];
|
|
206
|
+
array.length--;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const createStore = (defaultState, shouldUpdate) => {
|
|
211
|
+
const map = createObservableMap(defaultState, shouldUpdate);
|
|
212
|
+
map.use(stencilSubscription());
|
|
213
|
+
return map;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
function mitt(n){return {all:n=n||new Map,on:function(t,e){var i=n.get(t);i?i.push(e):n.set(t,[e]);},off:function(t,e){var i=n.get(t);i&&(e?i.splice(i.indexOf(e)>>>0,1):n.set(t,[]));},emit:function(t,e){var i=n.get(t);i&&i.slice().map(function(n){n(e);}),(i=n.get("*"))&&i.slice().map(function(n){n(t,e);});}}}
|
|
217
|
+
|
|
218
|
+
const themes = [
|
|
219
|
+
'light',
|
|
220
|
+
'dark',
|
|
221
|
+
'aqua',
|
|
222
|
+
'business',
|
|
223
|
+
'corporate',
|
|
224
|
+
'fantasy',
|
|
225
|
+
'night',
|
|
226
|
+
'winter',
|
|
227
|
+
'wireframe',
|
|
228
|
+
];
|
|
229
|
+
// --------------------------------------------------------[ mutable store ]
|
|
230
|
+
const storeDef = {
|
|
231
|
+
login: true,
|
|
232
|
+
mfe: 'proto-home',
|
|
233
|
+
pick: 0,
|
|
234
|
+
theme: 'dark',
|
|
235
|
+
themes,
|
|
236
|
+
};
|
|
237
|
+
const { state } = createStore(storeDef);
|
|
238
|
+
const emitter = mitt();
|
|
239
|
+
// --------------------------------------------------------[ utility ]
|
|
240
|
+
const clearStore = (login = false) => {
|
|
241
|
+
state.login = login;
|
|
242
|
+
state.pick = 0;
|
|
243
|
+
state.mfe = 'proto-home';
|
|
244
|
+
state.theme = 'dark';
|
|
245
|
+
state.themes = themes;
|
|
246
|
+
};
|
|
247
|
+
// --------------------------------------------------------[ processing ]
|
|
248
|
+
const processApp = (next) => {
|
|
249
|
+
state.mfe = next;
|
|
250
|
+
if (next) {
|
|
251
|
+
bag.store(LOGIN, false);
|
|
252
|
+
state.login = false;
|
|
253
|
+
emitter.emit('app', { mfe: next });
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
bag.store(LOGIN, true);
|
|
257
|
+
state.login = true;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const processLogin = (next) => {
|
|
261
|
+
state.login = next;
|
|
262
|
+
if (next) {
|
|
263
|
+
emitter.emit('login', { login: next });
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
const processPick = (next) => {
|
|
267
|
+
state.pick = next;
|
|
268
|
+
if (next) {
|
|
269
|
+
emitter.emit('pick', { pick: next });
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
const processTheme = (next) => {
|
|
273
|
+
state.theme = next;
|
|
274
|
+
console.log(next);
|
|
275
|
+
if (next) {
|
|
276
|
+
emitter.emit('theme', { theme: next });
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
// --------------------------------------------------------[ actions ]
|
|
280
|
+
const initApp = () => {
|
|
281
|
+
clearStore();
|
|
282
|
+
// this retrieves the last data we stored in the bag...
|
|
283
|
+
const login = bag.get(LOGIN);
|
|
284
|
+
const data = bag.get(MFE);
|
|
285
|
+
const pick = bag.get(PICK);
|
|
286
|
+
const theme = bag.get(THEME);
|
|
287
|
+
console.log('-- data:', data);
|
|
288
|
+
if (theme) {
|
|
289
|
+
processTheme(theme);
|
|
290
|
+
if (login !== undefined) {
|
|
291
|
+
processLogin(login);
|
|
292
|
+
}
|
|
293
|
+
if (login === false && data) {
|
|
294
|
+
console.log('-- app:', data);
|
|
295
|
+
processApp(data);
|
|
296
|
+
}
|
|
297
|
+
if (pick) {
|
|
298
|
+
processPick(pick);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
refresh();
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
const refresh = () => {
|
|
306
|
+
clearStore(true);
|
|
307
|
+
bag.store(PICK, 0);
|
|
308
|
+
};
|
|
309
|
+
const updateApp = (mfe) => {
|
|
310
|
+
bag.store(MFE, mfe);
|
|
311
|
+
processApp(mfe);
|
|
312
|
+
};
|
|
313
|
+
const updatePick = (pick) => {
|
|
314
|
+
bag.store(PICK, pick);
|
|
315
|
+
processPick(pick);
|
|
316
|
+
};
|
|
317
|
+
const updateTheme = (theme) => {
|
|
318
|
+
bag.store(THEME, theme);
|
|
319
|
+
processTheme(theme);
|
|
320
|
+
};
|
|
321
|
+
const actions = {
|
|
322
|
+
initApp,
|
|
323
|
+
refresh,
|
|
324
|
+
updateApp,
|
|
325
|
+
updatePick,
|
|
326
|
+
updateTheme,
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
export { actions as a, state as s };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const dealers = [
|
|
2
|
+
{ id: 'brookhaven', name: 'Brookhaven' },
|
|
3
|
+
{ id: 'buckhead', name: 'Buckhead' },
|
|
4
|
+
{ id: 'dawsonville', name: 'Dawsonville' },
|
|
5
|
+
{ id: 'decatur', name: 'Decatur' },
|
|
6
|
+
{ id: 'kennesaw', name: 'Kennesaw' },
|
|
7
|
+
{ id: 'marietta', name: 'Marietta' },
|
|
8
|
+
{ id: 'peachtree', name: 'Peachtree' },
|
|
9
|
+
{ id: 'perimeter', name: 'Perimeter' },
|
|
10
|
+
{ id: 'stoneMountain', name: 'Stone Mountain' },
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
export { dealers as d };
|