@vanelsas/baredom 2.5.0 → 2.6.0

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 (103) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +11 -296
  3. package/custom-elements.json +36 -1
  4. package/dist/base.js +38 -38
  5. package/dist/integrity.json +93 -93
  6. package/dist/x-alert.js +17 -17
  7. package/dist/x-avatar-group.js +10 -10
  8. package/dist/x-avatar.js +13 -13
  9. package/dist/x-badge.js +11 -11
  10. package/dist/x-bento-grid.js +5 -5
  11. package/dist/x-bento-item.js +4 -4
  12. package/dist/x-breadcrumbs.js +14 -14
  13. package/dist/x-button.js +15 -15
  14. package/dist/x-cancel-dialogue.js +12 -12
  15. package/dist/x-card.js +7 -7
  16. package/dist/x-carousel.js +28 -28
  17. package/dist/x-chart.js +46 -46
  18. package/dist/x-checkbox.js +11 -11
  19. package/dist/x-chip.js +8 -8
  20. package/dist/x-collapse.js +10 -10
  21. package/dist/x-color-picker.js +40 -40
  22. package/dist/x-combobox.d.ts +1 -0
  23. package/dist/x-combobox.js +25 -25
  24. package/dist/x-command-palette.js +24 -24
  25. package/dist/x-container.js +6 -6
  26. package/dist/x-context-menu.js +18 -18
  27. package/dist/x-copy.js +20 -20
  28. package/dist/x-currency-field.d.ts +1 -0
  29. package/dist/x-currency-field.js +23 -22
  30. package/dist/x-date-picker.js +37 -37
  31. package/dist/x-divider.js +8 -8
  32. package/dist/x-drawer.js +11 -11
  33. package/dist/x-dropdown.js +9 -9
  34. package/dist/x-fieldset.js +5 -5
  35. package/dist/x-file-download.js +7 -7
  36. package/dist/x-file-upload.js +22 -22
  37. package/dist/x-form-field.js +15 -15
  38. package/dist/x-form.js +9 -9
  39. package/dist/x-gaussian-blur.js +16 -16
  40. package/dist/x-grid.js +6 -6
  41. package/dist/x-icon.js +7 -7
  42. package/dist/x-image.js +18 -18
  43. package/dist/x-kinetic-font.js +28 -28
  44. package/dist/x-kinetic-typography.js +37 -37
  45. package/dist/x-liquid-dock.js +35 -35
  46. package/dist/x-liquid-fill.js +40 -40
  47. package/dist/x-liquid-glass.js +35 -35
  48. package/dist/x-menu-item.js +10 -10
  49. package/dist/x-menu.js +10 -10
  50. package/dist/x-metaball-cursor.js +25 -25
  51. package/dist/x-modal.js +11 -11
  52. package/dist/x-morph-stack.js +39 -39
  53. package/dist/x-navbar.js +12 -12
  54. package/dist/x-neural-glow.js +30 -30
  55. package/dist/x-notification-center.js +10 -10
  56. package/dist/x-organic-divider.js +15 -15
  57. package/dist/x-organic-progress.js +35 -35
  58. package/dist/x-organic-shape.js +12 -12
  59. package/dist/x-pagination.d.ts +2 -1
  60. package/dist/x-pagination.js +17 -16
  61. package/dist/x-particle-button.js +46 -46
  62. package/dist/x-popover.js +23 -23
  63. package/dist/x-progress-circle.js +7 -7
  64. package/dist/x-progress.js +7 -7
  65. package/dist/x-radio.js +11 -11
  66. package/dist/x-ripple-effect.js +11 -11
  67. package/dist/x-scroll-parallax.js +17 -17
  68. package/dist/x-scroll-stack.js +18 -18
  69. package/dist/x-scroll-story.js +33 -33
  70. package/dist/x-scroll-timeline.js +44 -44
  71. package/dist/x-scroll.js +39 -39
  72. package/dist/x-search-field.js +15 -15
  73. package/dist/x-select.d.ts +1 -0
  74. package/dist/x-select.js +10 -10
  75. package/dist/x-sidebar.js +16 -16
  76. package/dist/x-skeleton-group.js +13 -13
  77. package/dist/x-skeleton.js +1 -1
  78. package/dist/x-slider.d.ts +1 -0
  79. package/dist/x-slider.js +18 -16
  80. package/dist/x-soft-body.js +20 -20
  81. package/dist/x-spacer.js +5 -5
  82. package/dist/x-spinner.js +5 -5
  83. package/dist/x-splash.js +13 -13
  84. package/dist/x-stat.js +9 -9
  85. package/dist/x-stepper.js +14 -14
  86. package/dist/x-switch.js +10 -10
  87. package/dist/x-tab.js +7 -7
  88. package/dist/x-table-cell.js +19 -19
  89. package/dist/x-table-row.js +10 -10
  90. package/dist/x-table.js +13 -13
  91. package/dist/x-tabs.d.ts +1 -0
  92. package/dist/x-tabs.js +11 -11
  93. package/dist/x-text-area.d.ts +1 -0
  94. package/dist/x-text-area.js +20 -18
  95. package/dist/x-theme.js +24 -24
  96. package/dist/x-timeline-item.js +19 -19
  97. package/dist/x-timeline.js +9 -9
  98. package/dist/x-toast.js +21 -21
  99. package/dist/x-toaster.js +8 -8
  100. package/dist/x-tooltip.js +12 -12
  101. package/dist/x-typography.js +8 -8
  102. package/dist/x-welcome-tour.js +58 -58
  103. package/package.json +6 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to BareDOM will be documented in this file.
4
4
 
5
+ ## [2.6.0] - 2026-04-30
6
+
7
+ ### Added
8
+
9
+ - **Cancelable change-request events** — Seven input components now fire a cancelable `change-request` event before applying user-initiated value changes. Call `preventDefault()` to block the update (enables controlled component patterns in framework adapters). Components: x-slider, x-text-area, x-select, x-combobox, x-currency-field, x-tabs, x-pagination.
10
+
11
+ ### Fixed
12
+
13
+ - **x-context-menu** — Escape key and click-outside now correctly dismiss the menu. Handlers moved from the overlay layer (which has `pointer-events: none`) to document-level listeners.
14
+ - **x-button** — Fixed missing press events on mobile Safari. Added `touch-action: manipulation` and `-webkit-tap-highlight-color: transparent` to the internal button element (reset by `all: unset`).
15
+ - **x-carousel demo** — Control panel now uses correct BareDOM event names (`x-switch-change`, `x-form-field-input`, `select-change`, `press`) instead of native DOM events.
16
+ - **x-welcome-tour test** — Added missing `^js` type hint to fix Closure Advanced compilation warning.
17
+ - **x-combobox** — Fixed undefined category in demo gallery (changed from `"input"` to `"form"`).
18
+
5
19
  ## [2.5.0] - 2026-04-29
6
20
 
7
21
  ### Added
package/README.md CHANGED
@@ -157,228 +157,25 @@ See [docs/x-theme.md](./docs/x-theme.md) for the full token list, preset details
157
157
 
158
158
  ## Installation
159
159
 
160
- > **Using JavaScript?** See the [JavaScript Developer Guide](./docs/javascript-guide.md) for npm/ESM setup, event handling, theming, and framework integration examples (React, Vue, Svelte).
161
-
162
- BareDOM can be consumed three ways: as a **ClojureScript source dependency** (Clojars), as **standalone ES module files** (no build tool required), or as an **npm package**.
163
-
164
- ### Option A — ClojureScript via Clojars
165
-
166
- Add BareDOM to your `deps.edn`:
167
-
168
- ```clojure
169
- {:deps {com.github.avanelsas/baredom {:mvn/version "2.5.0"}}}
170
- ```
171
-
172
- Or in your `shadow-cljs.edn` dependencies:
173
-
174
- ```clojure
175
- :dependencies [[com.github.avanelsas/baredom "2.5.0"]]
176
- ```
177
-
178
- Then require component namespaces directly and call their `init!` function once at startup:
179
-
180
- ```clojure
181
- (ns my-app.core
182
- (:require
183
- [baredom.exports.x-button :as x-button]
184
- [baredom.exports.x-alert :as x-alert]
185
- [baredom.exports.x-toaster :as x-toaster]
186
- [baredom.exports.x-toast :as x-toast]))
187
-
188
- (defn- register-components! []
189
- (x-button/init)
190
- (x-alert/init)
191
- (x-toaster/init)
192
- (x-toast/init))
193
- ```
194
-
195
- Call `register-components!` once in your `init!` entry point. Registration is idempotent — calling `init` on an already-registered element is a no-op.
196
-
197
- ### Option B — Vanilla HTML/JS via ES modules
198
-
199
- No build tool, no npm, no ClojureScript required. Copy the `dist/` folder (from a release or after running `npm run build`) to your web server and load components directly with `<script type="module">`:
200
-
201
- ```html
202
- <!DOCTYPE html>
203
- <html lang="en">
204
- <head>
205
- <meta charset="UTF-8">
206
- <title>BareDOM Example</title>
207
- </head>
208
- <body>
209
- <x-button variant="primary">Click me</x-button>
210
- <x-alert type="success" text="It works!"></x-alert>
211
-
212
- <script type="module">
213
- import { init as initButton } from './dist/x-button.js';
214
- import { init as initAlert } from './dist/x-alert.js';
215
-
216
- initButton();
217
- initAlert();
218
- </script>
219
- </body>
220
- </html>
221
- ```
222
-
223
- Each component is a separate ES module. Import only the components you use — the browser loads only those files plus the shared `base.js` runtime.
224
-
225
- ### Option C — npm
226
-
227
- Add the npm package to your `package.json`:
228
-
229
- ```json
230
- {
231
- "dependencies": {
232
- "@vanelsas/baredom": "^2.5.0"
233
- }
234
- }
160
+ ```bash
161
+ npm install @vanelsas/baredom
235
162
  ```
236
163
 
237
- Then `npm install`. shadow-cljs resolves npm packages automatically via `node_modules`. From ClojureScript:
238
-
239
- ```clojure
240
- (ns my-app.core
241
- (:require
242
- ["@vanelsas/baredom/x-button" :as x-button]
243
- ["@vanelsas/baredom/x-alert" :as x-alert]
244
- ["@vanelsas/baredom/x-toaster" :as x-toaster]
245
- ["@vanelsas/baredom/x-toast" :as x-toast]))
246
-
247
- (defn- register-components! []
248
- (.init x-button)
249
- (.init x-alert)
250
- (.init x-toaster)
251
- (.init x-toast))
164
+ ```js
165
+ import { init } from '@vanelsas/baredom/x-button';
166
+ init();
252
167
  ```
253
168
 
254
- Call `register-components!` once in your `init!` entry point. Registration is idempotent — calling `.init` on an already-registered element is a no-op.
169
+ Also available via [Clojars](./docs/installation.md#clojurescript-via-clojars) and [standalone ES modules](./docs/installation.md#vanilla-htmljs-via-es-modules). See the [full installation guide](./docs/installation.md).
255
170
 
256
171
  ---
257
172
 
258
173
  ## Usage
259
174
 
260
- ### 1. Register components
261
-
262
- Whichever installation method you chose above, the pattern is the same: require/import each component you need and call its `init` function once before any rendering. Only the components you register are active on the page.
263
-
264
- ### 2. Add a renderer
265
-
266
- BareDOM components are plain DOM elements. You need no framework to use them — only a small renderer that turns ClojureScript hiccup vectors into DOM nodes and keeps them in sync with your state.
267
-
268
- The `bare-demo/` project includes a complete renderer (~120 lines) with DOM reconciliation that you can copy into any ClojureScript project. See [`bare-demo/src/bare_demo/renderer.cljs`](./bare-demo/src/bare_demo/renderer.cljs). No Node.js required — just Java and the Clojure CLI.
269
-
270
- What the renderer provides:
271
-
272
- - **Hiccup syntax** — describe UI as nested vectors: `[:tag {:attr val} children]`
273
- - **Prop handling** — `:on-*` keys become event listeners; `true`/`false` toggle boolean attributes; everything else calls `setAttribute`
274
- - **DOM reconciliation** — on re-render, the existing DOM is patched in place. Elements are never destroyed and recreated, so Web Components keep their lifecycle, shadow DOM, focus state, and animations intact.
275
- - **`mount!`** — renders the view and attaches `add-watch` to a state atom so every `swap!` triggers a reconciliation pass
276
-
277
- ### 3. Write views with hiccup syntax
278
-
279
- Views are plain ClojureScript functions that return nested vectors. The first element of each vector is a keyword matching the element tag name. An optional map of props follows, then children.
280
-
281
- ```clojure
282
- ;; String and number attributes
283
- [:x-button {:variant "primary"} "Save changes"]
284
- [:x-button {:variant "secondary" :size "sm"} "Cancel"]
285
-
286
- ;; Boolean attributes — true sets the attribute, false/nil removes it
287
- [:x-button {:variant "danger" :disabled true} "Delete"]
288
- [:x-button {:variant "primary" :loading true} "Saving…"]
289
- [:x-checkbox {:checked true}]
290
- [:x-checkbox {:indeterminate true}]
291
-
292
- ;; Nesting
293
- [:x-grid {:columns "2" :gap "md"}
294
- [:x-card "First card"]
295
- [:x-card "Second card"]]
296
-
297
- [:x-grid {:columns "4" :gap "md"}
298
- [:x-stat {:label "Revenue" :value "$48,295" :trend "up" :variant "positive"}]
299
- [:x-stat {:label "Users" :value "12,483" :trend "up"}]
300
- [:x-stat {:label "Orders" :value "1,429" :trend "neutral"}]
301
- [:x-stat {:label "Churn" :value "2.4%" :trend "down" :variant "danger"}]]
302
-
303
- ;; Slots — use the :slot attribute to target named slots
304
- [:x-navbar {:label "My App"}
305
- [:span {:slot "brand" :style "font-weight:700"} "My App"]
306
- [:div {:slot "actions"}
307
- [:x-button {:variant "ghost" :size "sm"} "Sign out"]]]
308
- ```
309
-
310
- ### 4. Handle events and manage state
311
-
312
- Event listeners are declared inline using `:on-<event-name>` keys. The key is stripped of `on-` and the remainder becomes the event name passed to `addEventListener`. Custom component events follow the same pattern — use the full event name after `on-`.
313
-
314
- ```clojure
315
- (defonce app-state (atom {:active-tab "overview"
316
- :sidebar-collapsed false}))
317
-
318
- ;; Standard DOM event
319
- [:x-button
320
- {:variant "ghost"
321
- :on-click (fn [_] (swap! app-state update :sidebar-collapsed not))}
322
- "Toggle sidebar"]
323
-
324
- ;; Custom component event — :on-value-change listens for "value-change"
325
- [:x-tabs
326
- {:value (:active-tab @app-state)
327
- :on-value-change (fn [e]
328
- (swap! app-state assoc
329
- :active-tab (.. e -detail -value)))}
330
- [:x-tab {:value "overview"} "Overview"]
331
- [:x-tab {:value "components"} "Components"]
332
- [:x-tab {:value "settings"} "Settings"]]
333
-
334
- ;; Custom event with detail payload
335
- [:x-alert
336
- {:type "success" :text "Changes saved." :dismissible true
337
- :on-x-alert-dismiss (fn [e]
338
- (js/console.log "dismissed by:" (.. e -detail -reason)))}]
339
-
340
- ;; Sidebar with open/collapse state
341
- [:x-sidebar
342
- {:open (:sidebar-open @app-state)
343
- :collapsed (:sidebar-collapsed @app-state)
344
- :placement "left"
345
- :on-toggle (fn [e]
346
- (swap! app-state assoc :sidebar-open (.. e -detail -open)))}
347
- ;; ... nav items ...
348
- ]
349
- ```
350
-
351
- Wire everything together in your `init!`:
352
-
353
- ```clojure
354
- (defn view []
355
- [:x-container {:size "xl" :padding "lg"}
356
- ;; ... your UI built from component vectors ...
357
- ])
358
-
359
- (defn init! []
360
- (register-components!)
361
- (renderer/mount! (.getElementById js/document "app") view app-state))
362
- ```
363
-
364
- `mount!` calls `view` immediately and re-calls it on every `swap!` or `reset!` to `app-state`. On each re-render the reconciler diffs the new hiccup tree against the live DOM and applies only the changes needed — attribute updates, text changes, children added or removed. Existing elements stay in place.
365
-
366
- ### Theming
367
-
368
- Override CSS custom properties at any scope:
175
+ BareDOM components are native HTML elements. Import, register, and use them in any framework or vanilla HTML.
369
176
 
370
- ```css
371
- /* Global overrides */
372
- :root {
373
- --x-button-radius: 4px;
374
- --x-alert-radius: 8px;
375
- }
376
-
377
- /* Per-instance override */
378
- #sidebar-save-btn {
379
- --x-button-bg-primary: #0a5c99;
380
- }
381
- ```
177
+ - **JavaScript / TypeScript** — see the [JavaScript Developer Guide](./docs/javascript-guide.md)
178
+ - **ClojureScript** — see the [ClojureScript Guide](./docs/clojurescript-guide.md)
382
179
 
383
180
  ---
384
181
 
@@ -521,91 +318,9 @@ No polyfills are included or required for these targets.
521
318
 
522
319
  ---
523
320
 
524
- ## Component Demo
525
-
526
- BareDOM ships with a built-in demo that lets you browse and interact with every component in isolation. It is intended for developer convenience when working on the library itself.
527
-
528
- ```bash
529
- npm install
530
- npx shadow-cljs watch app
531
- ```
532
-
533
- Then open `http://localhost:8000`. The dev server serves `public/index.html` and hot-reloads on every source change. Each component is demonstrated in its own section with controls for toggling attributes, properties, and variants.
534
-
535
- ### Debug Mode
536
-
537
- BareDOM includes a visual debug overlay for development. It highlights every component on the page, shows tag names on hover, and lets you inspect and edit live state — no browser extension required.
538
-
539
- **Activate** by adding `?baredom-debug` to any dev URL:
540
-
541
- ```
542
- http://localhost:8000?baredom-debug
543
- ```
544
-
545
- Or toggle from the browser console at any time:
546
-
547
- ```js
548
- window.BAREDOM_DEBUG = true
549
- ```
550
-
551
- When active, debug mode provides:
552
-
553
- - **Dashed blue outlines** around every BareDOM component
554
- - **Tag labels** that appear on hover (top-right corner)
555
- - **Inspection panel** — click a label to see current attributes, properties, and computed state
556
- - **Inline editing** — toggle boolean attributes with a switch, edit string/number values and press Enter to apply
557
- - **Console logging** — structured `console.group` output on every attribute change, lifecycle events at `console.debug` level
558
-
559
- Changes made through the debug panel are live but ephemeral — they modify the DOM directly and do not survive a page refresh.
560
-
561
- Debug mode is dev-only and is excluded from the production ESM build (`npm run build`).
562
-
563
- ---
564
-
565
- ## bare-demo — starter template for ClojureScript web apps
566
-
567
- The `bare-demo/` folder is a ready-to-use ClojureScript application that consumes BareDOM components with **zero framework dependency and no Node.js**. It is designed as a starting point for developers building new web apps on top of BareDOM.
568
-
569
- The architecture is built on three ideas:
570
-
571
- - **Declarative hiccup views.** UI is described as nested ClojureScript vectors — the same syntax used by Reagent and Hiccup. Views are plain functions, easy to compose and reason about.
572
- - **A single state atom with reactive rendering.** All UI state lives in one `defonce` atom. `mount!` attaches `add-watch` so every `swap!` triggers a re-render automatically.
573
- - **DOM reconciliation, not rebuild.** On state changes the renderer patches the existing DOM in place — updating attributes, text, and children without destroying elements. Web Components keep their lifecycle, shadow DOM, focus state, and animations intact.
574
-
575
- This approach scales naturally: add more state, more views, more components — no manual wiring, no framework overhead, no impedance mismatch with the Web Component model.
576
-
577
- **Run it:**
578
-
579
- ```bash
580
- cd bare-demo
581
- clj -M:dev
582
- ```
583
-
584
- Then open `http://localhost:8001`.
585
-
586
- See [`bare-demo/README.md`](./bare-demo/README.md) for a full walkthrough of the renderer, component registration, view syntax, state management, and theming.
587
-
588
- > **Prefer NPM?** The `bare-node-demo/` folder contains the same demo consuming BareDOM via npm. Run it with `cd bare-node-demo && npm install && npm start` (opens on `http://localhost:8003`).
589
-
590
- ---
591
-
592
- ## Building from Source
593
-
594
- BareDOM is authored in ClojureScript and compiled with [shadow-cljs](https://shadow-cljs.github.io/docs/UsersGuide.html).
321
+ ## Development
595
322
 
596
- ```bash
597
- # Install dependencies
598
- npm install
599
-
600
- # Start development server with hot reload (http://localhost:8000)
601
- npx shadow-cljs watch app
602
-
603
- # Run browser-based tests (http://localhost:8021)
604
- npx shadow-cljs watch test
605
-
606
- # Build production ESM library to dist/
607
- npm run build
608
- ```
323
+ See the [development guide](./docs/development.md) for setting up the dev server, using [debug mode](./docs/development.md#debug-mode), and building from source.
609
324
 
610
325
  ---
611
326
 
@@ -2749,6 +2749,11 @@
2749
2749
  }
2750
2750
  } ],
2751
2751
  "events" : [ {
2752
+ "name" : "x-slider-change-request",
2753
+ "type" : {
2754
+ "text" : "CustomEvent"
2755
+ }
2756
+ }, {
2752
2757
  "name" : "x-slider-input",
2753
2758
  "type" : {
2754
2759
  "text" : "CustomEvent"
@@ -2987,7 +2992,12 @@
2987
2992
  }
2988
2993
  } ],
2989
2994
  "events" : [ {
2990
- "name" : ":page-change",
2995
+ "name" : "page-change-request",
2996
+ "type" : {
2997
+ "text" : "CustomEvent"
2998
+ }
2999
+ }, {
3000
+ "name" : "page-change",
2991
3001
  "type" : {
2992
3002
  "text" : "CustomEvent"
2993
3003
  }
@@ -3112,6 +3122,11 @@
3112
3122
  }
3113
3123
  } ],
3114
3124
  "events" : [ {
3125
+ "name" : "value-change-request",
3126
+ "type" : {
3127
+ "text" : "CustomEvent"
3128
+ }
3129
+ }, {
3115
3130
  "name" : "value-change",
3116
3131
  "type" : {
3117
3132
  "text" : "CustomEvent"
@@ -4630,6 +4645,11 @@
4630
4645
  }
4631
4646
  } ],
4632
4647
  "events" : [ {
4648
+ "name" : "x-combobox-change-request",
4649
+ "type" : {
4650
+ "text" : "CustomEvent"
4651
+ }
4652
+ }, {
4633
4653
  "name" : "x-combobox-change",
4634
4654
  "type" : {
4635
4655
  "text" : "CustomEvent"
@@ -4728,6 +4748,11 @@
4728
4748
  }
4729
4749
  } ],
4730
4750
  "events" : [ {
4751
+ "name" : "x-text-area-change-request",
4752
+ "type" : {
4753
+ "text" : "CustomEvent"
4754
+ }
4755
+ }, {
4731
4756
  "name" : "x-text-area-input",
4732
4757
  "type" : {
4733
4758
  "text" : "CustomEvent"
@@ -5902,6 +5927,11 @@
5902
5927
  }
5903
5928
  } ],
5904
5929
  "events" : [ {
5930
+ "name" : "x-select-change-request",
5931
+ "type" : {
5932
+ "text" : "CustomEvent"
5933
+ }
5934
+ }, {
5905
5935
  "name" : "select-change",
5906
5936
  "type" : {
5907
5937
  "text" : "CustomEvent"
@@ -7126,6 +7156,11 @@
7126
7156
  }
7127
7157
  } ],
7128
7158
  "events" : [ {
7159
+ "name" : "x-currency-field-change-request",
7160
+ "type" : {
7161
+ "text" : "CustomEvent"
7162
+ }
7163
+ }, {
7129
7164
  "name" : "x-currency-field-input",
7130
7165
  "type" : {
7131
7166
  "text" : "CustomEvent"