@kizmann/pico-js 1.0.13 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/README.md +27 -7
  2. package/dist/pico-js.browser.js +2 -0
  3. package/dist/pico-js.browser.js.map +1 -0
  4. package/dist/pico-js.esm.js +2 -0
  5. package/dist/pico-js.esm.js.map +1 -0
  6. package/package.json +20 -7
  7. package/src/dom/DomAttribute.js +374 -0
  8. package/src/dom/DomBuilder.js +152 -0
  9. package/src/dom/DomEvent.js +253 -0
  10. package/src/dom/DomFinder.js +669 -0
  11. package/src/dom/DomForm.js +57 -0
  12. package/src/dom/DomGlobal.js +193 -0
  13. package/src/dom/DomInview.js +332 -0
  14. package/src/dom/DomMeta.js +66 -0
  15. package/src/dom/DomObserver.js +57 -0
  16. package/src/dom/DomRectangle.js +657 -0
  17. package/src/format/FormatFile.js +54 -0
  18. package/src/format/FormatOption.js +108 -0
  19. package/src/format/FormatParam.js +107 -0
  20. package/src/format/FormatParser.js +156 -0
  21. package/src/format/FormatUrl.js +75 -0
  22. package/src/index.browser.js +10 -0
  23. package/src/index.esm.js +138 -0
  24. package/src/now/NowDefault.js +533 -0
  25. package/src/now/NowFormat.js +196 -0
  26. package/src/now/NowGrid.js +251 -0
  27. package/src/now/NowHuman.js +118 -0
  28. package/src/now/NowMatch.js +175 -0
  29. package/src/now/NowRange.js +70 -0
  30. package/src/now/NowWalker.js +544 -0
  31. package/src/tool/scope.js +103 -0
  32. package/src/utils/Array.js +986 -0
  33. package/src/utils/Cookie.js +184 -0
  34. package/src/utils/Data.js +200 -0
  35. package/src/utils/Dom.js +208 -0
  36. package/src/utils/Event.js +140 -0
  37. package/src/utils/Format.js +62 -0
  38. package/src/utils/Hash.js +164 -0
  39. package/src/utils/Locale.js +229 -0
  40. package/src/utils/Mixed.js +887 -0
  41. package/src/utils/Now.js +234 -0
  42. package/src/utils/Number.js +238 -0
  43. package/src/utils/Object.js +655 -0
  44. package/src/utils/Route.js +67 -0
  45. package/src/utils/Runner.js +327 -0
  46. package/src/utils/String.js +618 -0
  47. package/src/{library/element.js → wip/Element.js} +90 -16
  48. package/src/{library/map.js → wip/Map.js} +256 -40
  49. package/types/dom/DomAttribute.d.ts +137 -0
  50. package/types/dom/DomBuilder.d.ts +67 -0
  51. package/types/dom/DomEvent.d.ts +103 -0
  52. package/types/dom/DomFinder.d.ts +321 -0
  53. package/types/dom/DomForm.d.ts +21 -0
  54. package/types/dom/DomGlobal.d.ts +79 -0
  55. package/types/dom/DomInview.d.ts +114 -0
  56. package/types/dom/DomMeta.d.ts +29 -0
  57. package/types/dom/DomObserver.d.ts +21 -0
  58. package/types/dom/DomRectangle.d.ts +270 -0
  59. package/types/format/FormatFile.d.ts +18 -0
  60. package/types/format/FormatOption.d.ts +40 -0
  61. package/types/format/FormatParam.d.ts +39 -0
  62. package/types/format/FormatParser.d.ts +46 -0
  63. package/types/format/FormatUrl.d.ts +17 -0
  64. package/types/index.browser.d.ts +1 -0
  65. package/types/index.esm.d.ts +52 -0
  66. package/types/now/NowDefault.d.ts +183 -0
  67. package/types/now/NowFormat.d.ts +70 -0
  68. package/types/now/NowGrid.d.ts +107 -0
  69. package/types/now/NowHuman.d.ts +37 -0
  70. package/types/now/NowMatch.d.ts +108 -0
  71. package/types/now/NowRange.d.ts +21 -0
  72. package/types/now/NowWalker.d.ts +301 -0
  73. package/types/tool/scope.d.ts +24 -0
  74. package/types/utils/Array.d.ts +480 -0
  75. package/types/utils/Cookie.d.ts +60 -0
  76. package/types/utils/Data.d.ts +91 -0
  77. package/types/utils/Dom.d.ts +138 -0
  78. package/types/utils/Event.d.ts +58 -0
  79. package/types/utils/Format.d.ts +37 -0
  80. package/types/utils/Hash.d.ts +81 -0
  81. package/types/utils/Locale.d.ts +115 -0
  82. package/types/utils/Mixed.d.ts +469 -0
  83. package/types/utils/Now.d.ts +125 -0
  84. package/types/utils/Number.d.ts +127 -0
  85. package/types/utils/Object.d.ts +255 -0
  86. package/types/utils/Route.d.ts +37 -0
  87. package/types/utils/Runner.d.ts +139 -0
  88. package/types/utils/String.d.ts +330 -0
  89. package/types/wip/Element.d.ts +119 -0
  90. package/types/wip/Map.d.ts +254 -0
  91. package/dist/.ignore.js +0 -0
  92. package/dist/pico-js.js +0 -2
  93. package/dist/pico-js.js.map +0 -1
  94. package/src/element/default.js +0 -46
  95. package/src/element/example.js +0 -58
  96. package/src/index.js +0 -90
  97. package/src/library/cookie.js +0 -123
  98. package/src/library/data.js +0 -111
  99. package/src/library/event.js +0 -91
  100. package/src/library/locale.js +0 -84
  101. package/src/library/queue.js +0 -64
  102. package/src/library/route.js +0 -28
  103. package/src/utility/any.js +0 -369
  104. package/src/utility/array.js +0 -410
  105. package/src/utility/dom.js +0 -1425
  106. package/src/utility/now.js +0 -544
  107. package/src/utility/number.js +0 -128
  108. package/src/utility/object.js +0 -429
  109. package/src/utility/string.js +0 -328
  110. package/types/index.d.ts +0 -77
  111. package/types/library/cookie.d.ts +0 -10
  112. package/types/library/data.d.ts +0 -15
  113. package/types/library/element.d.ts +0 -22
  114. package/types/library/event.d.ts +0 -13
  115. package/types/library/locale.d.ts +0 -14
  116. package/types/library/map.d.ts +0 -43
  117. package/types/library/queue.d.ts +0 -18
  118. package/types/library/route.d.ts +0 -11
  119. package/types/utility/any.d.ts +0 -35
  120. package/types/utility/array.d.ts +0 -46
  121. package/types/utility/dom.d.ts +0 -101
  122. package/types/utility/now.d.ts +0 -79
  123. package/types/utility/number.d.ts +0 -17
  124. package/types/utility/object.d.ts +0 -29
  125. package/types/utility/string.d.ts +0 -26
@@ -1,6 +1,6 @@
1
- import { Str, Obj, Dom, Any, Arr } from "../index.js";
1
+ import { Str, Obj, Dom, Mix, Arr } from "#src/index.esm.js";
2
2
 
3
- export class Element
3
+ export class PicoElement
4
4
  {
5
5
  /**
6
6
  * Prefix for attribute selector.
@@ -27,15 +27,29 @@ export class Element
27
27
  */
28
28
  static invi = [];
29
29
 
30
+ /**
31
+ * Listen to scroll events
32
+ *
33
+ * @example PicoElement.listen()
34
+ *
35
+ * @returns {void} No return value
36
+ */
30
37
  static listen()
31
38
  {
32
39
  // Apply dom scroll event
33
- document.addEventListener("scroll", Element.scroll);
40
+ document.addEventListener("scroll", PicoElement.scroll);
34
41
 
35
42
  // Apply initial scroll event
36
- Element.scroll();
43
+ PicoElement.scroll();
37
44
  }
38
45
 
46
+ /**
47
+ * Handle scroll visibility
48
+ *
49
+ * @example PicoElement.scroll()
50
+ *
51
+ * @returns {void} No return value
52
+ */
39
53
  static scroll()
40
54
  {
41
55
  Arr.each(this.invi, (item, index) => {
@@ -51,7 +65,13 @@ export class Element
51
65
  }
52
66
 
53
67
  /**
54
- * Bind a class on selector.
68
+ * Register element alias
69
+ *
70
+ * @example PicoElement.alias("tab", Tab)
71
+ *
72
+ * @param {string} key Alias key
73
+ * @param {any} instance Class instance
74
+ * @returns {this} Current class
55
75
  */
56
76
  static alias(key, instance)
57
77
  {
@@ -60,6 +80,16 @@ export class Element
60
80
  return this;
61
81
  }
62
82
 
83
+ /**
84
+ * Bind element to selector
85
+ *
86
+ * @example PicoElement.bind("tab", ".tabs")
87
+ *
88
+ * @param {string} key Alias key
89
+ * @param {any} selector Dom selector
90
+ * @param {any} [options] Init options
91
+ * @returns {this} Current class
92
+ */
63
93
  static bind(key, selector, options = {})
64
94
  {
65
95
  let el = Dom.find(selector), prefix = this.getPrefix(key);
@@ -70,7 +100,7 @@ export class Element
70
100
  let instance = Obj.get(this.inis,
71
101
  key, null);
72
102
 
73
- if ( Any.isEmpty(instance) ) {
103
+ if ( Mix.isEmpty(instance) ) {
74
104
  return console.error(`Element "${key}" is not defined.`);
75
105
  }
76
106
 
@@ -80,7 +110,7 @@ export class Element
80
110
  el.get(0), options
81
111
  );
82
112
 
83
- Element.runs.push({
113
+ PicoElement.runs.push({
84
114
  el: el.get(0), prefix: prefix, deamon: cb
85
115
  });
86
116
 
@@ -97,6 +127,16 @@ export class Element
97
127
  return this;
98
128
  }
99
129
 
130
+ /**
131
+ * Unbind element from selector
132
+ *
133
+ * @example PicoElement.unbind("tab", ".tabs")
134
+ *
135
+ * @param {string} key Alias key
136
+ * @param {any} selector Dom selector
137
+ * @param {any} [options] Init options
138
+ * @returns {this} Current class
139
+ */
100
140
  static unbind(key, selector, options = {})
101
141
  {
102
142
  let el = Dom.find(selector), prefix = this.getPrefix(key);
@@ -104,7 +144,7 @@ export class Element
104
144
  let instance = Obj.get(this.inis,
105
145
  key, null);
106
146
 
107
- if ( Any.isEmpty(instance) ) {
147
+ if ( Mix.isEmpty(instance) ) {
108
148
  return console.error(`Element "${key}" is not defined.`);
109
149
  }
110
150
 
@@ -122,14 +162,20 @@ export class Element
122
162
  // Unbind option
123
163
  callback.call({}, el, options);
124
164
 
125
- Arr.remove(Element.runs, { el: el.get(0) });
165
+ Arr.remove(PicoElement.runs, { el: el.get(0) });
126
166
 
127
167
  return this;
128
168
  }
129
169
 
130
170
 
131
171
  /**
132
- * Bind callback on selector.
172
+ * Observe DOM changes
173
+ *
174
+ * @example PicoElement.observe("tab")
175
+ *
176
+ * @param {string} key Alias key
177
+ * @param {boolean} [plain] Plain options
178
+ * @returns {this} Current class
133
179
  */
134
180
  static observe(key, plain = false)
135
181
  {
@@ -144,7 +190,7 @@ export class Element
144
190
 
145
191
  let callback = () => {
146
192
 
147
- let mounted = Element.getPrefix(key);
193
+ let mounted = PicoElement.getPrefix(key);
148
194
 
149
195
  let deamons = Arr.filter(this.runs,
150
196
  { prefix: selector });
@@ -155,7 +201,7 @@ export class Element
155
201
  Dom.find(el).attr(selector)
156
202
  );
157
203
 
158
- if ( plain && Any.isEmpty(options) ) {
204
+ if ( plain && Mix.isEmpty(options) ) {
159
205
  options = { _plain: Dom.find(el).attr(selector) };
160
206
  }
161
207
 
@@ -178,7 +224,7 @@ export class Element
178
224
  Dom.find(el).attr(selector)
179
225
  );
180
226
 
181
- if ( plain && Any.isEmpty(options) ) {
227
+ if ( plain && Mix.isEmpty(options) ) {
182
228
  options = { _plain: Dom.find(el).attr(selector) };
183
229
  }
184
230
 
@@ -201,11 +247,29 @@ export class Element
201
247
  return this;
202
248
  }
203
249
 
250
+ /**
251
+ * Bind element on inview
252
+ *
253
+ * @example PicoElement.bindInview(el, cb)
254
+ *
255
+ * @param {Element} el Target element
256
+ * @param {function} cb Callback fn
257
+ * @returns {void} No return value
258
+ */
204
259
  static bindInview(el, cb)
205
260
  {
206
261
  Arr.add(this.invi, { el, cb }, { el });
207
262
  }
208
263
 
264
+ /**
265
+ * Unbind element on inview
266
+ *
267
+ * @example PicoElement.unbindInview(el, cb)
268
+ *
269
+ * @param {Element} el Target element
270
+ * @param {function} cb Callback fn
271
+ * @returns {void} No return value
272
+ */
209
273
  static unbindInview(el, cb)
210
274
  {
211
275
  Arr.remove(this.invi, { el, cb }, { el });
@@ -214,7 +278,12 @@ export class Element
214
278
 
215
279
 
216
280
  /**
217
- * Return prefix with key.
281
+ * Get attribute prefix
282
+ *
283
+ * @example PicoElement.getPrefix("tab") // => "js-tab"
284
+ *
285
+ * @param {string} [key] Alias key
286
+ * @returns {string} Attribute prefix
218
287
  */
219
288
  static getPrefix(key)
220
289
  {
@@ -222,7 +291,12 @@ export class Element
222
291
  }
223
292
 
224
293
  /**
225
- * Set prefix to given value.
294
+ * Set attribute prefix
295
+ *
296
+ * @example PicoElement.setPrefix("pi")
297
+ *
298
+ * @param {string} prefix New prefix
299
+ * @returns {void} No return value
226
300
  */
227
301
  static setPrefix(prefix)
228
302
  {
@@ -231,4 +305,4 @@ export class Element
231
305
 
232
306
  }
233
307
 
234
- export default Element;
308
+ export default PicoElement;