@avlcodemonkey/nilla-components 0.0.0-stage → 0.0.1

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 (94) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/LICENSE +21 -0
  3. package/README.md +219 -3
  4. package/THIRD_PARTY_NOTICES.md +48 -0
  5. package/css/alert.css +48 -0
  6. package/css/autocomplete.css +38 -0
  7. package/css/dialog.css +61 -0
  8. package/css/file-to-textarea.css +8 -0
  9. package/css/html-editor.css +172 -0
  10. package/css/json.css +44 -0
  11. package/css/list.css +37 -0
  12. package/css/nav-toggle.css +92 -0
  13. package/css/nilla.css +16 -0
  14. package/css/pjax.css +58 -0
  15. package/css/slider-input.css +16 -0
  16. package/css/table.css +99 -0
  17. package/css/tokens.css +44 -0
  18. package/css/unsaved-changes.css +10 -0
  19. package/css/vendor/wysi.css +406 -0
  20. package/docs/llms.txt +319 -0
  21. package/package.json +121 -5
  22. package/src/components/Alert.js +24 -0
  23. package/src/components/Autocomplete.js +127 -0
  24. package/src/components/BaseComponent.js +78 -0
  25. package/src/components/BaseDialog.js +151 -0
  26. package/src/components/ConfirmDialog.js +34 -0
  27. package/src/components/CopyToClipboard.js +66 -0
  28. package/src/components/DateFormatter.js +51 -0
  29. package/src/components/DateTimeInput.js +63 -0
  30. package/src/components/DisplayToggle.js +53 -0
  31. package/src/components/FileToTextarea.js +81 -0
  32. package/src/components/HtmlEditor.js +309 -0
  33. package/src/components/InfoDialog.js +38 -0
  34. package/src/components/JsonFormatter.js +23 -0
  35. package/src/components/List.js +237 -0
  36. package/src/components/ListSortable.js +8 -0
  37. package/src/components/NavToggle.js +119 -0
  38. package/src/components/PJax.js +888 -0
  39. package/src/components/Share.js +41 -0
  40. package/src/components/SliderInput.js +26 -0
  41. package/src/components/Table.js +758 -0
  42. package/src/components/TimeOffsetSelect.js +29 -0
  43. package/src/components/UnsavedChanges.js +187 -0
  44. package/src/constants/Fetch.js +7 -0
  45. package/src/constants/HttpHeaders.js +19 -0
  46. package/src/constants/HttpMethods.js +14 -0
  47. package/src/constants/SortDirection.js +11 -0
  48. package/src/constants/TableElements.js +25 -0
  49. package/src/constants/TableSettings.js +14 -0
  50. package/src/errors/FetchError.js +7 -0
  51. package/src/events/ListReorderEvent.js +19 -0
  52. package/src/events/PJaxErrorEvent.js +38 -0
  53. package/src/events/PJaxNavigatingEvent.js +46 -0
  54. package/src/index.js +26 -0
  55. package/src/locales/en.json +55 -0
  56. package/src/locales/es.js +9 -0
  57. package/src/locales/es.json +55 -0
  58. package/src/models/TableSort.js +20 -0
  59. package/src/utils/ajaxHeaders.js +10 -0
  60. package/src/utils/announce.js +40 -0
  61. package/src/utils/defineElement.js +13 -0
  62. package/src/utils/editor/blockTools.js +256 -0
  63. package/src/utils/editor/elements.js +18 -0
  64. package/src/utils/editor/input.js +350 -0
  65. package/src/utils/editor/selection.js +125 -0
  66. package/src/utils/editor/tableTools.js +497 -0
  67. package/src/utils/escape.js +20 -0
  68. package/src/utils/fetchJsonArray.js +29 -0
  69. package/src/utils/filterArray.js +18 -0
  70. package/src/utils/formActionUrl.js +10 -0
  71. package/src/utils/formData.js +118 -0
  72. package/src/utils/index.js +18 -0
  73. package/src/utils/indexedCompare.js +18 -0
  74. package/src/utils/isSameOrigin.js +12 -0
  75. package/src/utils/locale.js +36 -0
  76. package/src/utils/notifyChange.js +10 -0
  77. package/src/utils/numberSetting.js +14 -0
  78. package/src/utils/pageLanguage.js +13 -0
  79. package/src/utils/parseUtcDate.js +22 -0
  80. package/src/utils/randomId.js +17 -0
  81. package/src/utils/registerTabTrap.js +60 -0
  82. package/src/utils/renderTemplate.js +44 -0
  83. package/src/utils/requestTimeout.js +12 -0
  84. package/src/utils/response.js +28 -0
  85. package/src/utils/sortedCompare.js +67 -0
  86. package/src/utils/storage.js +40 -0
  87. package/src/vendor/autocomplete.js +515 -0
  88. package/src/vendor/formatDate.js +236 -0
  89. package/src/vendor/licenses/autocomplete.LICENSE.md +21 -0
  90. package/src/vendor/licenses/fecha.LICENSE.md +21 -0
  91. package/src/vendor/licenses/pretty-print-json.LICENSE.md +21 -0
  92. package/src/vendor/licenses/wysi.LICENSE.md +21 -0
  93. package/src/vendor/prettyPrintJson.js +108 -0
  94. package/src/vendor/wyzi.js +2024 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here.
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project follows
5
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.1.0] - 2026-12-01
8
+
9
+ First release.
10
+
11
+ ### Components
12
+
13
+ - **Page behavior:** `<nilla-pjax>` (navigation and form submits over fetch, with redirects, title and head tags, scroll
14
+ and history handling), `<nilla-unsaved-changes>`, `<nilla-nav-toggle>`, `<nilla-display-toggle>`, `<nilla-alert>`.
15
+ - **Data:** `<nilla-table>` (server-side paging, sorting, search, and filter forms), `<nilla-autocomplete>`, `<nilla-list>`,
16
+ and `list-sortable` for drag-and-drop through an optional SortableJS.
17
+ - **Dialogs:** `<nilla-confirm>` and `<nilla-info>`, built on the native `<dialog>` element and a shared `BaseDialog`.
18
+ - **Inputs:** `<nilla-html-editor>` (a modified Wysi, sanitized with DOMPurify), `<nilla-datetime-input>`,
19
+ `<nilla-slider-input>`, `<nilla-time-offset>`, `<nilla-file-to-textarea>`.
20
+ - **Display and helpers:** `<nilla-date>`, `<nilla-json>`, `<nilla-copy-to-clipboard>`, `<nilla-share>`.
21
+ - `BaseComponent` and `BaseDialog` are exported for building your own components.
22
+
23
+ ### Package
24
+
25
+ - One stylesheet per component, plus `nilla.css` for all of them. Colors and spacing come from `--nilla-*` tokens with
26
+ light and dark values, and the CSS never sets page-wide styles.
27
+ - Utilities under `./utils`, constants, custom events (`nilla:<component>-<action>`), and error types as separate exports.
28
+ - English text, with Spanish in `locales/es`, picked by the page's `lang`.
29
+ - Typed with JSDoc and checked with `@ts-check`, with no build step for consumers.
30
+ - `docs/llms.txt` for AI tools, and a documentation site with live demos.
31
+ - Published to npm from a GitHub release with provenance.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 avlcodemonkey
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,219 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # Nilla Components
2
+
3
+ [![Main](https://github.com/AvlCodeMonkey-Industries/NillaComponents/actions/workflows/main.yml/badge.svg)](https://github.com/AvlCodeMonkey-Industries/NillaComponents/actions/workflows/main.yml)
4
+ [![npm](https://img.shields.io/npm/v/@avlcodemonkey/nilla-components)](https://www.npmjs.com/package/@avlcodemonkey/nilla-components)
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
+
7
+ Vanilla JavaScript web components that enhance plain, server-rendered HTML. No framework, and no build step required.
8
+
9
+ Each component is a custom element that wraps ordinary markup: forms, links, tables, and buttons. The page still works before the
10
+ JavaScript loads. Components find their parts through `data-*` attributes rather than class names, and the CSS styles native
11
+ elements and those same attributes, so it fits with whatever CSS framework you already use.
12
+
13
+ **[Docs and live demos](https://avlcodemonkey-industries.github.io/NillaComponents/)**
14
+
15
+ ## Components
16
+
17
+ | Component | Tag | Import |
18
+ | --- | --- | --- |
19
+ | Alert | `<nilla-alert>` | `alert` |
20
+ | Autocomplete | `<nilla-autocomplete>` | `autocomplete` |
21
+ | Confirm dialog | `<nilla-confirm>` | `confirm-dialog` |
22
+ | Copy to clipboard | `<nilla-copy-to-clipboard>` | `copy-to-clipboard` |
23
+ | Date formatter | `<nilla-date>` | `date-formatter` |
24
+ | Date time input | `<nilla-datetime-input>` | `datetime-input` |
25
+ | Display toggle | `<nilla-display-toggle>` | `display-toggle` |
26
+ | File to textarea | `<nilla-file-to-textarea>` | `file-to-textarea` |
27
+ | HTML editor | `<nilla-html-editor>` | `html-editor` |
28
+ | Info dialog | `<nilla-info>` | `info-dialog` |
29
+ | JSON formatter | `<nilla-json>` | `json-formatter` |
30
+ | List | `<nilla-list>` | `list`, or `list-sortable` for drag-and-drop |
31
+ | Nav toggle | `<nilla-nav-toggle>` | `nav-toggle` |
32
+ | PJax | `<nilla-pjax>` | `pjax` |
33
+ | Share | `<nilla-share>` | `share` |
34
+ | Slider input | `<nilla-slider-input>` | `slider-input` |
35
+ | Table | `<nilla-table>` | `table` |
36
+ | Time offset select | `<nilla-time-offset>` | `time-offset-select` |
37
+ | Unsaved changes | `<nilla-unsaved-changes>` | `unsaved-changes` |
38
+
39
+ `BaseComponent` and `BaseDialog` are exported too, for building your own components.
40
+
41
+ ## Install
42
+
43
+ ```sh
44
+ npm install @avlcodemonkey/nilla-components
45
+ ```
46
+
47
+ Works in current Chrome, Edge, Firefox, and Safari. It relies on ES modules, custom elements, `<dialog>`, `URL.canParse`,
48
+ `AbortSignal.timeout`, `AbortSignal.any`, popovers, JSON modules, and, in the CSS, nesting, `:has()`,
49
+ `light-dark()`, and container queries.
50
+
51
+ Some browser features work only on pages served over HTTPS or from `localhost`: copy to clipboard, the HTML editor's paste
52
+ button, and the share sheet.
53
+
54
+ ### What's included
55
+
56
+ - **Inside the package:** a modified [Wysi](https://github.com/mdbassit/Wysi), and parts of autocomplete, fecha, and
57
+ pretty-print-json. There's nothing to install. See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
58
+ - **Installed with it:** DOMPurify. Only the HTML editor uses it.
59
+ - **Installed by you, if you want it:** SortableJS, for dragging list items: `npm install sortablejs`.
60
+
61
+ Without a bundler, the page needs an import map for DOMPurify and SortableJS.
62
+ [The docs](https://avlcodemonkey-industries.github.io/NillaComponents/#installation) have an example.
63
+
64
+ ## Use with AI
65
+
66
+ Point your AI tool at [llms.txt](https://avlcodemonkey-industries.github.io/NillaComponents/llms.txt), which is also in the package
67
+ as `docs/llms.txt`. [The docs](https://avlcodemonkey-industries.github.io/NillaComponents/#ai) have a prompt to copy.
68
+
69
+ ## Languages
70
+
71
+ The components' own text is in English. For Spanish, import `@avlcodemonkey/nilla-components/locales/es`, and it's used wherever
72
+ the page's `lang` is Spanish. [The docs](https://avlcodemonkey-industries.github.io/NillaComponents/#languages) show how to add
73
+ other languages.
74
+
75
+ ## Usage
76
+
77
+ ### JavaScript
78
+
79
+ Importing a component registers its custom element. Import only what you use, and bundle with esbuild, Vite, or any tool that
80
+ understands ES modules.
81
+
82
+ ```js
83
+ import '@avlcodemonkey/nilla-components/table';
84
+ import '@avlcodemonkey/nilla-components/confirm-dialog';
85
+ import '@avlcodemonkey/nilla-components/list-sortable'; // list with drag-and-drop, needs sortablejs
86
+
87
+ // or register everything
88
+ import '@avlcodemonkey/nilla-components';
89
+
90
+ // helpers the components use
91
+ import { formToObject, renderTemplate } from '@avlcodemonkey/nilla-components/utils';
92
+ ```
93
+
94
+ An esbuild setup like the one these components came from:
95
+
96
+ ```js
97
+ // build.mjs
98
+ import esbuild from 'esbuild';
99
+
100
+ await esbuild.build({
101
+ entryPoints: ['./Assets/js/index.js', './Assets/css/index.css'],
102
+ outdir: 'wwwroot',
103
+ bundle: true,
104
+ minify: true,
105
+ sourcemap: true,
106
+ target: 'esnext',
107
+ });
108
+ ```
109
+
110
+ ### HTML
111
+
112
+ ```html
113
+ <form action="/items/3/delete" method="post">
114
+ <nilla-confirm>
115
+ <button type="submit" data-dialog-content="Delete this item?" data-dialog-ok="Delete" data-dialog-cancel="Keep it">Delete</button>
116
+ </nilla-confirm>
117
+ </form>
118
+
119
+ <nilla-table data-key="items" data-src-url="/items/list" data-sort-property="name">
120
+ <input type="search" data-table-search aria-label="Search">
121
+ <table>
122
+ <thead><tr><th data-property="name">Name</th></tr></thead>
123
+ <tbody>
124
+ <template><tr><td>{{name}}</td></tr></template>
125
+ <tr data-table-status><td><span data-table-loading>Loading…</span><span data-table-empty hidden>No items.</span></td></tr>
126
+ </tbody>
127
+ </table>
128
+ </nilla-table>
129
+ ```
130
+
131
+ See the [docs](https://avlcodemonkey-industries.github.io/NillaComponents/) for every component's markup and attributes, and the
132
+ [server contract](https://avlcodemonkey-industries.github.io/NillaComponents/#server) for what PJax, Table, and Autocomplete
133
+ expect from the server.
134
+
135
+ ### CSS
136
+
137
+ ```css
138
+ /* every component */
139
+ @import url("@avlcodemonkey/nilla-components/css");
140
+
141
+ /* or only what you use: tokens.css plus component files */
142
+ @import url("@avlcodemonkey/nilla-components/css/tokens.css");
143
+ @import url("@avlcodemonkey/nilla-components/css/table.css");
144
+ ```
145
+
146
+ The CSS styles the components only, not the rest of the page, so pair it with your own base styles or framework. Colors and
147
+ spacing come from `--nilla-*` custom properties, which have light and dark values. Override them to theme the components, or
148
+ point them at your framework's variables:
149
+
150
+ ```css
151
+ :root {
152
+ --nilla-primary: #7c3aed;
153
+ --nilla-radius: .5rem;
154
+ }
155
+
156
+ /* or match chota */
157
+ :root {
158
+ --nilla-primary: var(--color-primary);
159
+ --nilla-background: var(--bg-color);
160
+ --nilla-color: var(--font-color);
161
+ }
162
+ ```
163
+
164
+ The light values are used unless your page opts into dark mode with `color-scheme: light dark` (follow the reader's setting) or
165
+ `color-scheme: dark` on `:root`. The package CSS never sets `color-scheme`, so it won't change the rest of your page.
166
+
167
+ ## Development
168
+
169
+ Requires Node 22 or newer.
170
+
171
+ ```sh
172
+ npm install # install dev dependencies
173
+ npm test # run unit tests with coverage (node:test + jsdom)
174
+ npm run lint # ESLint and stylelint
175
+ npm run test:browser # use the docs site in Chrome, and scan it for accessibility problems
176
+ npm run js:fix # fix lint issues that can be fixed automatically
177
+ npm run docs # serve the docs at http://localhost:8080/
178
+ ```
179
+
180
+ ### Project layout
181
+
182
+ ```text
183
+ src/
184
+ components/ custom elements, one per file
185
+ utils/ helper functions, exported from ./utils
186
+ constants/ enums shared by components
187
+ locales/ text, by language
188
+ events/ custom events
189
+ errors/ error types
190
+ models/ data shapes
191
+ vendor/ modified third-party code, with licenses in vendor/licenses
192
+ css/ one stylesheet per component, nilla.css imports them all
193
+ docs/ docs site, served as static files on GitHub Pages
194
+ tests/ unit tests, mirroring src/
195
+ scripts/ docs server, and the script that copies docs/vendor from node_modules
196
+ ```
197
+
198
+ - Components are plain ES modules with JSDoc types, which editors check through `jsconfig.json`, with no compile step.
199
+ - Files use CRLF line endings, except the ones Dependabot updates (`package.json`, `package-lock.json`, and GitHub YAML),
200
+ which use LF. `.gitattributes`, `.editorconfig`, and ESLint enforce this.
201
+ - `npm run docs:vendor` refreshes `docs/vendor` (DOMPurify and SortableJS) after updating those packages.
202
+ - The docs page has its own small stylesheet, `docs/docs.css`, that isn't part of the package.
203
+
204
+ ### Releasing
205
+
206
+ 1. Add the release's notes to `CHANGELOG.md`, and merge to `main`.
207
+ 2. Publish a GitHub release with a tag like `v1.2.0`. Mark it as a prerelease to publish under the `next` dist-tag.
208
+ 3. The [release workflow](.github/workflows/release.yml) tests the code, sets the version from the tag, and publishes to npm with
209
+ provenance, using npm trusted publishing.
210
+
211
+ The docs site deploys to GitHub Pages on every push to `main` that changes `docs/`, `src/`, or `css/`.
212
+
213
+ ## Contributing
214
+
215
+ See [CONTRIBUTING.md](CONTRIBUTING.md). Report security issues as described in [SECURITY.md](SECURITY.md).
216
+
217
+ ## License
218
+
219
+ [MIT](LICENSE). Third-party code included in this package is listed in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
@@ -0,0 +1,48 @@
1
+ # Third-Party Notices
2
+
3
+ Nilla Components is MIT licensed. It includes or uses the third-party software below, each under its own license.
4
+
5
+ ## Included in the package
6
+
7
+ Modified copies of these are in `src/vendor` and `css/vendor`. Their license texts are in `src/vendor/licenses`.
8
+
9
+ | Software | Used for | License | Copyright |
10
+ | --- | --- | --- | --- |
11
+ | [Wysi](https://github.com/mdbassit/Wysi) | HTML editor (`src/vendor/wyzi.js`, `css/vendor/wysi.css`), modified with code, quote, and table tools, and its bold, italic, and delete icons redrawn | MIT | Copyright (c) 2023 Momo Bassit |
12
+ | [autocomplete](https://github.com/denis-taran/autocomplete) | Autocomplete menu (`src/vendor/autocomplete.js`) | MIT | Copyright (c) 2016 Denis Taran |
13
+ | [fecha](https://github.com/taylorhakes/fecha) | Date formatting (`src/vendor/formatDate.js`), a subset | MIT | Copyright (c) 2015 Taylor Hakes |
14
+ | [pretty-print-json](https://pretty-print-json.js.org) | JSON formatting (`src/vendor/prettyPrintJson.js`, `css/json.css`), a subset | MIT | Copyright (c) 2018-2025 Individual contributors to pretty-print-json |
15
+
16
+ ## Dependencies
17
+
18
+ | Package | Used for | License |
19
+ | --- | --- | --- |
20
+ | [DOMPurify](https://github.com/cure53/DOMPurify) | Sanitizing HTML editor content. Installed with this package. | Apache-2.0 or MPL-2.0 |
21
+ | [SortableJS](https://github.com/SortableJS/Sortable) | Dragging list items. Optional peer dependency, installed by you. | MIT |
22
+
23
+ ## Docs site only
24
+
25
+ These are in `docs/vendor` with their licenses, and are not part of the npm package.
26
+
27
+ | Software | Used for | License |
28
+ | --- | --- | --- |
29
+ | [DOMPurify](https://github.com/cure53/DOMPurify) | HTML editor demo | Apache-2.0 or MPL-2.0 |
30
+ | [SortableJS](https://github.com/SortableJS/Sortable) | List demo | MIT |
31
+
32
+ ## MIT License text
33
+
34
+ The MIT-licensed components above are distributed under these terms, with the copyright notices listed above:
35
+
36
+ ```text
37
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
38
+ files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
39
+ modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
40
+ is furnished to do so, subject to the following conditions:
41
+
42
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
43
+
44
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
45
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
46
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
47
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
48
+ ```
package/css/alert.css ADDED
@@ -0,0 +1,48 @@
1
+ /*
2
+ * nilla-alert: wraps any content, and hides itself when a [data-alert-dismiss] button is clicked.
3
+ * Style the inner [role="alert"] or [role="status"] element; set data-variant on the component for success, error, or warning.
4
+ */
5
+ nilla-alert {
6
+ display: block;
7
+
8
+ & [role="alert"],
9
+ & [role="status"] {
10
+ display: flex;
11
+ gap: var(--nilla-spacing);
12
+ align-items: flex-start;
13
+ margin-block-end: var(--nilla-spacing);
14
+ padding: calc(var(--nilla-spacing) * .75) var(--nilla-spacing);
15
+ border-inline-start: .25rem solid var(--nilla-alert-accent, var(--nilla-primary));
16
+ border-radius: var(--nilla-radius);
17
+ background: var(--nilla-surface);
18
+ color: var(--nilla-color);
19
+
20
+ > :first-child {
21
+ flex: 1;
22
+ }
23
+ }
24
+
25
+ &[data-variant="success"] {
26
+ --nilla-alert-accent: var(--nilla-success);
27
+ }
28
+
29
+ &[data-variant="error"] {
30
+ --nilla-alert-accent: var(--nilla-error);
31
+ }
32
+
33
+ &[data-variant="warning"] {
34
+ --nilla-alert-accent: var(--nilla-warning);
35
+ }
36
+
37
+ & [data-alert-dismiss] {
38
+ width: auto;
39
+ margin: 0;
40
+ padding: 0 .25em;
41
+ border: none;
42
+ background: none;
43
+ color: inherit;
44
+ font-size: 1.25em;
45
+ line-height: 1;
46
+ cursor: pointer;
47
+ }
48
+ }
@@ -0,0 +1,38 @@
1
+ /* nilla-autocomplete: the suggestion menu is added to the end of the body with the .autocomplete class. */
2
+ nilla-autocomplete {
3
+ display: block;
4
+ }
5
+
6
+ .autocomplete {
7
+ z-index: 1000;
8
+ overflow: auto;
9
+ box-sizing: border-box;
10
+ border: 1px solid var(--nilla-border);
11
+ border-radius: var(--nilla-radius);
12
+ background: var(--nilla-background);
13
+ box-shadow: var(--nilla-shadow);
14
+ color: var(--nilla-color);
15
+
16
+ & * {
17
+ font: inherit;
18
+ }
19
+
20
+ > div {
21
+ padding: .5em .75em;
22
+ }
23
+
24
+ & .group {
25
+ background: var(--nilla-surface);
26
+ font-weight: bold;
27
+ }
28
+
29
+ & .empty {
30
+ color: var(--nilla-muted);
31
+ }
32
+
33
+ > div:hover:not(.group, .empty),
34
+ > div.selected {
35
+ background: var(--nilla-highlight);
36
+ cursor: pointer;
37
+ }
38
+ }
package/css/dialog.css ADDED
@@ -0,0 +1,61 @@
1
+ /* nilla-info and nilla-confirm open a native <dialog data-nilla-dialog> at the end of the body. */
2
+ nilla-info,
3
+ nilla-confirm {
4
+ display: contents;
5
+ }
6
+
7
+ dialog[data-nilla-dialog] {
8
+ max-width: min(32rem, calc(100vw - 2rem));
9
+ padding: 0;
10
+ border: none;
11
+ border-radius: var(--nilla-radius);
12
+ background: transparent;
13
+ color: var(--nilla-color);
14
+ box-shadow: var(--nilla-shadow);
15
+
16
+ &::backdrop {
17
+ background: rgb(0 0 0 / 50%);
18
+ backdrop-filter: blur(.125rem);
19
+ }
20
+
21
+ > article {
22
+ margin: 0;
23
+ padding: calc(var(--nilla-spacing) * 1.5);
24
+ border-radius: var(--nilla-radius);
25
+ background: var(--nilla-background);
26
+
27
+ > p {
28
+ margin-block: 0 var(--nilla-spacing);
29
+
30
+ /* messages are plain text, so line breaks in the attribute are how they get paragraphs */
31
+ white-space: pre-line;
32
+ }
33
+ }
34
+
35
+ & form {
36
+ margin: 0;
37
+ }
38
+
39
+ & footer {
40
+ display: flex;
41
+ flex-wrap: wrap;
42
+ gap: calc(var(--nilla-spacing) / 2);
43
+ justify-content: flex-end;
44
+ margin: 0;
45
+ padding: 0;
46
+ border: none;
47
+ background: none;
48
+
49
+ > button {
50
+ width: auto;
51
+ margin: 0;
52
+ }
53
+
54
+ /* cancel is the safe choice in a confirm, so it gets focus and the strong style */
55
+ > button[value="ok"]:not(:only-child) {
56
+ border-color: var(--nilla-border);
57
+ background: transparent;
58
+ color: var(--nilla-color);
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,8 @@
1
+ /* nilla-file-to-textarea: reads a text file into a textarea. */
2
+ nilla-file-to-textarea {
3
+ display: block;
4
+
5
+ & [data-file-error] {
6
+ color: var(--nilla-error);
7
+ }
8
+ }
@@ -0,0 +1,172 @@
1
+ /* nilla-html-editor: rich text editor built on Wysi. */
2
+ @import url("./vendor/wysi.css");
3
+
4
+ nilla-html-editor {
5
+ display: block;
6
+ position: relative;
7
+ margin-block-end: var(--nilla-spacing);
8
+
9
+ & [data-html-actions] {
10
+ position: absolute;
11
+ inset-block-start: -2.25em;
12
+ inset-inline-end: 0;
13
+
14
+ & button {
15
+ width: auto;
16
+ margin: 0;
17
+ padding: .25em .75em;
18
+ font-size: .875em;
19
+ }
20
+ }
21
+
22
+ & [data-html-counter] {
23
+ display: block;
24
+ margin-block-start: .25em;
25
+ color: var(--nilla-muted);
26
+ font-size: .875em;
27
+ text-align: end;
28
+
29
+ &[data-warning] {
30
+ color: var(--nilla-warning);
31
+ }
32
+
33
+ &[data-over] {
34
+ color: var(--nilla-error);
35
+ font-weight: bold;
36
+ }
37
+ }
38
+
39
+ & .wysi-wrapper {
40
+ container-type: inline-size;
41
+ outline-color: var(--nilla-border);
42
+ background: var(--nilla-background);
43
+ color: var(--nilla-color);
44
+ }
45
+
46
+ & .wysi-toolbar {
47
+ background: var(--nilla-surface);
48
+ }
49
+
50
+ /* undo page-wide button styles, such as a framework's min-height, so the toolbar keeps Wysi's sizes */
51
+ & .wysi-toolbar button {
52
+ min-width: 0;
53
+ min-height: 0;
54
+ border: none;
55
+ box-shadow: none;
56
+ background: transparent;
57
+ color: inherit;
58
+ line-height: normal;
59
+
60
+ &:hover,
61
+ &:focus {
62
+ background: var(--nilla-background);
63
+ color: inherit;
64
+ }
65
+ }
66
+
67
+ & .wysi-table {
68
+ position: relative;
69
+
70
+ & .wysi-table-toggle {
71
+ justify-content: center;
72
+ width: 2rem;
73
+ }
74
+
75
+ & .wysi-table-menu:not([hidden]) {
76
+ display: flex;
77
+ position: absolute;
78
+ inset-block-start: 100%;
79
+ inset-inline-start: 0;
80
+ z-index: 10;
81
+ flex-direction: column;
82
+ min-width: 14rem;
83
+ padding: .25rem;
84
+ border: 1px solid var(--nilla-border);
85
+ border-radius: var(--nilla-radius);
86
+ background: var(--nilla-background);
87
+ box-shadow: var(--nilla-shadow);
88
+
89
+ & button {
90
+ width: 100%;
91
+ padding: .25rem .75rem;
92
+ text-align: start;
93
+ white-space: nowrap;
94
+
95
+ &:hover,
96
+ &:focus {
97
+ background: var(--nilla-surface);
98
+ }
99
+
100
+ &:disabled {
101
+ opacity: .4;
102
+ cursor: default;
103
+ }
104
+ }
105
+ }
106
+
107
+ & .wysi-table-size {
108
+ display: flex;
109
+ gap: .5rem;
110
+ padding: 0 .75rem .5rem;
111
+ font-size: .875em;
112
+
113
+ & input {
114
+ width: 4.5rem;
115
+ margin: 0;
116
+ }
117
+ }
118
+ }
119
+
120
+ /* where there's no room beside the button, line its menu up with the toolbar */
121
+ @container (width <= 36rem) {
122
+ & .wysi-table,
123
+ & .wysi-popover {
124
+ position: static;
125
+ }
126
+
127
+ & .wysi-table .wysi-table-menu,
128
+ & .wysi-popover div {
129
+ inset-inline-start: 0;
130
+ max-width: 100%;
131
+ transform: none;
132
+ }
133
+
134
+ & .wysi-popover div::before {
135
+ display: none;
136
+ }
137
+ }
138
+
139
+ & .wysi-editor {
140
+ background: var(--nilla-background);
141
+
142
+ & code {
143
+ padding: .1em .3em;
144
+ border: 1px solid var(--nilla-border);
145
+ border-radius: calc(var(--nilla-radius) / 2);
146
+ background: var(--nilla-surface);
147
+ font-family: var(--nilla-font-mono);
148
+ font-size: .9em;
149
+ }
150
+
151
+ & th,
152
+ & td {
153
+ min-width: 4rem;
154
+ height: 2rem;
155
+ border: 1px solid var(--nilla-border);
156
+ }
157
+
158
+ & pre {
159
+ overflow-x: auto;
160
+ padding: .75rem 1rem;
161
+ border: 1px solid var(--nilla-border);
162
+ border-radius: var(--nilla-radius);
163
+ background: var(--nilla-surface);
164
+
165
+ & code {
166
+ padding: 0;
167
+ border: none;
168
+ background: none;
169
+ }
170
+ }
171
+ }
172
+ }