smoothly 0.1.112 → 0.1.115

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 (246) hide show
  1. package/dist/cjs/{Notice-9c2b52b7.js → Notice-839702d8.js} +34 -26
  2. package/dist/cjs/{Trigger-74bd1ee8.js → Trigger-cf376531.js} +55 -146
  3. package/dist/cjs/{index-41a36ce2.js → index-1c61bdd3.js} +27 -1
  4. package/dist/cjs/index.cjs.js +20 -8
  5. package/dist/cjs/loader.cjs.js +3 -19
  6. package/dist/cjs/{smoothly-accordion_50.cjs.entry.js → smoothly-accordion_51.cjs.entry.js} +7694 -1487
  7. package/dist/cjs/smoothly-google-font.cjs.entry.js +2 -2
  8. package/dist/cjs/smoothly-radio-group.cjs.entry.js +2 -2
  9. package/dist/cjs/smoothly-reorder.cjs.entry.js +2 -2
  10. package/dist/cjs/smoothly-trigger-sink.cjs.entry.js +5 -5
  11. package/dist/cjs/smoothly-trigger-source.cjs.entry.js +5 -5
  12. package/dist/cjs/smoothly.cjs.js +5 -113
  13. package/dist/collection/collection-manifest.json +3 -2
  14. package/dist/collection/components/app-demo/index.js +6 -1
  15. package/dist/collection/components/button/index.js +168 -0
  16. package/dist/collection/components/button/style.css +49 -0
  17. package/dist/collection/components/input/style.css +2 -2
  18. package/dist/collection/components/picker/index.js +10 -6
  19. package/dist/collection/components/trigger/style.css +3 -3
  20. package/dist/custom-elements/index.d.ts +6 -0
  21. package/dist/custom-elements/index.js +7781 -2970
  22. package/dist/esm/{Notice-4131b4e0.js → Notice-608b552c.js} +34 -26
  23. package/dist/esm/{Trigger-d7b181ec.js → Trigger-365408f0.js} +55 -146
  24. package/dist/esm/{index-dcb2b612.js → index-a3737440.js} +27 -1
  25. package/dist/esm/index.js +17 -4
  26. package/dist/esm/loader.js +3 -19
  27. package/dist/esm/polyfills/css-shim.js +1 -1
  28. package/dist/esm/{smoothly-accordion_50.entry.js → smoothly-accordion_51.entry.js} +7694 -1488
  29. package/dist/esm/smoothly-google-font.entry.js +2 -2
  30. package/dist/esm/smoothly-radio-group.entry.js +2 -2
  31. package/dist/esm/smoothly-reorder.entry.js +2 -2
  32. package/dist/esm/smoothly-trigger-sink.entry.js +3 -3
  33. package/dist/esm/smoothly-trigger-source.entry.js +3 -3
  34. package/dist/esm/smoothly.js +5 -113
  35. package/dist/smoothly/index.esm.js +1 -376
  36. package/dist/smoothly/p-0215b4da.entry.js +1 -0
  37. package/dist/smoothly/{p-074a0448.js → p-0cba3e3d.js} +1 -1
  38. package/dist/smoothly/p-18a1063c.entry.js +1 -0
  39. package/dist/smoothly/p-6ca0d36c.js +1 -0
  40. package/dist/smoothly/p-6f009ac9.entry.js +1 -0
  41. package/dist/smoothly/p-7a30d9b8.js +1 -0
  42. package/dist/smoothly/p-8ae38136.entry.js +1 -0
  43. package/dist/smoothly/p-993534fa.entry.js +1 -0
  44. package/dist/smoothly/p-eec1c703.entry.js +1 -0
  45. package/dist/smoothly/smoothly.esm.js +1 -125
  46. package/dist/types/components/button/index.d.ts +11 -0
  47. package/dist/types/components.d.ts +27 -0
  48. package/dist/types/stencil-public-runtime.d.ts +6 -4
  49. package/package.json +18 -18
  50. package/dist/cjs/App-339acc9b.js +0 -647
  51. package/dist/cjs/_commonjsHelpers-10109b76.js +0 -48
  52. package/dist/cjs/app-globals-3a1e7e63.js +0 -5
  53. package/dist/cjs/css-shim-88cc6900.js +0 -6
  54. package/dist/cjs/dom-95afd968.js +0 -75
  55. package/dist/cjs/generate-f9a36f25.js +0 -66
  56. package/dist/cjs/index-138c41c2.js +0 -3066
  57. package/dist/cjs/index-40d009d5.js +0 -1354
  58. package/dist/cjs/index-ac32385c.js +0 -18850
  59. package/dist/cjs/index-d66869d7.js +0 -1672
  60. package/dist/cjs/shadow-css-71d0f821.js +0 -391
  61. package/dist/cjs/smoothly-accordion-item.cjs.entry.js +0 -54
  62. package/dist/cjs/smoothly-accordion.cjs.entry.js +0 -55
  63. package/dist/cjs/smoothly-app-demo.cjs.entry.js +0 -29
  64. package/dist/cjs/smoothly-app.cjs.entry.js +0 -19
  65. package/dist/cjs/smoothly-backtotop.cjs.entry.js +0 -37
  66. package/dist/cjs/smoothly-calendar.cjs.entry.js +0 -95
  67. package/dist/cjs/smoothly-checkbox.cjs.entry.js +0 -18671
  68. package/dist/cjs/smoothly-dialog-demo.cjs.entry.js +0 -16
  69. package/dist/cjs/smoothly-dialog.cjs.entry.js +0 -38
  70. package/dist/cjs/smoothly-display-amount.cjs.entry.js +0 -59
  71. package/dist/cjs/smoothly-display-date-time.cjs.entry.js +0 -20
  72. package/dist/cjs/smoothly-display-demo.cjs.entry.js +0 -25
  73. package/dist/cjs/smoothly-display.cjs.entry.js +0 -41
  74. package/dist/cjs/smoothly-frame.cjs.entry.js +0 -50
  75. package/dist/cjs/smoothly-icon-demo.cjs.entry.js +0 -491
  76. package/dist/cjs/smoothly-icon.cjs.entry.js +0 -52
  77. package/dist/cjs/smoothly-input-date-range.cjs.entry.js +0 -50
  78. package/dist/cjs/smoothly-input-date.cjs.entry.js +0 -44
  79. package/dist/cjs/smoothly-input-demo.cjs.entry.js +0 -19
  80. package/dist/cjs/smoothly-input-month.cjs.entry.js +0 -41
  81. package/dist/cjs/smoothly-input.cjs.entry.js +0 -202
  82. package/dist/cjs/smoothly-item.cjs.entry.js +0 -43
  83. package/dist/cjs/smoothly-menu-options.cjs.entry.js +0 -108
  84. package/dist/cjs/smoothly-notification.cjs.entry.js +0 -67
  85. package/dist/cjs/smoothly-notifier.cjs.entry.js +0 -29
  86. package/dist/cjs/smoothly-option.cjs.entry.js +0 -33
  87. package/dist/cjs/smoothly-picker.cjs.entry.js +0 -151
  88. package/dist/cjs/smoothly-popup.cjs.entry.js +0 -38
  89. package/dist/cjs/smoothly-quiet.cjs.entry.js +0 -19
  90. package/dist/cjs/smoothly-radio.cjs.entry.js +0 -28
  91. package/dist/cjs/smoothly-room.cjs.entry.js +0 -16
  92. package/dist/cjs/smoothly-select-demo.cjs.entry.js +0 -86
  93. package/dist/cjs/smoothly-select.cjs.entry.js +0 -31
  94. package/dist/cjs/smoothly-selector.cjs.entry.js +0 -119
  95. package/dist/cjs/smoothly-skeleton.cjs.entry.js +0 -27
  96. package/dist/cjs/smoothly-spinner.cjs.entry.js +0 -24
  97. package/dist/cjs/smoothly-submit.cjs.entry.js +0 -60
  98. package/dist/cjs/smoothly-svg.cjs.entry.js +0 -41
  99. package/dist/cjs/smoothly-tab-switch.cjs.entry.js +0 -32
  100. package/dist/cjs/smoothly-tab.cjs.entry.js +0 -37
  101. package/dist/cjs/smoothly-table-cell.cjs.entry.js +0 -19
  102. package/dist/cjs/smoothly-table-demo.cjs.entry.js +0 -22
  103. package/dist/cjs/smoothly-table-expandable-cell.cjs.entry.js +0 -45
  104. package/dist/cjs/smoothly-table-expandable-row.cjs.entry.js +0 -32
  105. package/dist/cjs/smoothly-table-header.cjs.entry.js +0 -41
  106. package/dist/cjs/smoothly-table-row.cjs.entry.js +0 -38
  107. package/dist/cjs/smoothly-table.cjs.entry.js +0 -26
  108. package/dist/cjs/smoothly-trigger.cjs.entry.js +0 -36
  109. package/dist/cjs/smoothly-tuple.cjs.entry.js +0 -16
  110. package/dist/cjs/smoothly-urlencoded.cjs.entry.js +0 -19
  111. package/dist/esm/App-22187759.js +0 -645
  112. package/dist/esm/_commonjsHelpers-8fe71198.js +0 -44
  113. package/dist/esm/app-globals-0f993ce5.js +0 -3
  114. package/dist/esm/css-shim-c64026cd.js +0 -4
  115. package/dist/esm/dom-a712b575.js +0 -73
  116. package/dist/esm/generate-50b98474.js +0 -61
  117. package/dist/esm/index-02a70ac1.js +0 -3027
  118. package/dist/esm/index-401c6ce3.js +0 -1670
  119. package/dist/esm/index-a5a08f46.js +0 -18848
  120. package/dist/esm/index-c8b5d468.js +0 -1349
  121. package/dist/esm/shadow-css-1e16431b.js +0 -389
  122. package/dist/esm/smoothly-accordion-item.entry.js +0 -50
  123. package/dist/esm/smoothly-accordion.entry.js +0 -51
  124. package/dist/esm/smoothly-app-demo.entry.js +0 -25
  125. package/dist/esm/smoothly-app.entry.js +0 -15
  126. package/dist/esm/smoothly-backtotop.entry.js +0 -33
  127. package/dist/esm/smoothly-calendar.entry.js +0 -91
  128. package/dist/esm/smoothly-checkbox.entry.js +0 -18667
  129. package/dist/esm/smoothly-dialog-demo.entry.js +0 -12
  130. package/dist/esm/smoothly-dialog.entry.js +0 -34
  131. package/dist/esm/smoothly-display-amount.entry.js +0 -55
  132. package/dist/esm/smoothly-display-date-time.entry.js +0 -16
  133. package/dist/esm/smoothly-display-demo.entry.js +0 -21
  134. package/dist/esm/smoothly-display.entry.js +0 -37
  135. package/dist/esm/smoothly-frame.entry.js +0 -46
  136. package/dist/esm/smoothly-icon-demo.entry.js +0 -487
  137. package/dist/esm/smoothly-icon.entry.js +0 -48
  138. package/dist/esm/smoothly-input-date-range.entry.js +0 -46
  139. package/dist/esm/smoothly-input-date.entry.js +0 -40
  140. package/dist/esm/smoothly-input-demo.entry.js +0 -15
  141. package/dist/esm/smoothly-input-month.entry.js +0 -37
  142. package/dist/esm/smoothly-input.entry.js +0 -198
  143. package/dist/esm/smoothly-item.entry.js +0 -39
  144. package/dist/esm/smoothly-menu-options.entry.js +0 -104
  145. package/dist/esm/smoothly-notification.entry.js +0 -63
  146. package/dist/esm/smoothly-notifier.entry.js +0 -25
  147. package/dist/esm/smoothly-option.entry.js +0 -29
  148. package/dist/esm/smoothly-picker.entry.js +0 -147
  149. package/dist/esm/smoothly-popup.entry.js +0 -34
  150. package/dist/esm/smoothly-quiet.entry.js +0 -15
  151. package/dist/esm/smoothly-radio.entry.js +0 -24
  152. package/dist/esm/smoothly-room.entry.js +0 -12
  153. package/dist/esm/smoothly-select-demo.entry.js +0 -82
  154. package/dist/esm/smoothly-select.entry.js +0 -27
  155. package/dist/esm/smoothly-selector.entry.js +0 -115
  156. package/dist/esm/smoothly-skeleton.entry.js +0 -23
  157. package/dist/esm/smoothly-spinner.entry.js +0 -20
  158. package/dist/esm/smoothly-submit.entry.js +0 -56
  159. package/dist/esm/smoothly-svg.entry.js +0 -37
  160. package/dist/esm/smoothly-tab-switch.entry.js +0 -28
  161. package/dist/esm/smoothly-tab.entry.js +0 -33
  162. package/dist/esm/smoothly-table-cell.entry.js +0 -15
  163. package/dist/esm/smoothly-table-demo.entry.js +0 -18
  164. package/dist/esm/smoothly-table-expandable-cell.entry.js +0 -41
  165. package/dist/esm/smoothly-table-expandable-row.entry.js +0 -28
  166. package/dist/esm/smoothly-table-header.entry.js +0 -37
  167. package/dist/esm/smoothly-table-row.entry.js +0 -34
  168. package/dist/esm/smoothly-table.entry.js +0 -22
  169. package/dist/esm/smoothly-trigger.entry.js +0 -32
  170. package/dist/esm/smoothly-tuple.entry.js +0 -12
  171. package/dist/esm/smoothly-urlencoded.entry.js +0 -15
  172. package/dist/smoothly/App-22187759.js +0 -645
  173. package/dist/smoothly/GoogleFont-8474516b.js +0 -21
  174. package/dist/smoothly/_commonjsHelpers-8fe71198.js +0 -44
  175. package/dist/smoothly/app-globals-0f993ce5.js +0 -3
  176. package/dist/smoothly/css-shim-c64026cd.js +0 -4
  177. package/dist/smoothly/dom-a712b575.js +0 -73
  178. package/dist/smoothly/generate-50b98474.js +0 -61
  179. package/dist/smoothly/index-02a70ac1.js +0 -3027
  180. package/dist/smoothly/index-401c6ce3.js +0 -1670
  181. package/dist/smoothly/index-a5a08f46.js +0 -18848
  182. package/dist/smoothly/index-c8b5d468.js +0 -1349
  183. package/dist/smoothly/p-0c1e9588.entry.js +0 -1
  184. package/dist/smoothly/p-14232157.entry.js +0 -1
  185. package/dist/smoothly/p-19518931.js +0 -1
  186. package/dist/smoothly/p-22d4d5a7.entry.js +0 -1
  187. package/dist/smoothly/p-2cda1784.js +0 -1
  188. package/dist/smoothly/p-436cd558.entry.js +0 -1
  189. package/dist/smoothly/p-9fa3ab06.entry.js +0 -1
  190. package/dist/smoothly/p-b8a3e273.entry.js +0 -1
  191. package/dist/smoothly/shadow-css-1e16431b.js +0 -389
  192. package/dist/smoothly/smoothly-accordion-item.entry.js +0 -50
  193. package/dist/smoothly/smoothly-accordion.entry.js +0 -51
  194. package/dist/smoothly/smoothly-app-demo.entry.js +0 -25
  195. package/dist/smoothly/smoothly-app.entry.js +0 -15
  196. package/dist/smoothly/smoothly-backtotop.entry.js +0 -33
  197. package/dist/smoothly/smoothly-calendar.entry.js +0 -91
  198. package/dist/smoothly/smoothly-checkbox.entry.js +0 -18667
  199. package/dist/smoothly/smoothly-dialog-demo.entry.js +0 -12
  200. package/dist/smoothly/smoothly-dialog.entry.js +0 -34
  201. package/dist/smoothly/smoothly-display-amount.entry.js +0 -55
  202. package/dist/smoothly/smoothly-display-date-time.entry.js +0 -16
  203. package/dist/smoothly/smoothly-display-demo.entry.js +0 -21
  204. package/dist/smoothly/smoothly-display.entry.js +0 -37
  205. package/dist/smoothly/smoothly-frame.entry.js +0 -46
  206. package/dist/smoothly/smoothly-google-font.entry.js +0 -13
  207. package/dist/smoothly/smoothly-icon-demo.entry.js +0 -487
  208. package/dist/smoothly/smoothly-icon.entry.js +0 -48
  209. package/dist/smoothly/smoothly-input-date-range.entry.js +0 -46
  210. package/dist/smoothly/smoothly-input-date.entry.js +0 -40
  211. package/dist/smoothly/smoothly-input-demo.entry.js +0 -15
  212. package/dist/smoothly/smoothly-input-month.entry.js +0 -37
  213. package/dist/smoothly/smoothly-input.entry.js +0 -198
  214. package/dist/smoothly/smoothly-item.entry.js +0 -39
  215. package/dist/smoothly/smoothly-menu-options.entry.js +0 -104
  216. package/dist/smoothly/smoothly-notification.entry.js +0 -63
  217. package/dist/smoothly/smoothly-notifier.entry.js +0 -25
  218. package/dist/smoothly/smoothly-option.entry.js +0 -29
  219. package/dist/smoothly/smoothly-picker.entry.js +0 -147
  220. package/dist/smoothly/smoothly-popup.entry.js +0 -34
  221. package/dist/smoothly/smoothly-quiet.entry.js +0 -15
  222. package/dist/smoothly/smoothly-radio-group.entry.js +0 -16
  223. package/dist/smoothly/smoothly-radio.entry.js +0 -24
  224. package/dist/smoothly/smoothly-reorder.entry.js +0 -99
  225. package/dist/smoothly/smoothly-room.entry.js +0 -12
  226. package/dist/smoothly/smoothly-select-demo.entry.js +0 -82
  227. package/dist/smoothly/smoothly-select.entry.js +0 -27
  228. package/dist/smoothly/smoothly-selector.entry.js +0 -115
  229. package/dist/smoothly/smoothly-skeleton.entry.js +0 -23
  230. package/dist/smoothly/smoothly-spinner.entry.js +0 -20
  231. package/dist/smoothly/smoothly-submit.entry.js +0 -56
  232. package/dist/smoothly/smoothly-svg.entry.js +0 -37
  233. package/dist/smoothly/smoothly-tab-switch.entry.js +0 -28
  234. package/dist/smoothly/smoothly-tab.entry.js +0 -33
  235. package/dist/smoothly/smoothly-table-cell.entry.js +0 -15
  236. package/dist/smoothly/smoothly-table-demo.entry.js +0 -18
  237. package/dist/smoothly/smoothly-table-expandable-cell.entry.js +0 -41
  238. package/dist/smoothly/smoothly-table-expandable-row.entry.js +0 -28
  239. package/dist/smoothly/smoothly-table-header.entry.js +0 -37
  240. package/dist/smoothly/smoothly-table-row.entry.js +0 -34
  241. package/dist/smoothly/smoothly-table.entry.js +0 -22
  242. package/dist/smoothly/smoothly-trigger-sink.entry.js +0 -29
  243. package/dist/smoothly/smoothly-trigger-source.entry.js +0 -28
  244. package/dist/smoothly/smoothly-trigger.entry.js +0 -32
  245. package/dist/smoothly/smoothly-tuple.entry.js +0 -12
  246. package/dist/smoothly/smoothly-urlencoded.entry.js +0 -15
@@ -1,647 +0,0 @@
1
- 'use strict';
2
-
3
- const index = require('./index-138c41c2.js');
4
-
5
- const appendToMap = (map, propName, value) => {
6
- const items = map.get(propName);
7
- if (!items) {
8
- map.set(propName, [value]);
9
- }
10
- else if (!items.includes(value)) {
11
- items.push(value);
12
- }
13
- };
14
- const debounce = (fn, ms) => {
15
- let timeoutId;
16
- return (...args) => {
17
- if (timeoutId) {
18
- clearTimeout(timeoutId);
19
- }
20
- timeoutId = setTimeout(() => {
21
- timeoutId = 0;
22
- fn(...args);
23
- }, ms);
24
- };
25
- };
26
-
27
- /**
28
- * Check if a possible element isConnected.
29
- * The property might not be there, so we check for it.
30
- *
31
- * We want it to return true if isConnected is not a property,
32
- * otherwise we would remove these elements and would not update.
33
- *
34
- * Better leak in Edge than to be useless.
35
- */
36
- const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
37
- const cleanupElements = debounce((map) => {
38
- for (let key of map.keys()) {
39
- map.set(key, map.get(key).filter(isConnected));
40
- }
41
- }, 2000);
42
- const stencilSubscription = ({ on }) => {
43
- const elmsToUpdate = new Map();
44
- if (typeof index.getRenderingRef === 'function') {
45
- // If we are not in a stencil project, we do nothing.
46
- // This function is not really exported by @stencil/core.
47
- on('dispose', () => {
48
- elmsToUpdate.clear();
49
- });
50
- on('get', (propName) => {
51
- const elm = index.getRenderingRef();
52
- if (elm) {
53
- appendToMap(elmsToUpdate, propName, elm);
54
- }
55
- });
56
- on('set', (propName) => {
57
- const elements = elmsToUpdate.get(propName);
58
- if (elements) {
59
- elmsToUpdate.set(propName, elements.filter(index.forceUpdate));
60
- }
61
- cleanupElements(elmsToUpdate);
62
- });
63
- on('reset', () => {
64
- elmsToUpdate.forEach((elms) => elms.forEach(index.forceUpdate));
65
- cleanupElements(elmsToUpdate);
66
- });
67
- }
68
- };
69
-
70
- const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
71
- let states = new Map(Object.entries(defaultState !== null && defaultState !== void 0 ? defaultState : {}));
72
- const handlers = {
73
- dispose: [],
74
- get: [],
75
- set: [],
76
- reset: [],
77
- };
78
- const reset = () => {
79
- states = new Map(Object.entries(defaultState !== null && defaultState !== void 0 ? defaultState : {}));
80
- handlers.reset.forEach((cb) => cb());
81
- };
82
- const dispose = () => {
83
- // Call first dispose as resetting the state would
84
- // cause less updates ;)
85
- handlers.dispose.forEach((cb) => cb());
86
- reset();
87
- };
88
- const get = (propName) => {
89
- handlers.get.forEach((cb) => cb(propName));
90
- return states.get(propName);
91
- };
92
- const set = (propName, value) => {
93
- const oldValue = states.get(propName);
94
- if (shouldUpdate(value, oldValue, propName)) {
95
- states.set(propName, value);
96
- handlers.set.forEach((cb) => cb(propName, value, oldValue));
97
- }
98
- };
99
- const state = (typeof Proxy === 'undefined'
100
- ? {}
101
- : new Proxy(defaultState, {
102
- get(_, propName) {
103
- return get(propName);
104
- },
105
- ownKeys(_) {
106
- return Array.from(states.keys());
107
- },
108
- getOwnPropertyDescriptor() {
109
- return {
110
- enumerable: true,
111
- configurable: true,
112
- };
113
- },
114
- has(_, propName) {
115
- return states.has(propName);
116
- },
117
- set(_, propName, value) {
118
- set(propName, value);
119
- return true;
120
- },
121
- }));
122
- const on = (eventName, callback) => {
123
- handlers[eventName].push(callback);
124
- return () => {
125
- removeFromArray(handlers[eventName], callback);
126
- };
127
- };
128
- const onChange = (propName, cb) => {
129
- const unSet = on('set', (key, newValue) => {
130
- if (key === propName) {
131
- cb(newValue);
132
- }
133
- });
134
- const unReset = on('reset', () => cb(defaultState[propName]));
135
- return () => {
136
- unSet();
137
- unReset();
138
- };
139
- };
140
- const use = (...subscriptions) => subscriptions.forEach((subscription) => {
141
- if (subscription.set) {
142
- on('set', subscription.set);
143
- }
144
- if (subscription.get) {
145
- on('get', subscription.get);
146
- }
147
- if (subscription.reset) {
148
- on('reset', subscription.reset);
149
- }
150
- });
151
- const forceUpdate = (key) => {
152
- const oldValue = states.get(key);
153
- handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
154
- };
155
- return {
156
- state,
157
- get,
158
- set,
159
- on,
160
- onChange,
161
- use,
162
- dispose,
163
- reset,
164
- forceUpdate,
165
- };
166
- };
167
- const removeFromArray = (array, item) => {
168
- const index = array.indexOf(item);
169
- if (index >= 0) {
170
- array[index] = array[array.length - 1];
171
- array.length--;
172
- }
173
- };
174
-
175
- const createStore = (defaultState, shouldUpdate) => {
176
- const map = createObservableMap(defaultState, shouldUpdate);
177
- stencilSubscription(map);
178
- return map;
179
- };
180
-
181
- let defaultRouter;
182
- const createRouter = (opts) => {
183
- var _a;
184
- const win = window;
185
- const url = new URL(win.location.href);
186
- const parseURL = (_a = opts === null || opts === void 0 ? void 0 : opts.parseURL) !== null && _a !== void 0 ? _a : DEFAULT_PARSE_URL;
187
- const { state, onChange, dispose } = createStore({
188
- url,
189
- activePath: parseURL(url)
190
- }, (newV, oldV, prop) => {
191
- if (prop === 'url') {
192
- return newV.href !== oldV.href;
193
- }
194
- return newV !== oldV;
195
- });
196
- const push = (href) => {
197
- history.pushState(null, null, href);
198
- const url = new URL(href, document.baseURI);
199
- state.url = url;
200
- state.activePath = parseURL(url);
201
- };
202
- const match = (routes) => {
203
- const { activePath } = state;
204
- for (let route of routes) {
205
- const params = matchPath(activePath, route.path);
206
- if (params) {
207
- if (route.to != null) {
208
- const to = (typeof route.to === 'string')
209
- ? route.to
210
- : route.to(activePath);
211
- push(to);
212
- return match(routes);
213
- }
214
- else {
215
- return { params, route };
216
- }
217
- }
218
- }
219
- return undefined;
220
- };
221
- const navigationChanged = () => {
222
- const url = new URL(win.location.href);
223
- state.url = url;
224
- state.activePath = parseURL(url);
225
- };
226
- const Switch = (_, childrenRoutes) => {
227
- const result = match(childrenRoutes);
228
- if (result) {
229
- if (typeof result.route.jsx === 'function') {
230
- return result.route.jsx(result.params);
231
- }
232
- else {
233
- return result.route.jsx;
234
- }
235
- }
236
- };
237
- const disposeRouter = () => {
238
- defaultRouter = undefined;
239
- win.removeEventListener('popstate', navigationChanged);
240
- dispose();
241
- };
242
- const router = defaultRouter = {
243
- Switch,
244
- get url() {
245
- return state.url;
246
- },
247
- get activePath() {
248
- return state.activePath;
249
- },
250
- push,
251
- onChange: onChange,
252
- dispose: disposeRouter,
253
- };
254
- // Initial update
255
- navigationChanged();
256
- // Listen URL changes
257
- win.addEventListener('popstate', navigationChanged);
258
- return router;
259
- };
260
- const Route = (props, children) => {
261
- var _a;
262
- if ('to' in props) {
263
- return {
264
- path: props.path,
265
- to: props.to,
266
- };
267
- }
268
- if (index.Build.isDev && props.render && children.length > 0) {
269
- console.warn('Route: if `render` is provided, the component should not have any children');
270
- }
271
- return {
272
- path: props.path,
273
- id: props.id,
274
- jsx: (_a = props.render) !== null && _a !== void 0 ? _a : children,
275
- };
276
- };
277
- const href = (href, router = defaultRouter) => {
278
- if (index.Build.isDev && !router) {
279
- throw new Error('Router must be defined in href');
280
- }
281
- return {
282
- href,
283
- onClick: (ev) => {
284
- if (ev.metaKey || ev.ctrlKey) {
285
- return;
286
- }
287
- if (ev.which == 2 || ev.button == 1) {
288
- return;
289
- }
290
- ev.preventDefault();
291
- router.push(href);
292
- },
293
- };
294
- };
295
- const matchPath = (pathname, path) => {
296
- if (typeof path === 'string') {
297
- if (path === pathname) {
298
- return {};
299
- }
300
- }
301
- else if (typeof path === 'function') {
302
- const params = path(pathname);
303
- if (params) {
304
- return params === true
305
- ? {}
306
- : { ...params };
307
- }
308
- }
309
- else {
310
- const results = path.exec(pathname);
311
- if (results) {
312
- path.lastIndex = 0;
313
- return { ...results };
314
- }
315
- }
316
- return undefined;
317
- };
318
- const DEFAULT_PARSE_URL = (url) => {
319
- return url.pathname.toLowerCase();
320
- };
321
- const NotFound = () => ({});
322
-
323
- /**
324
- * TS adaption of https://github.com/pillarjs/path-to-regexp/blob/master/index.js
325
- */
326
- /**
327
- * Default configs.
328
- */
329
- const DEFAULT_DELIMITER = '/';
330
- const DEFAULT_DELIMITERS = './';
331
- /**
332
- * The main path matching regexp utility.
333
- */
334
- const PATH_REGEXP = new RegExp([
335
- // Match escaped characters that would otherwise appear in future matches.
336
- // This allows the user to escape special characters that won't transform.
337
- '(\\\\.)',
338
- // Match Express-style parameters and un-named parameters with a prefix
339
- // and optional suffixes. Matches appear as:
340
- //
341
- // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?"]
342
- // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined]
343
- '(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?'
344
- ].join('|'), 'g');
345
- /**
346
- * Parse a string for the raw tokens.
347
- */
348
- const parse = (str, options) => {
349
- var tokens = [];
350
- var key = 0;
351
- var index = 0;
352
- var path = '';
353
- var defaultDelimiter = (options && options.delimiter) || DEFAULT_DELIMITER;
354
- var delimiters = (options && options.delimiters) || DEFAULT_DELIMITERS;
355
- var pathEscaped = false;
356
- var res;
357
- while ((res = PATH_REGEXP.exec(str)) !== null) {
358
- var m = res[0];
359
- var escaped = res[1];
360
- var offset = res.index;
361
- path += str.slice(index, offset);
362
- index = offset + m.length;
363
- // Ignore already escaped sequences.
364
- if (escaped) {
365
- path += escaped[1];
366
- pathEscaped = true;
367
- continue;
368
- }
369
- var prev = '';
370
- var next = str[index];
371
- var name = res[2];
372
- var capture = res[3];
373
- var group = res[4];
374
- var modifier = res[5];
375
- if (!pathEscaped && path.length) {
376
- var k = path.length - 1;
377
- if (delimiters.indexOf(path[k]) > -1) {
378
- prev = path[k];
379
- path = path.slice(0, k);
380
- }
381
- }
382
- // Push the current path onto the tokens.
383
- if (path) {
384
- tokens.push(path);
385
- path = '';
386
- pathEscaped = false;
387
- }
388
- var partial = prev !== '' && next !== undefined && next !== prev;
389
- var repeat = modifier === '+' || modifier === '*';
390
- var optional = modifier === '?' || modifier === '*';
391
- var delimiter = prev || defaultDelimiter;
392
- var pattern = capture || group;
393
- tokens.push({
394
- name: name || key++,
395
- prefix: prev,
396
- delimiter: delimiter,
397
- optional: optional,
398
- repeat: repeat,
399
- partial: partial,
400
- pattern: pattern ? escapeGroup(pattern) : '[^' + escapeString(delimiter) + ']+?'
401
- });
402
- }
403
- // Push any remaining characters.
404
- if (path || index < str.length) {
405
- tokens.push(path + str.substr(index));
406
- }
407
- return tokens;
408
- };
409
- /**
410
- * Escape a regular expression string.
411
- */
412
- const escapeString = (str) => {
413
- return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, '\\$1');
414
- };
415
- /**
416
- * Escape the capturing group by escaping special characters and meaning.
417
- */
418
- const escapeGroup = (group) => {
419
- return group.replace(/([=!:$/()])/g, '\\$1');
420
- };
421
- /**
422
- * Get the flags for a regexp from the options.
423
- */
424
- const flags = (options) => {
425
- return options && options.sensitive ? '' : 'i';
426
- };
427
- /**
428
- * Pull out keys from a regexp.
429
- */
430
- const regexpToRegexp = (path, keys) => {
431
- if (!keys)
432
- return path;
433
- // Use a negative lookahead to match only capturing groups.
434
- var groups = path.source.match(/\((?!\?)/g);
435
- if (groups) {
436
- for (var i = 0; i < groups.length; i++) {
437
- keys.push({
438
- name: i,
439
- prefix: null,
440
- delimiter: null,
441
- optional: false,
442
- repeat: false,
443
- partial: false,
444
- pattern: null
445
- });
446
- }
447
- }
448
- return path;
449
- };
450
- /**
451
- * Transform an array into a regexp.
452
- */
453
- const arrayToRegexp = (path, keys, options) => {
454
- var parts = [];
455
- for (var i = 0; i < path.length; i++) {
456
- parts.push(pathToRegexp(path[i], keys, options).source);
457
- }
458
- return new RegExp('(?:' + parts.join('|') + ')', flags(options));
459
- };
460
- /**
461
- * Create a path regexp from string input.
462
- */
463
- const stringToRegexp = (path, keys, options) => {
464
- return tokensToRegExp(parse(path, options), keys, options);
465
- };
466
- /**
467
- * Expose a function for taking tokens and returning a RegExp.
468
- */
469
- const tokensToRegExp = (tokens, keys, options) => {
470
- options = options || {};
471
- var strict = options.strict;
472
- var end = options.end !== false;
473
- var delimiter = escapeString(options.delimiter || DEFAULT_DELIMITER);
474
- var delimiters = options.delimiters || DEFAULT_DELIMITERS;
475
- var endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|');
476
- var route = '';
477
- var isEndDelimited = false;
478
- // Iterate over the tokens and create our regexp string.
479
- for (var i = 0; i < tokens.length; i++) {
480
- var token = tokens[i];
481
- if (typeof token === 'string') {
482
- route += escapeString(token);
483
- isEndDelimited = i === tokens.length - 1 && delimiters.indexOf(token[token.length - 1]) > -1;
484
- }
485
- else {
486
- var prefix = escapeString(token.prefix || '');
487
- var capture = token.repeat
488
- ? '(?:' + token.pattern + ')(?:' + prefix + '(?:' + token.pattern + '))*'
489
- : token.pattern;
490
- if (keys)
491
- keys.push(token);
492
- if (token.optional) {
493
- if (token.partial) {
494
- route += prefix + '(' + capture + ')?';
495
- }
496
- else {
497
- route += '(?:' + prefix + '(' + capture + '))?';
498
- }
499
- }
500
- else {
501
- route += prefix + '(' + capture + ')';
502
- }
503
- }
504
- }
505
- if (end) {
506
- if (!strict)
507
- route += '(?:' + delimiter + ')?';
508
- route += endsWith === '$' ? '$' : '(?=' + endsWith + ')';
509
- }
510
- else {
511
- if (!strict)
512
- route += '(?:' + delimiter + '(?=' + endsWith + '))?';
513
- if (!isEndDelimited)
514
- route += '(?=' + delimiter + '|' + endsWith + ')';
515
- }
516
- return new RegExp('^' + route, flags(options));
517
- };
518
- /**
519
- * Normalize the given path string, returning a regular expression.
520
- *
521
- * An empty array can be passed in for the keys, which will hold the
522
- * placeholder key descriptions. For example, using `/user/:id`, `keys` will
523
- * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
524
- */
525
- const pathToRegexp = (path, keys, options) => {
526
- if (path instanceof RegExp) {
527
- return regexpToRegexp(path, keys);
528
- }
529
- if (Array.isArray(path)) {
530
- return arrayToRegexp(path, keys, options);
531
- }
532
- return stringToRegexp(path, keys, options);
533
- };
534
-
535
- let cacheCount = 0;
536
- const patternCache = {};
537
- const cacheLimit = 10000;
538
- // Memoized function for creating the path match regex
539
- const compilePath = (pattern, options) => {
540
- const cacheKey = `${options.end}${options.strict}`;
541
- const cache = patternCache[cacheKey] || (patternCache[cacheKey] = {});
542
- const cachePattern = JSON.stringify(pattern);
543
- if (cache[cachePattern]) {
544
- return cache[cachePattern];
545
- }
546
- const keys = [];
547
- const re = pathToRegexp(pattern, keys, options);
548
- const compiledPattern = { re, keys };
549
- if (cacheCount < cacheLimit) {
550
- cache[cachePattern] = compiledPattern;
551
- cacheCount += 1;
552
- }
553
- return compiledPattern;
554
- };
555
- const match = (pathname, options = {}) => {
556
- const { exact = false, strict = false } = options;
557
- const { re, keys } = compilePath(pathname, { end: exact, strict });
558
- return (path) => {
559
- const match = re.exec(path);
560
- if (!match) {
561
- return undefined;
562
- }
563
- const [url, ...values] = match;
564
- const isExact = path === url;
565
- if (exact && !isExact) {
566
- return undefined;
567
- }
568
- return keys.reduce((memo, key, index) => {
569
- memo[key.name] = values[index];
570
- return memo;
571
- }, {});
572
- };
573
- };
574
-
575
- const Router = createRouter();
576
- const App = (attributes, nodes, utils) => {
577
- var _a;
578
- const emptyNode = Object.entries(nodes[0]).reduce((r, entry) => {
579
- r[entry[0]] = null;
580
- return r;
581
- }, {});
582
- const emptyChild = nodeToChild(emptyNode);
583
- function nodeToChild(node) {
584
- let result;
585
- utils.forEach([node], child => (result = child));
586
- return result !== null && result !== void 0 ? result : emptyChild;
587
- }
588
- function childToNode(child) {
589
- return utils.map([emptyNode], c => (Object.assign(Object.assign({}, c), child)))[0];
590
- }
591
- const children = nodes.map((node, index) => (Object.assign(Object.assign({}, nodeToChild(node)), { node })));
592
- return (index.h("smoothly-app", null,
593
- index.h("header", null,
594
- index.h("h1", null,
595
- index.h("a", Object.assign({}, href((_a = resolve("")) !== null && _a !== void 0 ? _a : "/")), attributes.label)),
596
- index.h("nav", null,
597
- index.h("ul", null, utils
598
- .map([
599
- ...children.filter(child => { var _a; return ((_a = child.vattrs) === null || _a === void 0 ? void 0 : _a.slot) == "nav-start"; }),
600
- ...children.filter(child => { var _a, _b; return ((_a = child.vattrs) === null || _a === void 0 ? void 0 : _a.label) && ((_b = child.vattrs) === null || _b === void 0 ? void 0 : _b.path); }),
601
- ...children.filter(child => { var _a; return ((_a = child.vattrs) === null || _a === void 0 ? void 0 : _a.slot) == "nav-end"; }),
602
- ].map(child => child.node), child => {
603
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
604
- if (((_a = child.vattrs) === null || _a === void 0 ? void 0 : _a.label) && ((_b = child.vattrs) === null || _b === void 0 ? void 0 : _b.path))
605
- child = Object.assign(Object.assign({}, emptyChild), { vtag: "a", vattrs: { href: (_c = child.vattrs) === null || _c === void 0 ? void 0 : _c.path }, vchildren: [
606
- ((_d = child.vattrs) === null || _d === void 0 ? void 0 : _d.icon)
607
- ? childToNode({
608
- vtag: "smoothly-icon",
609
- vattrs: {
610
- toolTip: (_e = child.vattrs) === null || _e === void 0 ? void 0 : _e.label,
611
- name: (_f = child.vattrs) === null || _f === void 0 ? void 0 : _f.icon,
612
- size: "medium",
613
- },
614
- })
615
- : childToNode({ vtext: (_g = child.vattrs) === null || _g === void 0 ? void 0 : _g.label }),
616
- ] });
617
- const url = resolve((_h = child.vattrs) === null || _h === void 0 ? void 0 : _h.href);
618
- return child.vtag != "a"
619
- ? child
620
- : url
621
- ? Object.assign(Object.assign({}, child), { vattrs: Object.assign(Object.assign({}, child.vattrs), { class: [(_j = child.vattrs) === null || _j === void 0 ? void 0 : _j.class, Router.activePath == url ? "active" : ""].join(" ") || undefined, href: url }) }) : Object.assign(Object.assign({}, child), { vattrs: Object.assign(Object.assign({}, child.vattrs), { target: "new" }) });
622
- })
623
- .map(node => {
624
- var _a, _b;
625
- const child = nodeToChild(node);
626
- return child.vtag == "a" && !((_a = child.vattrs) === null || _a === void 0 ? void 0 : _a.target) ? (index.h("a", Object.assign({}, child.vattrs, href((_b = child.vattrs) === null || _b === void 0 ? void 0 : _b.href)), child.vchildren)) : (node);
627
- })
628
- .map(child => (index.h("li", null, child))))),
629
- children.filter(child => { var _a; return ((_a = child.vattrs) === null || _a === void 0 ? void 0 : _a.slot) == "header"; }).map(child => child.node)),
630
- index.h("main", null,
631
- index.h(Router.Switch, null, children
632
- .filter(child => { var _a; return ((_a = child.vattrs) === null || _a === void 0 ? void 0 : _a.path) != undefined; })
633
- .map(child => {
634
- var _a, _b, _c, _d, _e, _f, _g, _h;
635
- return ((_a = child.vattrs) === null || _a === void 0 ? void 0 : _a.to) ? (index.h(Route, { path: (_c = resolve((_b = child.vattrs) === null || _b === void 0 ? void 0 : _b.path)) !== null && _c !== void 0 ? _c : (_d = child.vattrs) === null || _d === void 0 ? void 0 : _d.path, to: (_e = child.vattrs) === null || _e === void 0 ? void 0 : _e.to })) : (index.h(Route, { path: (_g = resolve((_f = child.vattrs) === null || _f === void 0 ? void 0 : _f.path)) !== null && _g !== void 0 ? _g : (_h = child.vattrs) === null || _h === void 0 ? void 0 : _h.path }, child.node));
636
- })))));
637
- };
638
- function resolve(url) {
639
- const u = new URL(url, document.baseURI);
640
- return url == ""
641
- ? new URL(document.baseURI).pathname
642
- : u.toString().startsWith(document.baseURI)
643
- ? u.pathname
644
- : undefined;
645
- }
646
-
647
- exports.App = App;
@@ -1,48 +0,0 @@
1
- 'use strict';
2
-
3
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
-
5
- function getDefaultExportFromCjs (x) {
6
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
7
- }
8
-
9
- function createCommonjsModule(fn, basedir, module) {
10
- return module = {
11
- path: basedir,
12
- exports: {},
13
- require: function (path, base) {
14
- return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
15
- }
16
- }, fn(module, module.exports), module.exports;
17
- }
18
-
19
- function getDefaultExportFromNamespaceIfPresent (n) {
20
- return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n;
21
- }
22
-
23
- function getDefaultExportFromNamespaceIfNotNamed (n) {
24
- return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
25
- }
26
-
27
- function getAugmentedNamespace(n) {
28
- if (n.__esModule) return n;
29
- var a = Object.defineProperty({}, '__esModule', {value: true});
30
- Object.keys(n).forEach(function (k) {
31
- var d = Object.getOwnPropertyDescriptor(n, k);
32
- Object.defineProperty(a, k, d.get ? d : {
33
- enumerable: true,
34
- get: function () {
35
- return n[k];
36
- }
37
- });
38
- });
39
- return a;
40
- }
41
-
42
- function commonjsRequire () {
43
- throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
44
- }
45
-
46
- exports.commonjsGlobal = commonjsGlobal;
47
- exports.createCommonjsModule = createCommonjsModule;
48
- exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- const globalScripts = () => {};
4
-
5
- exports.globalScripts = globalScripts;