native-document 1.0.166 → 1.0.168

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 (108) hide show
  1. package/.vitepress/config.js +166 -0
  2. package/CHANGELOG.md +153 -0
  3. package/components.js +2 -1
  4. package/dist/native-document.components.min.js +495 -228
  5. package/dist/native-document.dev.js +7 -0
  6. package/dist/native-document.dev.js.map +1 -1
  7. package/dist/native-document.min.js +1 -1
  8. package/docs/advanced-components.md +213 -608
  9. package/docs/anchor.md +173 -312
  10. package/docs/cache.md +95 -803
  11. package/docs/cli.md +179 -0
  12. package/docs/components/accordion.md +172 -0
  13. package/docs/components/alert.md +99 -0
  14. package/docs/components/avatar.md +160 -0
  15. package/docs/components/badge.md +102 -0
  16. package/docs/components/breadcrumb.md +89 -0
  17. package/docs/components/button.md +183 -0
  18. package/docs/components/card.md +69 -0
  19. package/docs/components/context-menu.md +118 -0
  20. package/docs/components/data-table.md +345 -0
  21. package/docs/components/dropdown.md +214 -0
  22. package/docs/components/form/autocomplete-field.md +81 -0
  23. package/docs/components/form/checkbox-field.md +41 -0
  24. package/docs/components/form/checkbox-group-field.md +54 -0
  25. package/docs/components/form/color-field.md +64 -0
  26. package/docs/components/form/date-field.md +92 -0
  27. package/docs/components/form/field-collection.md +63 -0
  28. package/docs/components/form/file-field.md +203 -0
  29. package/docs/components/form/form-control.md +87 -0
  30. package/docs/components/form/image-field.md +90 -0
  31. package/docs/components/form/index.md +115 -0
  32. package/docs/components/form/number-field.md +65 -0
  33. package/docs/components/form/radio-field.md +51 -0
  34. package/docs/components/form/select-field.md +123 -0
  35. package/docs/components/form/slider.md +136 -0
  36. package/docs/components/form/string-field.md +134 -0
  37. package/docs/components/form/textarea-field.md +65 -0
  38. package/docs/components/form-fields.md +372 -0
  39. package/docs/components/getting-started.md +264 -0
  40. package/docs/components/index.md +337 -0
  41. package/docs/components/layout.md +279 -0
  42. package/docs/components/list.md +73 -0
  43. package/docs/components/menu.md +215 -0
  44. package/docs/components/modal.md +156 -0
  45. package/docs/components/pagination.md +95 -0
  46. package/docs/components/popover.md +131 -0
  47. package/docs/components/progress.md +111 -0
  48. package/docs/components/shortcut-manager.md +221 -0
  49. package/docs/components/simple-table.md +107 -0
  50. package/docs/components/skeleton.md +155 -0
  51. package/docs/components/spinner.md +100 -0
  52. package/docs/components/splitter.md +133 -0
  53. package/docs/components/stepper.md +163 -0
  54. package/docs/components/switch.md +113 -0
  55. package/docs/components/tabs.md +153 -0
  56. package/docs/components/toast.md +119 -0
  57. package/docs/components/tooltip.md +151 -0
  58. package/docs/components/traits.md +261 -0
  59. package/docs/conditional-rendering.md +170 -588
  60. package/docs/contributing.md +300 -25
  61. package/docs/core-concepts.md +205 -374
  62. package/docs/elements.md +251 -367
  63. package/docs/extending-native-document-element.md +192 -207
  64. package/docs/filters.md +153 -1122
  65. package/docs/getting-started.md +193 -267
  66. package/docs/i18n.md +241 -0
  67. package/docs/index.md +76 -0
  68. package/docs/lifecycle-events.md +143 -75
  69. package/docs/list-rendering.md +227 -852
  70. package/docs/memory-management.md +134 -47
  71. package/docs/native-document-element.md +337 -186
  72. package/docs/native-fetch.md +99 -630
  73. package/docs/observable-resource.md +364 -0
  74. package/docs/observables.md +592 -526
  75. package/docs/routing.md +244 -653
  76. package/docs/state-management.md +134 -241
  77. package/docs/svg-elements.md +231 -0
  78. package/docs/theming.md +409 -0
  79. package/docs/tutorials/.gitkeep +0 -0
  80. package/docs/validation.md +95 -97
  81. package/docs/vitepress-conventions.md +219 -0
  82. package/package.json +34 -13
  83. package/readme.md +269 -89
  84. package/src/components/card/Card.js +93 -39
  85. package/src/components/card/index.js +1 -1
  86. package/src/components/list/HasListItem.js +171 -0
  87. package/src/components/list/List.js +41 -107
  88. package/src/components/list/ListDivider.js +39 -0
  89. package/src/components/list/ListGroup.js +76 -59
  90. package/src/components/list/ListItem.js +117 -69
  91. package/src/components/list/index.js +3 -1
  92. package/src/components/list/types/ListItem.d.ts +45 -34
  93. package/src/components/spacer/Spacer.js +1 -1
  94. package/src/core/data/ObservableResource.js +5 -0
  95. package/src/core/data/observable-helpers/observable.prototypes.js +2 -0
  96. package/src/ui/components/card/CardRender.js +133 -0
  97. package/src/ui/components/card/card.css +169 -0
  98. package/src/ui/components/contextmenu/ContextmenuRender.js +1 -1
  99. package/src/ui/components/list/ListRender.js +18 -0
  100. package/src/ui/components/list/divider/ListDividerRender.js +10 -0
  101. package/src/ui/components/list/divider/list-divider.css +12 -0
  102. package/src/ui/components/list/group/ListGroupRender.js +61 -0
  103. package/src/ui/components/list/group/list-group.css +62 -0
  104. package/src/ui/components/list/item/ListItemRender.js +238 -0
  105. package/src/ui/components/list/item/list-item.css +191 -0
  106. package/src/ui/components/list/list.css +24 -0
  107. package/src/ui/components/spacer/SpacerRender.js +10 -0
  108. package/src/ui/index.js +8 -0
package/docs/cli.md ADDED
@@ -0,0 +1,179 @@
1
+ ---
2
+ title: CLI
3
+ description: The official NativeDocument CLI for scaffolding projects, pages, components, and services
4
+ ---
5
+
6
+ # CLI
7
+
8
+ The official NativeDocument CLI scaffolds projects, pages, components, and services so you can focus on building.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install -g @native-document/cli
14
+ ```
15
+
16
+ Verify:
17
+
18
+ ```bash
19
+ nd --help
20
+ ```
21
+
22
+ > Source: [github.com/afrocodeur/native-document-cli](https://github.com/afrocodeur/native-document-cli)
23
+
24
+ ---
25
+
26
+ ## `nd create` - New Project
27
+
28
+ ### Default structure
29
+
30
+ ```bash
31
+ nd create MyApp
32
+ cd MyApp
33
+ npm install
34
+ npm start
35
+ ```
36
+
37
+ ### Feature-based structure
38
+
39
+ ```bash
40
+ nd create MyApp --feature
41
+ ```
42
+
43
+ Use `--feature` when you want to organize code by domain feature rather than by file type.
44
+
45
+ ---
46
+
47
+ ## Project Structures
48
+
49
+ ### Default
50
+
51
+ ```
52
+ src/
53
+ ├── main.js
54
+ ├── index.css
55
+ ├── core/
56
+ │ ├── lang/
57
+ │ │ ├── lang.js
58
+ │ │ └── locales/
59
+ │ │ ├── en.json
60
+ │ │ └── fr.json
61
+ │ ├── middlewares/
62
+ │ └── services/
63
+ ├── routes/
64
+ │ ├── routes.js
65
+ │ └── layouts/
66
+ │ └── DefaultLayout/
67
+ ├── components/
68
+ ├── pages/
69
+ │ ├── home/
70
+ │ │ ├── HomePage.js
71
+ │ │ └── home.css
72
+ │ └── not-found/
73
+ │ ├── NotFoundPage.js
74
+ │ └── not-found.css
75
+ └── services/
76
+ ```
77
+
78
+ ### Feature-based (`--feature`)
79
+
80
+ Same root structure, plus a `src/features/` folder. Each feature is self-contained:
81
+
82
+ ```
83
+ src/features/auth/
84
+ ├── components/
85
+ ├── services/
86
+ │ └── AuthService/
87
+ │ └── AuthService.js
88
+ ├── utils/
89
+ └── index.js # public API - import from here
90
+ ```
91
+
92
+ Import from a feature via its public API:
93
+
94
+ ```javascript
95
+ import { AuthService } from '@/features/auth';
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Generator Commands
101
+
102
+ ### `nd create:page`
103
+
104
+ Scaffold a new page:
105
+
106
+ ```bash
107
+ nd create:page dashboard
108
+ nd create:page user/profile # nested page
109
+ ```
110
+
111
+ Generates a page folder with component and CSS file inside `src/pages/`.
112
+
113
+ ### `nd create:component`
114
+
115
+ Scaffold a reusable component:
116
+
117
+ ```bash
118
+ nd create:component UserCard
119
+ nd create:component ui/Button # nested component
120
+ ```
121
+
122
+ Generates a component folder inside `src/components/`.
123
+
124
+ ### `nd create:service`
125
+
126
+ Scaffold a service (business logic + observables):
127
+
128
+ ```bash
129
+ nd create:service AuthService
130
+ nd create:service api/UserService
131
+ ```
132
+
133
+ Generates a service folder inside `src/services/`.
134
+
135
+ ### `nd create:feature` (feature mode only)
136
+
137
+ Scaffold a complete feature module:
138
+
139
+ ```bash
140
+ nd create:feature auth
141
+ nd create:feature cart
142
+ ```
143
+
144
+ Generates a feature folder inside `src/features/` with its own components, services, and `index.js`.
145
+
146
+ ---
147
+
148
+ ## Available Scripts
149
+
150
+ After creating a project:
151
+
152
+ ```bash
153
+ npm start # start development server (Vite)
154
+ npm run build # build for production
155
+ npm run preview # preview the production build
156
+ npm run lint # run ESLint
157
+ npm run i18n:scan # scan for missing translation keys
158
+ ```
159
+
160
+ ---
161
+
162
+ ## Aliases
163
+
164
+ The `@` alias points to `src/` and is pre-configured in Vite:
165
+
166
+ ```javascript
167
+ import { AuthService } from '@/services/AuthService';
168
+ import { UserCard } from '@/components/UserCard';
169
+ import { AuthService } from '@/features/auth'; // feature mode
170
+ ```
171
+
172
+ ---
173
+
174
+ ## Next Steps
175
+
176
+ - **[Getting Started](./getting-started.md)** - First steps after `nd create`
177
+ - **[Routing](./routing.md)** - Define routes in `src/routes/routes.js`
178
+ - **[State Management](./state-management.md)** - Organize state with Store groups
179
+ - **[i18n & Formatting](./i18n.md)** - Set up translations and locale formatting
@@ -0,0 +1,172 @@
1
+ ---
2
+ title: Accordion
3
+ description: Headless Accordion component with multiple expand, variants, and item management
4
+ ---
5
+
6
+ # Accordion
7
+
8
+ ```javascript
9
+ import { Accordion, AccordionItem } from 'native-document/components';
10
+ ```
11
+
12
+ ```javascript
13
+ Accordion(props?)
14
+ ```
15
+
16
+
17
+ ## Default Renderers
18
+
19
+ ```javascript
20
+ import { AccordionRender, AccordionItemRender } from 'native-document/ui';
21
+
22
+ Accordion.use(AccordionRender);
23
+ AccordionItem.use(AccordionItemRender);
24
+ ```
25
+
26
+ ---
27
+
28
+ ## `$description`
29
+
30
+ ```javascript
31
+ {
32
+ items: [], // AccordionItem[]
33
+ multiple: null, // boolean - allow multiple open at once
34
+ variant: null, // string
35
+ renderContent: null, // (item) => element - custom content renderer
36
+ renderIndicator: null, // (item) => element - custom indicator renderer
37
+ props: {} // HTML attributes for the root element
38
+ }
39
+ ```
40
+
41
+ ## Methods
42
+
43
+ ### Adding items
44
+
45
+ ```javascript
46
+ // Add by title + content
47
+ Accordion()
48
+ .item('Section 1', Div('Content 1'))
49
+ .item('Section 2', Div('Content 2'), { expanded: true, disabled: false })
50
+
51
+ // Add AccordionItem instance
52
+ Accordion()
53
+ .item(
54
+ AccordionItem()
55
+ .title('Section')
56
+ .content(Div('Content'))
57
+ )
58
+
59
+ // Add multiple at once
60
+ Accordion()
61
+ .items([
62
+ { title: 'A', content: Div('Content A') },
63
+ { title: 'B', content: Div('Content B') }
64
+ ])
65
+ ```
66
+
67
+ ### Behavior
68
+
69
+ ```javascript
70
+ .multiple() // allow multiple panels open at once
71
+ .multiple(false) // only one panel at a time (default)
72
+ ```
73
+
74
+ ### Variants
75
+
76
+ ```javascript
77
+ .bordered() // adds borders
78
+ .separated() // space between items
79
+ .flush() // no borders, no padding
80
+ ```
81
+
82
+ ### Expand / Collapse
83
+
84
+ ```javascript
85
+ .expanded(key, true) // expand item by key
86
+ .expanded(key, false) // collapse item by key
87
+ .expandAll()
88
+ .collapseAll()
89
+ .isExpanded(key) // returns boolean
90
+ .getByKey(key) // returns AccordionItem
91
+ ```
92
+
93
+ ### Remove items
94
+
95
+ ```javascript
96
+ .removeItemById(id)
97
+ .remove(item => item.id === 'my-id') // filter function
98
+ ```
99
+
100
+ ### Events
101
+
102
+ ```javascript
103
+ Accordion()
104
+ .onExpand((item) => console.log('Expanded:', item.title))
105
+ .onCollapse((item) => console.log('Collapsed:', item.title))
106
+ ```
107
+
108
+ ### Custom renderers
109
+
110
+ ```javascript
111
+ .renderContent(($item) => Div({ class: 'custom-body' }, $item.content))
112
+ .renderIndicator(($item) => $item.expanded.transform(e => e ? '-' : '+'))
113
+ ```
114
+
115
+ ## `AccordionItem`
116
+
117
+ ```javascript
118
+ AccordionItem()
119
+ .identifyBy('item-1')
120
+ .title('Section Title')
121
+ .content(Div('Content'))
122
+ .icon(InfoIcon)
123
+ .expanded()
124
+ .collapsible()
125
+ .disabled()
126
+ .showIndicator()
127
+ .renderHeader(($item) => Div({ class: 'header' }, $item.title))
128
+ .renderContent(($item) => Div({ class: 'body' }, $item.content))
129
+ .renderIndicator(($item) => $item.expanded.transform(e => e ? '-' : '+'))
130
+ .onExpand(() => console.log('Expanded'))
131
+ .onCollapse(() => console.log('Collapsed'))
132
+ ```
133
+
134
+ ## Example
135
+
136
+ ```javascript
137
+ const faq = Accordion()
138
+ .bordered()
139
+ .item('What is NativeDocument?',
140
+ P('A reactive JavaScript framework without Virtual DOM.')
141
+ )
142
+ .item('How do I install it?',
143
+ Div([
144
+ P('Use the CLI:'),
145
+ Pre('nd create my-app')
146
+ ]),
147
+ { expanded: true }
148
+ )
149
+ .item('Is it free?', P('Yes, MIT licensed.'))
150
+ .onExpand(item => trackFAQ(item.id))
151
+
152
+ document.body.appendChild(faq)
153
+ ```
154
+
155
+ ---
156
+
157
+ ## Theming
158
+
159
+ ```css
160
+ :root {
161
+ --accordion-border: var(--gray-lite-3);
162
+ --accordion-radius: var(--radius-card);
163
+ --accordion-font-size: var(--description-size);
164
+ --accordion-header-padding: var(--space-comfortable);
165
+ --accordion-content-padding: var(--space-comfortable);
166
+ --accordion-header-color: var(--text-color);
167
+ --accordion-header-color-hover: var(--text-color);
168
+ --accordion-header-bg-hover: var(--gray-lite-5);
169
+ --accordion-indicator-color: var(--gray);
170
+ --accordion-transition: 0.2s ease;
171
+ }
172
+ ```
@@ -0,0 +1,99 @@
1
+ ---
2
+ title: Alert
3
+ description: Contextual message component with title, icon, actions, and auto-dismiss
4
+ ---
5
+
6
+ # Alert
7
+
8
+ ```javascript
9
+ import { Alert } from 'native-document/components';
10
+
11
+ Alert(content, props?)
12
+ ```
13
+
14
+ Displays a contextual message with optional title, icon, and actions.
15
+
16
+ ## Default Renderer
17
+
18
+ ```javascript
19
+ import { AlertRender } from 'native-document/ui';
20
+ import { ButtonRender } from 'native-document/ui';
21
+
22
+ Alert.use(AlertRender);
23
+ Button.use(ButtonRender); // required - actions are rendered as buttons
24
+ ```
25
+
26
+ ## Methods
27
+
28
+ ```javascript
29
+ // Type
30
+ .info()
31
+ .success()
32
+ .warning()
33
+ .error()
34
+ .danger()
35
+
36
+ // Appearance
37
+ .filled()
38
+ .bordered()
39
+ .outline()
40
+
41
+ // Content
42
+ .title('Alert title')
43
+ .content(Div('Updated content'))
44
+ .icon(InfoIcon)
45
+ .showIcon()
46
+ .closable()
47
+ .dismissible()
48
+ .autoDismiss(3000)
49
+
50
+ // Actions
51
+ .action('Undo', () => undo())
52
+ .action('Retry', retryFn)
53
+ .clearActions()
54
+
55
+ // Events
56
+ .onClose(() => console.log('Closed'))
57
+ .onShow(() => console.log('Shown'))
58
+
59
+ // Programmatic
60
+ .close()
61
+ .show()
62
+
63
+ // Custom renderers
64
+ .renderTitle(($description) => Strong($description.title))
65
+ .renderContent(($description) => P($description.content))
66
+ .renderFooter(($description) => Div($description.actions))
67
+ .layout(($description) => Div([$description.title, $description.content, $description.footer]))
68
+ ```
69
+
70
+ ## Example
71
+
72
+ ```javascript
73
+ Alert('Your changes have been saved successfully.')
74
+ .success()
75
+ .filled()
76
+ .title('Saved!')
77
+ .icon(CheckIcon)
78
+ .action('Undo', () => undo())
79
+ ```
80
+
81
+ ---
82
+
83
+ ## Theming
84
+
85
+ ```css
86
+ :root {
87
+ --alert-padding: var(--space-comfortable);
88
+ --alert-radius: var(--radius-card);
89
+ --alert-gap: var(--space-cozy);
90
+ --alert-font-size: var(--description-size);
91
+ --alert-title-size: var(--text-size);
92
+ --alert-title-weight: 600;
93
+ --alert-border-width: 1px;
94
+ --alert-color-info: var(--color-info);
95
+ --alert-color-success: var(--color-success);
96
+ --alert-color-warning: var(--color-warning);
97
+ --alert-color-danger: var(--color-danger);
98
+ }
99
+ ```
@@ -0,0 +1,160 @@
1
+ ---
2
+ title: Avatar
3
+ description: Avatar and AvatarGroup components for displaying user profile pictures, initials, or icons
4
+ ---
5
+
6
+ # Avatar
7
+
8
+ ```javascript
9
+ import { Avatar, AvatarGroup } from 'native-document/components';
10
+
11
+ Avatar(source?, props?)
12
+ ```
13
+
14
+ ## Default Renderer
15
+
16
+ ```javascript
17
+ import { AvatarRender, AvatarGroupRender } from 'native-document/ui';
18
+
19
+ Avatar.use(AvatarRender);
20
+ AvatarGroup.use(AvatarGroupRender);
21
+ ```
22
+
23
+ ## `$description`
24
+
25
+ ```javascript
26
+ {
27
+ src: null, // string | Observable<string>
28
+ alt: null,
29
+ name: null, // full name - initials auto-generated
30
+ initials: null, // explicit initials override
31
+ icon: null, // DOM element fallback
32
+ size: 'medium', // 'xs' | 'small' | 'medium' | 'large' | 'xl'
33
+ shape: 'circle', // 'circle' | 'square' | 'rounded'
34
+ variant: null, // background color variant
35
+ color: null, // custom background color
36
+ textColor: null,
37
+ status: null, // 'online' | 'offline' | 'busy' | 'away'
38
+ props: {} // HTML attributes for the root element
39
+ }
40
+ ```
41
+
42
+ ## Methods
43
+
44
+ ```javascript
45
+ // Source
46
+ .src('/images/alice.jpg')
47
+ .src(Observable('/api/user/avatar')) // reactive
48
+ .alt('Alice Johnson')
49
+
50
+ // Name & initials
51
+ .name('Alice Johnson') // auto-generates initials 'AJ'
52
+ .initials('AJ') // explicit initials
53
+
54
+ // Fallback when no src
55
+ .icon(UserIcon)
56
+
57
+ // Size
58
+ .extraSmall()
59
+ .small()
60
+ .medium()
61
+ .large()
62
+ .extraLarge()
63
+
64
+ // Shape
65
+ .circle()
66
+ .square()
67
+ .rounded()
68
+
69
+ // Color (for initials/icon fallback)
70
+ .primary()
71
+ .success()
72
+ .danger()
73
+ .warning()
74
+ .info()
75
+ .color('#6366f1')
76
+ .textColor('#fff')
77
+
78
+ // Status indicator
79
+ .status('online') // green dot
80
+ .status('offline') // gray dot
81
+ .status('busy') // red dot
82
+ .status('away') // yellow dot
83
+ .statusAtTopLeading()
84
+ .statusAtBottomLeading()
85
+ .statusAtTopTrailing()
86
+ .statusAtBottomTrailing()
87
+ ```
88
+
89
+ ## Example
90
+
91
+ ```javascript
92
+ Avatar(user.avatar)
93
+ .name(user.name)
94
+ .status(user.status)
95
+ .large()
96
+
97
+ // With initials fallback
98
+ Avatar()
99
+ .name('Alice Johnson')
100
+ .primary()
101
+ .circle()
102
+ ```
103
+
104
+ ---
105
+
106
+ ## `AvatarGroup`
107
+
108
+ ```javascript
109
+ AvatarGroup(props?)
110
+ ```
111
+
112
+ Displays a stack of overlapping avatars.
113
+
114
+ ### Methods
115
+
116
+ ```javascript
117
+ .item(avatar) // add an Avatar instance
118
+ .items([avatar1, avatar2]) // add multiple
119
+ .max(5) // show max N avatars, then "+N more"
120
+ .overlap(12) // overlap in px
121
+ .onMoreClick((count) => showAll()) // callback when "+N" is clicked
122
+ ```
123
+
124
+ ### Example
125
+
126
+ ```javascript
127
+ AvatarGroup()
128
+ .item(Avatar(user1.avatar).name(user1.name))
129
+ .item(Avatar(user2.avatar).name(user2.name))
130
+ .item(Avatar(user3.avatar).name(user3.name))
131
+ .max(5)
132
+ .overlap(12)
133
+ .onMoreClick((count) => showAllMembers())
134
+ ```
135
+
136
+ ---
137
+
138
+ ## Theming
139
+
140
+ ```css
141
+ :root {
142
+ --avatar-size-extra-small: 24px;
143
+ --avatar-size-small: 32px;
144
+ --avatar-size-medium: 40px;
145
+ --avatar-size-large: 56px;
146
+ --avatar-size-extra-large: 72px;
147
+ --avatar-status-size: 10px;
148
+ --avatar-status-offset: 1px;
149
+ --avatar-color-primary: var(--color-primary);
150
+ --avatar-color-secondary: var(--color-secondary);
151
+ --avatar-color-success: var(--color-success);
152
+ --avatar-color-danger: var(--color-danger);
153
+ --avatar-color-warning: var(--color-warning);
154
+ --avatar-color-info: var(--color-info);
155
+ /* AvatarGroup */
156
+ --avatar-group-overlap: -15px;
157
+ --avatar-group-more-text-color: var(--white);
158
+ --avatar-group-more-background-color: var(--gray-lite-4);
159
+ }
160
+ ```
@@ -0,0 +1,102 @@
1
+ ---
2
+ title: Badge
3
+ description: Small inline label for status, count, or category
4
+ ---
5
+
6
+ # Badge
7
+
8
+ ```javascript
9
+ import { Badge } from 'native-document/components';
10
+
11
+ Badge(content, props?)
12
+ ```
13
+
14
+ A small inline label for status, count, or category.
15
+
16
+ ## Default Renderer
17
+
18
+ ```javascript
19
+ import { BadgeRender } from 'native-document/ui';
20
+
21
+ Badge.use(BadgeRender);
22
+ ```
23
+
24
+ ## `$description`
25
+
26
+ ```javascript
27
+ {
28
+ appearance: 'filled', // 'filled' | 'outlined' | 'ghost'
29
+ borderRadiusType: 'pill',
30
+ variant: 'primary',
31
+ size: 'medium',
32
+ content: null,
33
+ icon: null,
34
+ iconPosition: 'leading',
35
+ props: {} // HTML attributes for the root element
36
+ }
37
+ ```
38
+
39
+ ## Methods
40
+
41
+ ```javascript
42
+ // Variants
43
+ .primary()
44
+ .secondary()
45
+ .success()
46
+ .danger()
47
+ .warning()
48
+ .info()
49
+
50
+ // Appearance
51
+ .filled()
52
+ .outlined()
53
+ .ghost()
54
+
55
+ // Size
56
+ .small()
57
+ .medium()
58
+ .large()
59
+
60
+ // Shape
61
+ .rounded()
62
+ .pill()
63
+ .circle()
64
+
65
+ // Icon
66
+ .icon(element, position?)
67
+
68
+ // Event
69
+ .onClick(handler)
70
+ ```
71
+
72
+ ## Example
73
+
74
+ ```javascript
75
+ Badge('New').primary().pill()
76
+ Badge(count).danger()
77
+ Badge('Beta').outlined().warning()
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Theming
83
+
84
+ ```css
85
+ :root {
86
+ --badge-height-small: 18px;
87
+ --badge-height-medium: 22px;
88
+ --badge-height-large: 28px;
89
+ --badge-padding-small: 0 var(--space-cozy);
90
+ --badge-padding-medium: 0 var(--space-cozy-comfortable);
91
+ --badge-padding-large: 0 var(--space-comfortable);
92
+ --badge-font-size-small: var(--diablo-size);
93
+ --badge-font-size-medium: var(--note-size);
94
+ --badge-font-size-large: var(--description-size);
95
+ --badge-color-primary: var(--color-primary);
96
+ --badge-color-secondary: var(--color-secondary);
97
+ --badge-color-success: var(--color-success);
98
+ --badge-color-danger: var(--color-danger);
99
+ --badge-color-warning: var(--color-warning);
100
+ --badge-color-info: var(--color-info);
101
+ }
102
+ ```