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
package/dist/icons.js DELETED
@@ -1,374 +0,0 @@
1
- /*#
2
- # icons
3
-
4
- <div class="center">
5
- <xin-icon icon="settings" style="--xin-icon-size: 128px"></xin-icon>
6
- <xin-icon icon="xrColor" style="--xin-icon-size: 96px"></xin-icon>
7
- <xin-icon icon="rgb" style="--xin-icon-size: 128px"></xin-icon>
8
- </div>
9
-
10
- A library that provides `ElementCreator` functions that produce SVG icons. It leverages `xinjs`'s
11
- `svgElements` proxy and is intended to address all the key use-cases for SVG icons in web
12
- applications along with being very easy to extend and maintain.
13
-
14
- > ### Supported Use Cases
15
- > - inline SVGs that can be styled by CSS (for buttons, etc.)
16
- > - allows both stroked and filled icons (unlike font-based systems)
17
- > - No build process magic needed (it's "just javascript")
18
- > - highly optimized and compressible
19
- > - support for color icons (without requiring multiple glyphs perfectly aligned)
20
- > - icons can be rendered as data urls, e.g. to insert into CSS…
21
-
22
- ## icons
23
-
24
- `icons` is a proxy that generates an `ElementCreator` for a given icon on demand,
25
- e.g. `icons.chevronDown()` produces an `<svg>` element containing a downward-pointing chevron
26
- icon with the class `icon-chevron-down`.
27
-
28
- ```js
29
- const { icons, svgIcon } = xinjsui
30
- const { div } = xinjs.elements
31
-
32
- preview.append(...Object.keys(icons).sort().map(iconName => div(
33
- { class: 'tile' },
34
- svgIcon({icon: iconName, size: 24}),
35
- div(iconName)
36
- )))
37
- ```
38
- ```css
39
- .preview {
40
- display: grid;
41
- grid-template-columns: calc(33% - 5px) calc(33% - 5px) calc(33% - 5px);
42
- flex-wrap: wrap;
43
- padding: var(--spacing);
44
- gap: var(--spacing);
45
- overflow: hidden scroll !important;
46
- }
47
-
48
- .preview .tile {
49
- display: flex;
50
- text-align: center;
51
- cursor: pointer;
52
- background: #fff8;
53
- padding: 10px;
54
- gap: 10px;
55
- border-radius: 5px;
56
- }
57
-
58
- .preview .tile:hover {
59
- background: white;
60
- color: var(--brand-color);
61
- }
62
-
63
- .preview .tile > div {
64
- font-family: Menlo, Monaco, monospace;
65
- whitespace: no-wrap;
66
- overflow: hidden;
67
- text-overflow: ellipsis;
68
- font-size: 14px;
69
- line-height: 1.5;
70
- }
71
-
72
- .preview .tile xin-icon {
73
- font-size: 24px;
74
- }
75
- ```
76
-
77
- These icons are completely unstyled and can be colored using the css `fill` property. This will
78
- probably be broken out as a standalone library to allow the use of whatever icons you like
79
- (its source data is currently generated from an [icomoon](https://icomoon.com/app)
80
- `selection.json` file, but could just as easily be generated from a directory full of SVGs).
81
-
82
- ## Adding and redefining icons
83
-
84
- Simply pass a map of icon names to svg source strings…
85
-
86
- ```
87
- defineIcons({
88
- someIcon: '<svg ....',
89
- otherIcon: '<svg ...',
90
- })
91
- ```
92
-
93
- ### Icon Classes
94
-
95
- Icons will be generated with the class `xin-icon`.
96
-
97
- You can also assign the classes `filled`, `stroked`, and `color` to icons to set default
98
- icon styling.
99
-
100
- ## `<xin-icon>`
101
-
102
- `<xin-icon>` is a simple component that lets you embed icons as HTML. Check the CSS tab to see
103
- how it's styled.
104
-
105
- `<xin-icon>` supports four attributes:
106
-
107
- - `size` (defaults to 0) if non-zero sets the height of the icon in pixels
108
- - `icon` is the name of the icon
109
- - `color` is the fill color (if you don't want to style it using CSS)
110
- - `stroke` is the stroke color
111
- - `stroke-width` (defaults to 1) is the width of the stroke assuming the icon's viewBox is 1024 units tall but the
112
- icon is rendered at 32px (so it's multiplied by 32).
113
-
114
- > **Aside**: the tool used to build the icon library scales up the viewBox to 1024 tall and then rounds
115
- > all coordinates to nearest integer on the assumption that this is plenty precise enough for icons and
116
- > makes everything smaller and easier to compress.
117
-
118
- ## SVGs as data-urls
119
-
120
- ```js
121
- const { elements } = xinjs
122
- const { icons, svg2DataUrl } = xinjsui
123
-
124
- preview.append(
125
- elements.span({
126
- style: {
127
- display: 'inline-block',
128
- width: '120px',
129
- height: '24px',
130
- content: '" "',
131
- background: svg2DataUrl(icons.star(), 'none', '#bbb', 3)
132
- }
133
- }),
134
- elements.span({
135
- style: {
136
- display: 'inline-block',
137
- width: '120px',
138
- height: '24px',
139
- content: '" "',
140
- background: svg2DataUrl(icons.star(), 'gold', 'orange', 2)
141
- }
142
- }),
143
- elements.span({
144
- style: {
145
- display: 'inline-block',
146
- width: '100px',
147
- height: '200px',
148
- content: '" "',
149
- background: svg2DataUrl(icons.tosi())
150
- }
151
- }),
152
- )
153
- ```
154
-
155
- `svg2DataUrl(svg: SVGElement, fill?: string, stroke?: string): string` is provided as a
156
- utility for converting SVG elements into data-urls (e.g. for incorporation into
157
- CSS properties. (It's used by the `<xin-3d>` component to render the XR widget.)
158
-
159
- If you're using `SVGElement`s created using the `icons` proxy, you'll want to provide `fill` and/or
160
- `stroke` values, because images loaded via css properties cannot be styled.
161
-
162
- ## Color Icons
163
-
164
- ```html
165
- <xin-icon icon="tosiFavicon" class="demo-icon"></xin-icon>
166
- <xin-icon icon="tosiPlatform" class="demo-icon recolored"></xin-icon>
167
- <xin-icon icon="tosiXr" class="demo-icon animated"></xin-icon>
168
- ```
169
- ```css
170
- .demo-icon {
171
- --xin-icon-size: 160px
172
- }
173
-
174
- .recolored > svg {
175
- pointer-events: all;
176
- transition: 0.25s ease-out;
177
- transform: scale(1);
178
- filter: grayscale(0.5)
179
- }
180
-
181
- .recolored:hover > svg {
182
- opacity: 1;
183
- transform: scale(1.1);
184
- filter: grayscale(0);
185
- }
186
-
187
- .animated > svg {
188
- animation: 2s linear 0s infinite rainbow;
189
- }
190
-
191
- @keyframes rainbow {
192
- 0% {
193
- filter: hue-rotate(0deg);
194
- }
195
- 100% {
196
- filter: hue-rotate(360deg);
197
- }
198
- }
199
- ```
200
-
201
- Colored icons have the `color` class added to them, so you can easily create css rules
202
- that, for example, treat all colored icons inside buttons the same way.
203
-
204
- > Earlier versions of this library replaced color specifications with CSS-variables in a
205
- > very convoluted way, but in practice this isn't terribly useful as SVG properties can't
206
- > be animated by CSS, so this functionality has been stripped out.
207
-
208
- ## Missing Icons
209
-
210
- If you ask for an icon that isn't defined, the `icons` proxy will print a warning to console
211
- and render a `square` (in fact, `icons.square()`) as a fallback.
212
-
213
- ## Why?
214
-
215
- My evolution has been:
216
-
217
- 1. Using Icomoon.io, which I still think is a solid choice for managing custom icon fonts
218
- 2. Processing Icomoon selection.json files into icon-data and then generating SVGs dynamically
219
- from the data
220
- 3. Ingesting SVGs directly, with a little cleanup
221
-
222
- The goal is always to have a single source of truth for icons, no magic or convoluted tooling, and
223
- be able to quickly and easily add and replace icons, distribute them with components, and
224
- have no mess or fuss.
225
-
226
- 1. Works well, but…
227
- - color icons are flaky,
228
- - doesn't play well with others,
229
- - can't really distribute the icons with your components.
230
- - difficult to use icons in CSS `content`
231
- - impossible to use icons in CSS backgrounds
232
- 2. This is `icons.ts` until just now! Solves all the above, but…
233
- - no fancy SVG effects, like gradients (goodness knows I experimented with converting CSS gradients to SVG gradients) and, most
234
- - **strokes** need to be converted to outlines
235
- - outlined strokes can't be styled the way strokes can
236
- - blocks use of popular icon libraries
237
- 3. This is how everyone else works, except…
238
- - no build magic needed: `defineIcons({ myIcon: '<svg....>', ... })`
239
- - if you want build magic, `icons.js` has no dependencies, finds icons and creates an `icon-data.ts` file.
240
- - smaller icon files, even though I'm now including more icons (including *all the current* feathericons)
241
-
242
- ## Icon Sources
243
-
244
- Many of these icons are sourced from [Feather Icons](https://github.com/feathericons/feather), but
245
- all the icons have been processed to have integer coordinates in a `viewBox` typically scaled to 1024 &times; 1024.
246
-
247
- The corporate logos (Google, etc.) are from a variety of sources, in many cases ultimately from the
248
- organizations themselves. It's up to you to use them correctly.
249
-
250
- The remaining icons I have created myself using the excellent but sometimes flawed
251
- [Amadine](https://apps.apple.com/us/app/amadine-vector-design-art/id1339198386?mt=12)
252
- and generally reliable [Graphic](https://apps.apple.com/us/app/graphic/id404705039?mt=12).
253
-
254
- ### Feather Icons Copyright Notice
255
-
256
- The MIT License (MIT)
257
-
258
- Copyright (c) 2013-2023 Cole Bemis
259
-
260
- Permission is hereby granted, free of charge, to any person obtaining a copy
261
- of this software and associated documentation files (the "Software"), to deal
262
- in the Software without restriction, including without limitation the rights
263
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
264
- copies of the Software, and to permit persons to whom the Software is
265
- furnished to do so, subject to the following conditions:
266
-
267
- The above copyright notice and this permission notice shall be included in all
268
- copies or substantial portions of the Software.
269
- */
270
- import { elements, svgElements, Component as WebComponent, Color, varDefault, } from 'xinjs';
271
- import iconData from './icon-data';
272
- const { svg, path } = svgElements;
273
- export const defineIcons = (newIcons) => {
274
- Object.assign(iconData, newIcons);
275
- };
276
- export const svg2DataUrl = (svg, fill, stroke, strokeWidth = 1) => {
277
- svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
278
- if (fill || stroke) {
279
- for (const path of [...svg.querySelectorAll('path, polygon')]) {
280
- if (fill) {
281
- path.setAttribute('fill', fill);
282
- }
283
- if (stroke) {
284
- path.setAttribute('stroke', stroke);
285
- path.setAttribute('stroke-width', strokeWidth);
286
- }
287
- }
288
- }
289
- const styled = svg.querySelectorAll('[style]');
290
- svg.removeAttribute('style');
291
- for (const item of [...styled]) {
292
- const { fill, stroke, strokeWidth, strokeLinecap, strokeLinejoin } = item.style;
293
- if (fill)
294
- item.setAttribute('fill', Color.fromCss(fill).html);
295
- if (stroke)
296
- item.setAttribute('stroke', Color.fromCss(stroke).html);
297
- if (strokeWidth)
298
- item.setAttribute('strokeWidth', strokeWidth);
299
- if (strokeLinecap)
300
- item.setAttribute('strokeLinecap', strokeLinecap);
301
- if (strokeLinejoin)
302
- item.setAttribute('strokeLinejoin', strokeLinejoin);
303
- item.removeAttribute('style');
304
- }
305
- const text = encodeURIComponent(svg.outerHTML);
306
- return `url(data:image/svg+xml;charset=UTF-8,${text})`;
307
- };
308
- export const icons = new Proxy(iconData, {
309
- get(target, prop) {
310
- if (prop && !iconData[prop]) {
311
- console.warn(`icon ${prop} does not exist`);
312
- }
313
- const iconSpec = iconData[prop] || iconData.square;
314
- return (...parts) => {
315
- const div = elements.div();
316
- div.innerHTML = iconSpec;
317
- const sourceSvg = div.querySelector('svg');
318
- const classes = new Set(sourceSvg.classList);
319
- classes.add('xin-icon');
320
- const svg = svgElements.svg({
321
- class: Array.from(classes).join(' '),
322
- viewBox: sourceSvg.getAttribute('viewBox'),
323
- }, ...parts, ...sourceSvg.children);
324
- svg.style.strokeWidth = varDefault.xinIconStrokeWidth('2px');
325
- svg.style.stroke = varDefault.xinIconStroke(classes.has('filled') ? 'none' : 'currentColor');
326
- svg.style.fill = varDefault.xinIconFill(classes.has('stroked') ? 'none' : 'currentColor');
327
- svg.style.height = varDefault.xinIconSize('16px');
328
- return svg;
329
- };
330
- },
331
- });
332
- export class SvgIcon extends WebComponent {
333
- icon = '';
334
- size = 0;
335
- fill = '';
336
- stroke = '';
337
- strokeWidth = 1;
338
- constructor() {
339
- super();
340
- this.initAttributes('icon', 'size', 'fill', 'stroke', 'strokeWidth');
341
- }
342
- render() {
343
- this.textContent = '';
344
- const style = {};
345
- if (this.size) {
346
- style.height = this.size;
347
- this.style.setProperty('--xin-icon-size', `${this.size}px`);
348
- }
349
- if (this.stroke) {
350
- style.stroke = this.stroke;
351
- style.strokeWidth = this.strokeWidth;
352
- }
353
- style.fill = this.fill;
354
- this.append(icons[this.icon]({ style }));
355
- }
356
- }
357
- export const svgIcon = SvgIcon.elementCreator({
358
- tag: 'xin-icon',
359
- styleSpec: {
360
- ':host': {
361
- display: 'inline-flex',
362
- },
363
- ':host, :host svg': {
364
- height: varDefault.xinIconSize('16px'),
365
- },
366
- ':host': {
367
- stroke: 'currentColor',
368
- strokeWidth: varDefault.iconStrokeWidth('2px'),
369
- strokeLinejoin: varDefault.iconStrokeLinejoin('round'),
370
- strokeLinecap: varDefault.iconStrokeLinecap('round'),
371
- fill: varDefault.iconFill('none'),
372
- },
373
- },
374
- });
@@ -1,4 +0,0 @@
1
- import * as xinjsui from './index';
2
- import * as xinjs from 'xinjs';
3
- console.log('foobar');
4
- Object.assign(globalThis, { xinjs, xinjsui });