tosijs-ui 1.0.1 → 1.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.
Files changed (93) hide show
  1. package/README.md +4 -2
  2. package/dist/iife.js +70 -60
  3. package/dist/iife.js.map +42 -42
  4. package/dist/index.js +15 -37
  5. package/dist/index.js.map +39 -39
  6. package/dist/version.d.ts +1 -1
  7. package/package.json +2 -2
  8. package/dist/ab-test.js +0 -116
  9. package/dist/babylon-3d.js +0 -292
  10. package/dist/bodymovin-player.js +0 -172
  11. package/dist/bp-loader.js +0 -26
  12. package/dist/carousel.js +0 -308
  13. package/dist/code-editor.js +0 -102
  14. package/dist/color-input.js +0 -112
  15. package/dist/data-table.js +0 -774
  16. package/dist/drag-and-drop.js +0 -386
  17. package/dist/editable-rect.js +0 -450
  18. package/dist/filter-builder.js +0 -468
  19. package/dist/float.js +0 -170
  20. package/dist/form.js +0 -466
  21. package/dist/gamepad.js +0 -115
  22. package/dist/icon-data.js +0 -308
  23. package/dist/icon-types.js +0 -1
  24. package/dist/icons.js +0 -374
  25. package/dist/index-iife.js +0 -4
  26. package/dist/live-example.js +0 -611
  27. package/dist/localize.js +0 -381
  28. package/dist/make-sorter.js +0 -119
  29. package/dist/make-sorter.test.d.ts +0 -1
  30. package/dist/make-sorter.test.js +0 -48
  31. package/dist/mapbox.js +0 -161
  32. package/dist/markdown-viewer.js +0 -173
  33. package/dist/match-shortcut.js +0 -13
  34. package/dist/match-shortcut.test.d.ts +0 -1
  35. package/dist/match-shortcut.test.js +0 -194
  36. package/dist/menu.js +0 -614
  37. package/dist/notifications.js +0 -308
  38. package/dist/password-strength.js +0 -302
  39. package/dist/playwright.config.d.ts +0 -9
  40. package/dist/playwright.config.js +0 -73
  41. package/dist/pop-float.js +0 -231
  42. package/dist/rating.js +0 -192
  43. package/dist/rich-text.js +0 -296
  44. package/dist/segmented.js +0 -298
  45. package/dist/select.js +0 -427
  46. package/dist/side-nav.js +0 -106
  47. package/dist/size-break.js +0 -118
  48. package/dist/sizer.js +0 -92
  49. package/dist/src/ab-test.d.ts +0 -14
  50. package/dist/src/babylon-3d.d.ts +0 -53
  51. package/dist/src/bodymovin-player.d.ts +0 -32
  52. package/dist/src/bp-loader.d.ts +0 -0
  53. package/dist/src/carousel.d.ts +0 -113
  54. package/dist/src/code-editor.d.ts +0 -27
  55. package/dist/src/color-input.d.ts +0 -41
  56. package/dist/src/data-table.d.ts +0 -79
  57. package/dist/src/drag-and-drop.d.ts +0 -2
  58. package/dist/src/editable-rect.d.ts +0 -97
  59. package/dist/src/filter-builder.d.ts +0 -64
  60. package/dist/src/float.d.ts +0 -18
  61. package/dist/src/form.d.ts +0 -68
  62. package/dist/src/gamepad.d.ts +0 -34
  63. package/dist/src/icon-data.d.ts +0 -309
  64. package/dist/src/icon-types.d.ts +0 -7
  65. package/dist/src/icons.d.ts +0 -17
  66. package/dist/src/index.d.ts +0 -37
  67. package/dist/src/live-example.d.ts +0 -51
  68. package/dist/src/localize.d.ts +0 -30
  69. package/dist/src/make-sorter.d.ts +0 -3
  70. package/dist/src/mapbox.d.ts +0 -24
  71. package/dist/src/markdown-viewer.d.ts +0 -15
  72. package/dist/src/match-shortcut.d.ts +0 -9
  73. package/dist/src/menu.d.ts +0 -60
  74. package/dist/src/notifications.d.ts +0 -106
  75. package/dist/src/password-strength.d.ts +0 -35
  76. package/dist/src/pop-float.d.ts +0 -10
  77. package/dist/src/rating.d.ts +0 -62
  78. package/dist/src/rich-text.d.ts +0 -28
  79. package/dist/src/segmented.d.ts +0 -80
  80. package/dist/src/select.d.ts +0 -43
  81. package/dist/src/side-nav.d.ts +0 -36
  82. package/dist/src/size-break.d.ts +0 -18
  83. package/dist/src/sizer.d.ts +0 -34
  84. package/dist/src/tab-selector.d.ts +0 -91
  85. package/dist/src/tag-list.d.ts +0 -37
  86. package/dist/src/track-drag.d.ts +0 -5
  87. package/dist/src/version.d.ts +0 -1
  88. package/dist/src/via-tag.d.ts +0 -2
  89. package/dist/tab-selector.js +0 -326
  90. package/dist/tag-list.js +0 -375
  91. package/dist/track-drag.js +0 -143
  92. package/dist/version.js +0 -1
  93. package/dist/via-tag.js +0 -102
@@ -1,143 +0,0 @@
1
- import { elements } from 'xinjs';
2
- /*#
3
- # trackDrag
4
-
5
- Sometimes you want to track a mouse-drag or touch-drag operation without messing around.
6
- This is how the resizeable columns in `<xin-table>` work.
7
-
8
- Just call `trackDrag(event, (dx, dy, event) => { ... })` and you'll get updates on corresponding events until
9
- you return `true` from the event-handler (or, in the case of `touch` events, the last `touch` ends).
10
- For mouse events, a "tracker" element is thrown up in front of everything for the event.
11
-
12
- ```html
13
- <p>
14
- Try dragging the squares…<br>
15
- (You can drag them separately with multi-touch!)
16
- </p>
17
- <div class="draggable" style="top: 20px; left: 40px; background: #f008"></div>
18
- <div class="draggable" style="left: 40%; bottom: 30%; background: #0f08"></div>
19
- <div class="draggable" style="bottom: 30px; right: 10px; background: #00f8"></div>
20
- ```
21
- ```css
22
- .preview {
23
- touch-action: none;
24
- }
25
-
26
- .draggable {
27
- content: ' ';
28
- position: absolute;
29
- width: 50px;
30
- height: 50px;
31
- cursor: move;
32
- }
33
-
34
- .preview p {
35
- position: absolute;
36
- left: 50%;
37
- top: 50%;
38
- transform: translateX(-50%) translateY(-50%);
39
- }
40
- ```
41
- ```js
42
- const { trackDrag } = xinjsui
43
-
44
- function dragItem(event) {
45
- const draggable = event.target
46
- if (draggable.classList.contains('draggable')) {
47
- const x = draggable.offsetLeft
48
- const y = draggable.offsetTop
49
- trackDrag(event, (dx, dy, event) => {
50
- draggable.style.left = (x + dx) + 'px'
51
- draggable.style.top = (y + dy) + 'px'
52
- draggable.style.bottom = 'auto'
53
- draggable.style.right = 'auto'
54
- return event.type === 'mouseup'
55
- })
56
- }
57
- }
58
-
59
- preview.addEventListener('mousedown', dragItem )
60
- preview.addEventListener('touchstart', dragItem, { passive: true } )
61
- ```
62
-
63
- For `touch` events, `dx` and `dy` are based on tracking `event.changedTouches[0]` which
64
- is almost certainly what you want.
65
-
66
- To handle multi-touch gestures you will need to track the touches yourself.
67
-
68
- ## bringToFront
69
-
70
- `bringToFront(element: HTMLElement, selector = 'body *')` gives the element the highest
71
- `z-index` of any element matching the selector (which is passed to findHighestZ).
72
-
73
- ## findHighestZ
74
-
75
- `findHighestZ(selector = 'body *'): number` returns the the highest `z-index` of any element
76
- matching `selector`.
77
- */
78
- const TRACKER = elements.div({
79
- style: {
80
- content: ' ',
81
- position: 'fixed',
82
- top: 0,
83
- left: 0,
84
- right: 0,
85
- bottom: 0,
86
- },
87
- });
88
- const PASSIVE = { passive: true };
89
- export const trackDrag = (event, callback, cursor = 'move') => {
90
- const isTouchEvent = event.type.startsWith('touch');
91
- if (!isTouchEvent) {
92
- const origX = event.clientX;
93
- const origY = event.clientY;
94
- TRACKER.style.cursor = cursor;
95
- bringToFront(TRACKER);
96
- document.body.append(TRACKER);
97
- const wrappedCallback = (event) => {
98
- const dx = event.clientX - origX;
99
- const dy = event.clientY - origY;
100
- if (callback(dx, dy, event) === true) {
101
- TRACKER.removeEventListener('mousemove', wrappedCallback);
102
- TRACKER.removeEventListener('mouseup', wrappedCallback);
103
- TRACKER.remove();
104
- }
105
- };
106
- TRACKER.addEventListener('mousemove', wrappedCallback, PASSIVE);
107
- TRACKER.addEventListener('mouseup', wrappedCallback, PASSIVE);
108
- }
109
- else if (event instanceof TouchEvent) {
110
- const touch = event.changedTouches[0];
111
- const touchId = touch.identifier;
112
- const origX = touch.clientX;
113
- const origY = touch.clientY;
114
- const target = event.target;
115
- let dx = 0;
116
- let dy = 0;
117
- const wrappedCallback = (event) => {
118
- const touch = [...event.touches].find((touch) => touch.identifier === touchId);
119
- if (touch !== undefined) {
120
- dx = touch.clientX - origX;
121
- dy = touch.clientY - origY;
122
- }
123
- if (event.type === 'touchmove') {
124
- event.stopPropagation();
125
- event.preventDefault();
126
- }
127
- if (callback(dx, dy, event) === true || touch === undefined) {
128
- target.removeEventListener('touchmove', wrappedCallback);
129
- target.removeEventListener('touchend', wrappedCallback);
130
- target.removeEventListener('touchcancel', wrappedCallback);
131
- }
132
- };
133
- target.addEventListener('touchmove', wrappedCallback);
134
- target.addEventListener('touchend', wrappedCallback, PASSIVE);
135
- target.addEventListener('touchcancel', wrappedCallback, PASSIVE);
136
- }
137
- };
138
- export const findHighestZ = (selector = 'body *') => [...document.querySelectorAll(selector)]
139
- .map((elt) => parseFloat(getComputedStyle(elt).zIndex))
140
- .reduce((z, highest) => (isNaN(z) || Number(z) < highest ? highest : Number(z)), 0);
141
- export const bringToFront = (element, selector = 'body *') => {
142
- element.style.zIndex = String(findHighestZ(selector) + 1);
143
- };
package/dist/version.js DELETED
@@ -1 +0,0 @@
1
- export const version = '0.9.15';
package/dist/via-tag.js DELETED
@@ -1,102 +0,0 @@
1
- /*#
2
- # scriptTag & styleSheet
3
-
4
- ## scriptTag
5
-
6
- If you need to load an old school (cjs) javascript or css library via cdn then use these two functions.
7
-
8
- `xinjs-ui` uses this library to implement the `<xin-code>`, `<xin-lottie>`, and `<xin-map>`
9
- elements.
10
-
11
- `scriptTag()` and `styleSheet()` return promises that resolve `globalThis` when the module in question
12
- has loaded and otherwise behave as much like `import()` as possible.
13
-
14
- This example uses `scriptTag` and `styleSheet` to load [quilljs](https://quilljs.com) on-the-fly.
15
-
16
- ```js
17
- const { elements } = xinjs
18
- const { scriptTag, styleSheet } = xinjsui
19
-
20
- const toolbarOptions = [
21
- [{ header: [1, 2, 3, 4, false] }],
22
- ['blockquote', 'code-block'],
23
- [{ 'align': [] }],
24
- ['bold', 'italic', 'strike'],
25
- ['link', 'image', 'video'],
26
- [{ 'list': 'ordered'}, { 'list': 'bullet' }, { 'list': 'check' }],
27
- [{ 'indent': '-1'}, { 'indent': '+1' }],
28
- ['clean']
29
- ]
30
-
31
- ;(async () => {
32
- await Promise.all([
33
- styleSheet('https://cdn.jsdelivr.net/npm/quill@2.0.2/dist/quill.core.css'),
34
- styleSheet('https://cdn.jsdelivr.net/npm/quill@2.0.2/dist/quill.snow.css'),
35
- ])
36
-
37
- const container = elements.div()
38
- const { Quill } = await scriptTag('https://cdn.jsdelivr.net/npm/quill@2.0.2/dist/quill.js')
39
- preview.append(container)
40
-
41
- const quill = new Quill(container, {
42
- debug: 'info',
43
- modules: {
44
- toolbar: toolbarOptions,
45
- },
46
- theme: 'snow',
47
- })
48
- })()
49
- ```
50
-
51
- Note that `scriptTag` will resolve `globalThis` so it behaves as much like async `import()`
52
- as possible.
53
-
54
- As an aside:
55
-
56
- `<xin-lottie>` is implemented in such a way that if you've preloaded the module
57
- (e.g. via a script tag or packaging) it won't load it again, which affords offline
58
- use.
59
-
60
- There's no point for `<xin-map>` since it won't work without connectivity anyway.
61
-
62
- ## styleSheet
63
-
64
- styleSheet creates a `<link>` tag for a specified css file.
65
-
66
- Using `styleSheet`:
67
-
68
- styleSheet('../path/to/style.css')
69
-
70
- This is awaitable, if you care. The stylesheet `<link>` will only be inserted _once_.
71
- */
72
- import { elements } from 'xinjs';
73
- const loadedScripts = {};
74
- export function scriptTag(src, existingSymbolName) {
75
- if (loadedScripts[src] === undefined) {
76
- if (existingSymbolName !== undefined) {
77
- const existing = globalThis[existingSymbolName];
78
- loadedScripts[src] = Promise.resolve({ [existingSymbolName]: existing });
79
- }
80
- const scriptElt = elements.script({ src });
81
- document.head.append(scriptElt);
82
- loadedScripts[src] = new Promise((resolve) => {
83
- scriptElt.onload = () => resolve(globalThis);
84
- });
85
- }
86
- return loadedScripts[src];
87
- }
88
- const loadedStyleSheets = {};
89
- export function styleSheet(href) {
90
- if (loadedStyleSheets[href] === undefined) {
91
- const linkElement = elements.link({
92
- rel: 'stylesheet',
93
- type: 'text/css',
94
- href,
95
- });
96
- document.head.append(linkElement);
97
- loadedStyleSheets[href] = new Promise((resolve) => {
98
- linkElement.onload = resolve;
99
- });
100
- }
101
- return loadedStyleSheets[href];
102
- }