@dodlhuat/basix 1.2.1 → 1.2.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 (3) hide show
  1. package/README.md +210 -5
  2. package/css/style.css +3 -7
  3. package/package.json +1 -3
package/README.md CHANGED
@@ -16,12 +16,23 @@ A demo can be found here: <a href="http://www.andibauer.at/basix/" target="_blan
16
16
  Take a look at style.scss for a glimpse on a full import. reset, parameters, colors & defaults are mandatory, anything
17
17
  else can be added as needed.
18
18
 
19
- To use the import functionality of javascript files you need to import your main script as a module. And either build
20
- your own css or include the existing full style.css (or min)
19
+ Include the stylesheet and import individual components as ES modules. There is no bundled entry point only the components you use are loaded.
21
20
 
22
21
  ``` html
23
22
  <link rel="stylesheet" href="css/style.css" type="text/css">
24
- <script src="js/index.js" type="module"></script>
23
+ <script type="module">
24
+ import { Chart } from './js/chart.js';
25
+ import { Modal } from './js/modal.js';
26
+ import { Stepper } from './js/stepper.js';
27
+ // … add only what you need
28
+ </script>
29
+ ```
30
+
31
+ When installed via npm, import from the package:
32
+
33
+ ``` js
34
+ import { Chart } from '@dodlhuat/basix/js/chart.js';
35
+ import { Modal } from '@dodlhuat/basix/js/modal.js';
25
36
  ```
26
37
 
27
38
  ---
@@ -125,10 +136,20 @@ The Switch component creates styled toggle switches based on checkboxes.
125
136
 
126
137
  ### Range Slider
127
138
 
128
- The Range Slider component creates a simple styled slider.
139
+ The Range Slider component creates a styled slider with a CSS custom property `--range-fill` that tracks the current value for fill styling. Use the JS class to initialise fill tracking automatically.
129
140
 
130
141
  ``` html
131
- <input type="range" min="1" max="100" value="50" />
142
+ <div class="range-slider">
143
+ <input type="range" min="1" max="100" value="50" />
144
+ </div>
145
+ ```
146
+
147
+ ``` js
148
+ // Initialise a single slider
149
+ new RangeSlider(document.querySelector('.range-slider input'));
150
+
151
+ // Or initialise all sliders on the page at once
152
+ RangeSlider.initAll();
132
153
  ```
133
154
 
134
155
  ---
@@ -155,6 +176,37 @@ The Flyout Menu component creates slide-in navigation menus with nested submenus
155
176
  | `footerText` | string | `'© 2025 Brand Inc.'` | Shown in the footer if enabled |
156
177
  | `enableFooter` | boolean | `true` | Shows the menu footer |
157
178
 
179
+ ### Popover
180
+
181
+ The Popover component attaches a floating content panel to any trigger element. Supports click and hover trigger modes, four placement directions, optional arrow, and stacks correctly when multiple popovers exist.
182
+
183
+ | Option | Type | Default | Description |
184
+ |---|---|---|---|
185
+ | `content` | string | — | HTML content rendered inside the popover |
186
+ | `placement` | string | `'top'` | Preferred placement: `'top'`, `'bottom'`, `'left'`, `'right'`, or `'auto'` |
187
+ | `align` | string | `'center'` | Alignment along the axis: `'start'`, `'center'`, `'end'` |
188
+ | `offset` | number | `8` | Distance in px between the trigger and the popover |
189
+ | `arrow` | boolean | `true` | Shows a directional arrow |
190
+ | `triggerMode` | string | `'click'` | `'click'` or `'hover'` |
191
+ | `closeOnOutsideClick` | boolean | `true` | Closes when clicking outside |
192
+ | `closeOnEscape` | boolean | `true` | Closes on Escape key |
193
+ | `className` | string | — | Extra CSS class on the popover element |
194
+ | `onOpen` | function | — | Callback fired when the popover opens |
195
+ | `onClose` | function | — | Callback fired when the popover closes |
196
+
197
+ ``` js
198
+ const pop = new Popover('#my-trigger', {
199
+ content: '<p>Popover content</p>',
200
+ placement: 'bottom',
201
+ triggerMode: 'click',
202
+ });
203
+
204
+ pop.open();
205
+ pop.close();
206
+ pop.toggle();
207
+ pop.destroy();
208
+ ```
209
+
158
210
  ### Dropdown Menu
159
211
 
160
212
  The Dropdown Menu allows to create multi-level dropdown menus with nested submenus. The menu fires custom events `CustomEvent<DropdownSelectDetail>` that can be listened to in order to react to user selections.
@@ -426,6 +478,91 @@ The Placeholder component creates skeleton loading states. Use `.placeholder` wi
426
478
 
427
479
  ## Advanced Components
428
480
 
481
+ ### Chart
482
+
483
+ The Chart component renders SVG-based charts with no external dependencies. Supports line, area, column, bar, and pie chart types. Animates on first render and redraws on container resize.
484
+
485
+ ``` js
486
+ const chart = new Chart('#chart-container', {
487
+ type: 'line',
488
+ title: 'Monthly Revenue',
489
+ series: [
490
+ {
491
+ name: 'Product A',
492
+ data: [
493
+ { label: 'Jan', value: 120 },
494
+ { label: 'Feb', value: 180 },
495
+ { label: 'Mar', value: 150 },
496
+ ],
497
+ },
498
+ ],
499
+ });
500
+
501
+ chart.update(newSeries); // replace data and redraw
502
+ chart.setType('bar'); // switch chart type
503
+ chart.destroy(); // remove listeners and DOM
504
+ ```
505
+
506
+ | Option | Type | Default | Description |
507
+ |---|---|---|---|
508
+ | `type` | ChartType | — | `'line'`, `'area'`, `'column'`, `'bar'`, or `'pie'` |
509
+ | `series` | ChartSeries[] | — | Array of `{ name, data, color? }` objects |
510
+ | `title` | string | — | Optional chart title |
511
+ | `subtitle` | string | — | Optional subtitle below the title |
512
+ | `height` | number | `280` | Inner chart height in px |
513
+ | `showLegend` | boolean | `true` | Renders the series legend |
514
+ | `showGrid` | boolean | `true` | Renders background grid lines |
515
+ | `animate` | boolean | `true` | Animates on first render |
516
+ | `curve` | string | `'smooth'` | Line interpolation for line/area: `'smooth'`, `'linear'`, `'step'` |
517
+ | `yMin` | number | `0` | Fixed y-axis minimum |
518
+ | `yMax` | number | auto | Fixed y-axis maximum (defaults to max value × 1.1) |
519
+ | `onPointClick` | function | — | Callback `(series, point, index) => void` fired on data point click |
520
+
521
+ ### Calendar
522
+
523
+ The Calendar component renders a full interactive calendar with month, week, and agenda views. Supports event display, keyboard navigation, and locale configuration.
524
+
525
+ ``` js
526
+ const cal = new Calendar({
527
+ container: '#my-calendar',
528
+ view: 'month',
529
+ events: [
530
+ {
531
+ id: '1',
532
+ title: 'Team Meeting',
533
+ start: new Date(2026, 3, 20, 10, 0),
534
+ end: new Date(2026, 3, 20, 11, 0),
535
+ className: 'badge-success',
536
+ },
537
+ ],
538
+ onEventClick: (event) => console.log(event),
539
+ onDayClick: (date) => console.log(date),
540
+ onChange: (date, view) => console.log(date, view),
541
+ });
542
+
543
+ cal.next();
544
+ cal.prev();
545
+ cal.today();
546
+ cal.setView('week');
547
+ cal.addEvent({ id: '2', title: 'Lunch', start: new Date(), end: new Date() });
548
+ cal.removeEvent('2');
549
+ cal.setEvents(events);
550
+ cal.getEvents();
551
+ cal.destroy();
552
+ ```
553
+
554
+ | Option | Type | Default | Description |
555
+ |---|---|---|---|
556
+ | `container` | HTMLElement \| string | — | Target container element or CSS selector |
557
+ | `events` | CalendarEvent[] | `[]` | Initial events |
558
+ | `view` | string | `'month'` | Initial view: `'month'`, `'week'`, or `'agenda'` |
559
+ | `showOutsideDays` | boolean | `true` | Show days from adjacent months in the month grid |
560
+ | `locale` | object | — | Override locale strings (day names, month names, labels) |
561
+ | `onDayClick` | function | — | Callback `(date: Date) => void` |
562
+ | `onEventClick` | function | — | Callback `(event: CalendarEvent) => void` |
563
+ | `onChange` | function | — | Callback `(date: Date, view: CalendarView) => void` |
564
+ | `className` | string | — | Extra CSS class on the root element |
565
+
429
566
  ### Context Menu
430
567
 
431
568
  The Context Menu component shows a custom right-click menu on any target element. Supports icons, keyboard shortcuts, group labels, separators, submenus, destructive items, and disabled items. Automatically flips to avoid viewport overflow and animates in from the click origin.
@@ -594,6 +731,74 @@ const picker = new GroupPicker('#group-picker-demo', data, {
594
731
  | `collapseAll()` | Collapse all groups |
595
732
  | `destroy()` | Remove event listeners and clear the DOM |
596
733
 
734
+ ### Time Span Picker
735
+
736
+ The TimeSpanPicker component provides a paired start/end time input for selecting a time range.
737
+
738
+ ``` js
739
+ const picker = new TimeSpanPicker('my-container', {
740
+ defaultStart: '09:00',
741
+ defaultEnd: '17:00',
742
+ onChange: (start, end) => console.log(start, end),
743
+ });
744
+
745
+ picker.getValue(); // { start: '09:00', end: '17:00' }
746
+ picker.setValue('10:00', '18:00');
747
+ picker.reset();
748
+ picker.isValid(); // boolean
749
+ picker.destroy();
750
+ ```
751
+
752
+ ### Select
753
+
754
+ The Select component wraps a native `<select>` element with custom Basix styling. Supports single and multi-select.
755
+
756
+ ``` html
757
+ <select id="my-select">
758
+ <option value="a">Option A</option>
759
+ <option value="b">Option B</option>
760
+ </select>
761
+ ```
762
+
763
+ ``` js
764
+ const sel = new Select('#my-select');
765
+ sel.value(); // returns selected value string, or string[] for multi-select
766
+
767
+ // Or initialise by passing the element directly
768
+ Select.init(document.querySelector('#my-select'));
769
+ ```
770
+
771
+ ### Code Viewer
772
+
773
+ The CodeViewer component renders syntax-highlighted code blocks inside any container. Supports JavaScript, HTML, and CSS.
774
+
775
+ ``` js
776
+ new CodeViewer('#output', '<div class="card">Hello</div>', 'html');
777
+ new CodeViewer('#output', 'const x = 42;', 'javascript');
778
+ new CodeViewer('#output', '.card { padding: 1rem; }', 'css');
779
+ ```
780
+
781
+ ### Editor
782
+
783
+ The Editor component provides a contenteditable rich-text editing area with undo/redo, word count, and an optional side panel showing the raw HTML source and a live preview. Requires a `#editable` element in the DOM.
784
+
785
+ ``` html
786
+ <div id="editable" contenteditable="true"></div>
787
+ <!-- Optional side panel elements -->
788
+ <textarea id="code"></textarea>
789
+ <div id="preview"></div>
790
+ <div id="sidePanel"></div>
791
+ <span id="wordCount"></span>
792
+ ```
793
+
794
+ ``` js
795
+ // Full editor with side panel
796
+ new Editor();
797
+
798
+ // Simple mode — hides the side panel permanently
799
+ new Editor({ simple: true });
800
+ ```
801
+
597
802
  ### Custom Scrollbar
598
803
 
599
804
  The Scrollbar component creates custom-styled scrollbars. Supports pointer/touch dragging, track clicking, and automatic thumb sizing. Can be used with any class.
package/css/style.css CHANGED
@@ -8102,18 +8102,14 @@ body {
8102
8102
  left: 0;
8103
8103
  top: 0;
8104
8104
  height: 100vh;
8105
+ overflow-y: auto;
8105
8106
  background: var(--primary-bg);
8106
8107
  border-right: 1px solid var(--divider);
8107
8108
  display: flex;
8108
8109
  flex-direction: column;
8109
8110
  z-index: 100;
8110
- }
8111
- .sidebar-nav .sidebar-scroll {
8112
- flex: 1;
8113
- min-height: 0;
8114
- background: none;
8115
- border-radius: 0;
8116
- box-shadow: none;
8111
+ scrollbar-width: thin;
8112
+ scrollbar-color: var(--divider) transparent;
8117
8113
  }
8118
8114
 
8119
8115
  .sidebar-main {
package/package.json CHANGED
@@ -1,10 +1,8 @@
1
1
  {
2
2
  "name": "@dodlhuat/basix",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Basix is intended as a starter for the rapid development of a design. Each design element can be added individually to include only the data required. It is using plain javascript / typescript and therefore is not dependent on any plugin.",
5
- "main": "js/index.js",
6
5
  "exports": {
7
- ".": "./js/index.js",
8
6
  "./css/*": "./css/*",
9
7
  "./js/*": "./js/*"
10
8
  },