native-document 1.0.168 → 1.0.169

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 (40) hide show
  1. package/CHANGELOG.md +38 -4
  2. package/components.js +3 -1
  3. package/dist/native-document.components.min.js +197 -171
  4. package/dist/native-document.dev.js +92 -75
  5. package/dist/native-document.dev.js.map +1 -1
  6. package/dist/native-document.min.js +1 -1
  7. package/docs/components/icons.md +321 -0
  8. package/package.json +1 -1
  9. package/src/components/form/field/types/FileField.js +3 -3
  10. package/src/components/icon/Icon.js +107 -0
  11. package/src/components/icon/icon-getters.js +142 -0
  12. package/src/components/icon/icons.js +171 -0
  13. package/src/components/icon/index.js +17 -0
  14. package/src/components/icon/types/Icon.d.ts +191 -0
  15. package/src/components/index.d.ts +6 -1
  16. package/src/components/list/types/List.d.ts +45 -32
  17. package/src/components/list/types/ListDivider.ts +16 -0
  18. package/src/components/list/types/ListGroup.d.ts +51 -29
  19. package/src/components/list/types/ListItem.d.ts +20 -21
  20. package/src/core/elements/content-formatter.js +16 -2
  21. package/src/core/elements/form.js +1 -1
  22. package/src/core/elements/img.js +1 -1
  23. package/src/core/elements/medias.js +2 -2
  24. package/src/core/elements/meta-data.js +1 -1
  25. package/src/core/wrappers/AttributesWrapper.js +37 -22
  26. package/src/core/wrappers/ElementCreator.js +9 -16
  27. package/src/core/wrappers/HtmlElementWrapper.js +26 -7
  28. package/src/core/wrappers/NDElement.js +12 -1
  29. package/src/core/wrappers/prototypes/attributes-extensions.js +24 -24
  30. package/src/core/wrappers/prototypes/nd-element-extensions.js +1 -8
  31. package/src/ui/components/icon/material/MaterialIconRender.js +71 -0
  32. package/src/ui/components/icon/material/material.css +15 -0
  33. package/src/ui/components/icon/material/material.map.js +170 -0
  34. package/src/ui/components/icon/phosphor/PhosphorIconRender.js +71 -0
  35. package/src/ui/components/icon/phosphor/phosphor.css +17 -0
  36. package/src/ui/components/icon/phosphor/phosphor.map.js +165 -0
  37. package/src/ui/components/icon/tabler/TablerIconRender.js +59 -0
  38. package/src/ui/components/icon/tabler/tabler.css +14 -0
  39. package/src/ui/components/icon/tabler/tabler.map.js +165 -0
  40. package/src/ui/index.js +5 -0
@@ -0,0 +1,71 @@
1
+ import './phosphor.css';
2
+ import MAP from './phosphor.map.js';
3
+ import { Span } from '../../../../core/elements';
4
+
5
+ const SIZES = {
6
+ small: 16,
7
+ medium: 24,
8
+ large: 32,
9
+ extraLarge: 48,
10
+ };
11
+
12
+ // Variant -> CSS weight class
13
+ // regular uses 'ph' (no suffix), others use 'ph-{variant}'
14
+ const VARIANT_CLASS = {
15
+ thin: 'ph-thin',
16
+ light: 'ph-light',
17
+ regular: 'ph',
18
+ bold: 'ph-bold',
19
+ fill: 'ph-fill',
20
+ duotone: 'ph-duotone',
21
+ };
22
+
23
+ /**
24
+ * Renders a Phosphor icon as a <span> element using CSS webfont classes.
25
+ *
26
+ * Variants: thin, light, regular (default), bold, fill, duotone
27
+ * Each variant requires its own CSS - see phosphor.css.
28
+ *
29
+ * @param {object} $desc
30
+ * @param {string} $desc.name
31
+ * @param {'thin'|'light'|'regular'|'bold'|'fill'|'duotone'|Observable<string>|null} $desc.variant
32
+ * @param {'small'|'medium'|'large'|'extraLarge'|number|Observable<string|number>|null} $desc.size
33
+ * @param {string|Observable<string>|null} $desc.color
34
+ * @returns {HTMLElement}
35
+ */
36
+ export default function PhosphorIconRender($desc) {
37
+ const phosphorName = MAP[$desc.name] ?? $desc.name;
38
+ const style = {};
39
+
40
+ let className;
41
+
42
+ if($desc.variant?.__$Observable) {
43
+ className = $desc.variant.transform((variant) => {
44
+ const weightClass = VARIANT_CLASS[variant] ?? 'ph';
45
+ return `${weightClass} ph-${phosphorName}`;
46
+ });
47
+ } else {
48
+ const weightClass = VARIANT_CLASS[$desc.variant] ?? 'ph';
49
+ className = `${weightClass} ph-${phosphorName}`;
50
+ }
51
+
52
+ if($desc.size?.__$Observable) {
53
+ style.fontSize = $desc.size.transform((size) => {
54
+ const px = typeof size === 'number' ? size : (SIZES[size] ?? SIZES.medium);
55
+ return `${px}px`;
56
+ });
57
+ } else {
58
+ const px = typeof $desc.size === 'number' ? $desc.size : (SIZES[$desc.size] ?? SIZES.medium);
59
+ style.fontSize = `${px}px`;
60
+ }
61
+
62
+ if($desc.color) {
63
+ style.color = $desc.color;
64
+ }
65
+
66
+ return Span({
67
+ 'aria-hidden': 'true',
68
+ class: className,
69
+ style,
70
+ });
71
+ }
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Phosphor Icons webfont
3
+ * Install : npm install @phosphor-icons/web
4
+ *
5
+ * Each variant requires its own CSS file.
6
+ * Import only the variants you need to keep bundle size minimal.
7
+ */
8
+ /*@import '@phosphor-icons/web/src/regular/style.css';*/
9
+
10
+ /*
11
+ * Uncomment the variants you need:
12
+ */
13
+ /* @import '@phosphor-icons/web/src/thin/style.css'; */
14
+ /* @import '@phosphor-icons/web/src/light/style.css'; */
15
+ /* @import '@phosphor-icons/web/src/bold/style.css'; */
16
+ /* @import '@phosphor-icons/web/src/fill/style.css'; */
17
+ /* @import '@phosphor-icons/web/src/duotone/style.css'; */
@@ -0,0 +1,165 @@
1
+ export default {
2
+ // Navigation
3
+ arrowLeft: 'arrow-left',
4
+ arrowRight: 'arrow-right',
5
+ arrowUp: 'arrow-up',
6
+ arrowDown: 'arrow-down',
7
+ chevronLeft: 'caret-left',
8
+ chevronRight: 'caret-right',
9
+ chevronUp: 'caret-up',
10
+ chevronDown: 'caret-down',
11
+ home: 'house',
12
+ menu: 'list',
13
+ close: 'x',
14
+ back: 'arrow-left',
15
+ forward: 'arrow-right',
16
+ expand: 'arrows-out',
17
+ collapse: 'arrows-in',
18
+ fullscreen: 'arrows-out-simple',
19
+ fullscreenExit: 'arrows-in-simple',
20
+
21
+ // Actions
22
+ search: 'magnifying-glass',
23
+ filter: 'funnel',
24
+ sort: 'arrows-down-up',
25
+ edit: 'pencil-simple',
26
+ delete: 'trash',
27
+ add: 'plus',
28
+ remove: 'minus',
29
+ save: 'floppy-disk',
30
+ copy: 'copy',
31
+ download: 'download-simple',
32
+ upload: 'upload-simple',
33
+ share: 'share-network',
34
+ refresh: 'arrows-clockwise',
35
+ more: 'dots-three',
36
+ settings: 'gear-six',
37
+ drag: 'dots-six-vertical',
38
+ resize: 'corners-out',
39
+ undo: 'arrow-counter-clockwise',
40
+ redo: 'arrow-clockwise',
41
+ scan: 'scan',
42
+ print: 'printer',
43
+ import: 'upload',
44
+ export: 'export',
45
+
46
+ // Feedback
47
+ check: 'check',
48
+ checkCircle: 'check-circle',
49
+ error: 'x-circle',
50
+ warning: 'warning',
51
+ info: 'info',
52
+ help: 'question',
53
+ loading: 'circle-notch',
54
+ success: 'check-circle',
55
+
56
+ // User
57
+ user: 'user',
58
+ userCircle: 'user-circle',
59
+ users: 'users',
60
+ lock: 'lock',
61
+ unlock: 'lock-open',
62
+ eye: 'eye',
63
+ eyeOff: 'eye-slash',
64
+ bell: 'bell',
65
+ notification: 'bell-ringing',
66
+
67
+ // Files & Media
68
+ file: 'file',
69
+ folder: 'folder',
70
+ image: 'image',
71
+ document: 'file-text',
72
+ attachment: 'paperclip',
73
+ link: 'link',
74
+ externalLink: 'arrow-square-out',
75
+ play: 'play',
76
+ pause: 'pause',
77
+ stop: 'stop',
78
+ mute: 'speaker-slash',
79
+ sound: 'speaker-high',
80
+ video: 'video',
81
+ camera: 'camera',
82
+
83
+ // Interface
84
+ grid: 'squares-four',
85
+ list: 'list',
86
+ calendar: 'calendar',
87
+ clock: 'clock',
88
+ tag: 'tag',
89
+ tags: 'tag',
90
+ qrCode: 'qr-code',
91
+ barcode: 'barcode',
92
+
93
+ // Text editing
94
+ bold: 'text-b',
95
+ italic: 'text-italic',
96
+ underline: 'text-underline',
97
+ strikethrough: 'text-strikethrough',
98
+ alignLeft: 'text-align-left',
99
+ alignCenter: 'text-align-center',
100
+ alignRight: 'text-align-right',
101
+ alignJustify: 'text-align-justify',
102
+ orderedList: 'list-numbers',
103
+ unorderedList: 'list-bullets',
104
+ indent: 'text-indent',
105
+ outdent: 'text-outdent',
106
+ scissors: 'scissors',
107
+ fontColor: 'text-aa',
108
+ highlight: 'highlighter-circle',
109
+
110
+ // Data & charts
111
+ barChart: 'chart-bar',
112
+ lineChart: 'chart-line',
113
+ pieChart: 'chart-pie',
114
+ areaChart: 'chart-line-up',
115
+ table: 'table',
116
+ database: 'database',
117
+
118
+ // Commerce & finance
119
+ shoppingCart: 'shopping-cart',
120
+ creditCard: 'credit-card',
121
+ wallet: 'wallet',
122
+ bank: 'bank',
123
+ gift: 'gift',
124
+ percentage: 'percent',
125
+ dollar: 'currency-dollar',
126
+ euro: 'currency-eur',
127
+
128
+ // Communication
129
+ mail: 'envelope',
130
+ message: 'chat-text',
131
+ comment: 'chat',
132
+ phone: 'phone',
133
+
134
+ // System & dev
135
+ cloud: 'cloud',
136
+ cloudUpload: 'cloud-arrow-up',
137
+ cloudDownload: 'cloud-arrow-down',
138
+ api: 'plugs',
139
+ code: 'code',
140
+ bug: 'bug',
141
+ tool: 'wrench',
142
+ robot: 'robot',
143
+
144
+ // Location
145
+ map: 'map-trifold',
146
+ compass: 'compass',
147
+ global: 'globe',
148
+ location: 'map-pin',
149
+
150
+ // Shapes & objects
151
+ star: 'star',
152
+ heart: 'heart',
153
+ flag: 'flag',
154
+ trophy: 'trophy',
155
+ medal: 'medal',
156
+ rocket: 'rocket',
157
+ fire: 'fire',
158
+ thunder: 'lightning',
159
+ smile: 'smiley',
160
+ frown: 'smiley-melting',
161
+ like: 'thumbs-up',
162
+ dislike: 'thumbs-down',
163
+ safety: 'shield-check',
164
+ key: 'key',
165
+ };
@@ -0,0 +1,59 @@
1
+ import MAP from './tabler.map.js';
2
+ import {Italic, Span} from '../../../../core/elements';
3
+
4
+ const SIZES = {
5
+ small: 16,
6
+ medium: 24,
7
+ large: 32,
8
+ extraLarge: 48,
9
+ };
10
+
11
+ import './tabler.css';
12
+
13
+ /**
14
+ * Renders a Tabler icon as an <i> element using CSS webfont classes.
15
+ *
16
+ * Variants:
17
+ * - outline (default) : ti ti-{name} requires tabler-icons.css
18
+ * - fill : ti ti-{name}-filled requires tabler-icons-filled.css
19
+ *
20
+ * @param {object} $desc
21
+ * @param {string} $desc.name
22
+ * @param {'outline'|'fill'|null} $desc.variant
23
+ * @param {'small'|'medium'|'large'|'extraLarge'|number|null} $desc.size
24
+ * @param {string|null} $desc.color
25
+ * @returns {HTMLElement}
26
+ */
27
+ export default function TablerIconRender($desc) {
28
+ const tablerName = MAP[$desc.name] ?? $desc.name;
29
+ const style = {};
30
+
31
+ let className = '';
32
+ if($desc.variant?.__$Observable) {
33
+ className = $desc.variant.format((variant) => {
34
+ if(variant === 'fill') {
35
+ return `ti ti-${tablerName}-filled`;
36
+ }
37
+ return `ti ti-${tablerName}`;
38
+ });
39
+ } else {
40
+ className = ($desc.variant === 'fill') ? `ti ti-${tablerName}-filled` : `ti ti-${tablerName}`;
41
+ }
42
+
43
+ let px;
44
+
45
+ style.fontSize = $desc.size?.__$Observable
46
+ ? $desc.size.transform((size) => `${typeof size === 'number' ? size : (SIZES[size] ?? SIZES.medium)}px`)
47
+ : `${typeof $desc.size === 'number' ? $desc.size : (SIZES[$desc.size] ?? SIZES.medium)}px`;
48
+
49
+ if($desc.color) {
50
+ style.color = $desc.color;
51
+ }
52
+ console.log(style);
53
+
54
+ return Italic({
55
+ 'aria-hidden': 'true',
56
+ style,
57
+ class: className,
58
+ });
59
+ }
@@ -0,0 +1,14 @@
1
+ /*
2
+ * Tabler Icons webfont
3
+ * Outline : @tabler/icons-webfont/tabler-icons.css
4
+ * Filled : @tabler/icons-webfont/tabler-icons-filled.css
5
+ *
6
+ * Install : npm install @tabler/icons-webfont
7
+ */
8
+ /*@import '@tabler/icons-webfont/tabler-icons.css';*/
9
+
10
+ /*
11
+ * Uncomment to enable filled variant (ti ti-{name}-filled)
12
+ * Note: filled and outline use separate font files
13
+ */
14
+ /* @import '@tabler/icons-webfont/tabler-icons-filled.css'; */
@@ -0,0 +1,165 @@
1
+ export default {
2
+ // Navigation
3
+ arrowLeft: 'arrow-left',
4
+ arrowRight: 'arrow-right',
5
+ arrowUp: 'arrow-up',
6
+ arrowDown: 'arrow-down',
7
+ chevronLeft: 'chevron-left',
8
+ chevronRight: 'chevron-right',
9
+ chevronUp: 'chevron-up',
10
+ chevronDown: 'chevron-down',
11
+ home: 'home',
12
+ menu: 'menu-2',
13
+ close: 'x',
14
+ back: 'arrow-back',
15
+ forward: 'arrow-forward',
16
+ expand: 'arrows-maximize',
17
+ collapse: 'arrows-minimize',
18
+ fullscreen: 'maximize',
19
+ fullscreenExit: 'minimize',
20
+
21
+ // Actions
22
+ search: 'search',
23
+ filter: 'filter',
24
+ sort: 'arrows-sort',
25
+ edit: 'pencil',
26
+ delete: 'trash',
27
+ add: 'plus',
28
+ remove: 'minus',
29
+ save: 'device-floppy',
30
+ copy: 'copy',
31
+ download: 'download',
32
+ upload: 'upload',
33
+ share: 'share',
34
+ refresh: 'refresh',
35
+ more: 'dots',
36
+ settings: 'settings',
37
+ drag: 'grip-horizontal',
38
+ resize: 'resize',
39
+ undo: 'arrow-back-up',
40
+ redo: 'arrow-forward-up',
41
+ scan: 'scan',
42
+ print: 'printer',
43
+ import: 'file-import',
44
+ export: 'file-export',
45
+
46
+ // Feedback
47
+ check: 'check',
48
+ checkCircle: 'circle-check',
49
+ error: 'circle-x',
50
+ warning: 'alert-triangle',
51
+ info: 'info-circle',
52
+ help: 'help-circle',
53
+ loading: 'loader-2',
54
+ success: 'circle-check',
55
+
56
+ // User
57
+ user: 'user',
58
+ userCircle: 'user-circle',
59
+ users: 'users',
60
+ lock: 'lock',
61
+ unlock: 'lock-open',
62
+ eye: 'eye',
63
+ eyeOff: 'eye-off',
64
+ bell: 'bell',
65
+ notification: 'bell-ringing',
66
+
67
+ // Files & Media
68
+ file: 'file',
69
+ folder: 'folder',
70
+ image: 'photo',
71
+ document: 'file-text',
72
+ attachment: 'paperclip',
73
+ link: 'link',
74
+ externalLink: 'external-link',
75
+ play: 'player-play',
76
+ pause: 'player-pause',
77
+ stop: 'player-stop',
78
+ mute: 'volume-off',
79
+ sound: 'volume',
80
+ video: 'video',
81
+ camera: 'camera',
82
+
83
+ // Interface
84
+ grid: 'layout-grid',
85
+ list: 'list',
86
+ calendar: 'calendar',
87
+ clock: 'clock',
88
+ tag: 'tag',
89
+ tags: 'tags',
90
+ qrCode: 'qrcode',
91
+ barcode: 'barcode',
92
+
93
+ // Text editing
94
+ bold: 'bold',
95
+ italic: 'italic',
96
+ underline: 'underline',
97
+ strikethrough: 'strikethrough',
98
+ alignLeft: 'align-left',
99
+ alignCenter: 'align-center',
100
+ alignRight: 'align-right',
101
+ alignJustify: 'align-justified',
102
+ orderedList: 'list-numbers',
103
+ unorderedList: 'list',
104
+ indent: 'indent-increase',
105
+ outdent: 'indent-decrease',
106
+ scissors: 'scissors',
107
+ fontColor: 'letter-case',
108
+ highlight: 'highlight',
109
+
110
+ // Data & charts
111
+ barChart: 'chart-bar',
112
+ lineChart: 'chart-line',
113
+ pieChart: 'chart-pie',
114
+ areaChart: 'chart-area',
115
+ table: 'table',
116
+ database: 'database',
117
+
118
+ // Commerce & finance
119
+ shoppingCart: 'shopping-cart',
120
+ creditCard: 'credit-card',
121
+ wallet: 'wallet',
122
+ bank: 'building-bank',
123
+ gift: 'gift',
124
+ percentage: 'percentage',
125
+ dollar: 'currency-dollar',
126
+ euro: 'currency-euro',
127
+
128
+ // Communication
129
+ mail: 'mail',
130
+ message: 'message',
131
+ comment: 'message-circle',
132
+ phone: 'phone',
133
+
134
+ // System & dev
135
+ cloud: 'cloud',
136
+ cloudUpload: 'cloud-upload',
137
+ cloudDownload: 'cloud-download',
138
+ api: 'api',
139
+ code: 'code',
140
+ bug: 'bug',
141
+ tool: 'tool',
142
+ robot: 'robot',
143
+
144
+ // Location
145
+ map: 'map',
146
+ compass: 'compass',
147
+ global: 'world',
148
+ location: 'map-pin',
149
+
150
+ // Shapes & objects
151
+ star: 'star',
152
+ heart: 'heart',
153
+ flag: 'flag',
154
+ trophy: 'trophy',
155
+ medal: 'medal',
156
+ rocket: 'rocket',
157
+ fire: 'flame',
158
+ thunder: 'bolt',
159
+ smile: 'mood-smile',
160
+ frown: 'mood-sad',
161
+ like: 'thumb-up',
162
+ dislike: 'thumb-down',
163
+ safety: 'shield-check',
164
+ key: 'key',
165
+ };
package/src/ui/index.js CHANGED
@@ -43,5 +43,10 @@ export { default as ListDividerRender } from './components/list/divider/ListDivi
43
43
 
44
44
  export { default as CardRender } from './components/card/CardRender';
45
45
 
46
+
47
+ export { default as TablerIconRender } from './components/icon/tabler/TablerIconRender';
48
+ export { default as MaterialIconRender } from './components/icon/material/MaterialIconRender';
49
+ export { default as PhosphorIconRender } from './components/icon/phosphor/PhosphorIconRender';
50
+
46
51
  export * from './components/stacks';
47
52
  export * from './components/form';