mithril-materialized 3.7.0 → 3.8.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.
- package/dist/index.css +29 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +121 -1
- package/dist/index.js +121 -0
- package/dist/index.min.css +1 -1
- package/dist/index.umd.js +121 -0
- package/dist/toggle-button.d.ts +46 -0
- package/dist/toggle-group.d.ts +84 -0
- package/package.json +1 -1
- package/sass/components/_toggle-group.scss +36 -0
- package/sass/materialize.scss +1 -0
package/dist/index.css
CHANGED
|
@@ -12014,4 +12014,33 @@ body.dark {
|
|
|
12014
12014
|
.rating--focused:not(.rating--read-only):not(.rating--disabled) .rating__items {
|
|
12015
12015
|
transform: none;
|
|
12016
12016
|
}
|
|
12017
|
+
}
|
|
12018
|
+
.toggle-group {
|
|
12019
|
+
display: inline-flex;
|
|
12020
|
+
border-radius: 4px;
|
|
12021
|
+
overflow: hidden;
|
|
12022
|
+
border: 1px solid var(--mm-border-color, #e0e0e0);
|
|
12023
|
+
}
|
|
12024
|
+
.toggle-group .toggle-button {
|
|
12025
|
+
margin: 0;
|
|
12026
|
+
border-radius: 0;
|
|
12027
|
+
border-right: 1px solid var(--mm-border-color, #e0e0e0);
|
|
12028
|
+
}
|
|
12029
|
+
.toggle-group .toggle-button:last-child {
|
|
12030
|
+
border-right: none;
|
|
12031
|
+
}
|
|
12032
|
+
.toggle-group .toggle-button.checked {
|
|
12033
|
+
background-color: var(--mm-primary-color, #26a69a);
|
|
12034
|
+
color: var(--mm-button-text, #fff);
|
|
12035
|
+
}
|
|
12036
|
+
|
|
12037
|
+
[data-theme=dark] .toggle-group {
|
|
12038
|
+
border-color: var(--mm-border-color, #555);
|
|
12039
|
+
}
|
|
12040
|
+
[data-theme=dark] .toggle-group .toggle-button {
|
|
12041
|
+
border-right-color: var(--mm-border-color, #555);
|
|
12042
|
+
}
|
|
12043
|
+
[data-theme=dark] .toggle-group .toggle-button.checked {
|
|
12044
|
+
background-color: var(--mm-primary-color, #80cbc4);
|
|
12045
|
+
color: var(--mm-button-text, #000);
|
|
12017
12046
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -10711,6 +10711,126 @@ const Rating = () => {
|
|
|
10711
10711
|
};
|
|
10712
10712
|
};
|
|
10713
10713
|
|
|
10714
|
+
/**
|
|
10715
|
+
* ToggleButton component.
|
|
10716
|
+
*
|
|
10717
|
+
* A button that can be toggled on/off. Typically used within a ToggleGroup
|
|
10718
|
+
* to create grouped button controls where one or more buttons can be selected.
|
|
10719
|
+
*
|
|
10720
|
+
* @example
|
|
10721
|
+
* ```typescript
|
|
10722
|
+
* m(ToggleButton, {
|
|
10723
|
+
* value: 'bold',
|
|
10724
|
+
* iconName: 'format_bold',
|
|
10725
|
+
* checked: true,
|
|
10726
|
+
* tooltip: 'Bold',
|
|
10727
|
+
* onchange: () => console.log('Toggled')
|
|
10728
|
+
* })
|
|
10729
|
+
* ```
|
|
10730
|
+
*/
|
|
10731
|
+
const ToggleButton = () => {
|
|
10732
|
+
return {
|
|
10733
|
+
view: ({ attrs }) => {
|
|
10734
|
+
const { checked, iconName, icon, label, onchange, className, tooltip } = attrs, rest = __rest(attrs, ["checked", "iconName", "icon", "label", "onchange", "className", "tooltip"]);
|
|
10735
|
+
const classes = [className, checked ? 'checked' : ''].filter(Boolean).join(' ');
|
|
10736
|
+
return m('button.btn-flat.waves-effect.toggle-button', Object.assign(Object.assign({}, rest), { className: classes, title: tooltip, onclick: () => {
|
|
10737
|
+
if (onchange) {
|
|
10738
|
+
onchange();
|
|
10739
|
+
}
|
|
10740
|
+
}, onmousedown: WavesEffect.onMouseDown, onmouseup: WavesEffect.onMouseUp, onmouseleave: WavesEffect.onMouseLeave, ontouchstart: WavesEffect.onTouchStart, ontouchend: WavesEffect.onTouchEnd }), [icon, iconName && m(Icon, { iconName, className: attrs.iconClass }), label]);
|
|
10741
|
+
},
|
|
10742
|
+
};
|
|
10743
|
+
};
|
|
10744
|
+
|
|
10745
|
+
/**
|
|
10746
|
+
* ToggleGroup component.
|
|
10747
|
+
*
|
|
10748
|
+
* A group of toggle buttons that can operate in single-select or multi-select mode.
|
|
10749
|
+
* The component supports both controlled and uncontrolled modes.
|
|
10750
|
+
*
|
|
10751
|
+
* **Controlled mode**: Manage the state externally using the `value` prop.
|
|
10752
|
+
* **Uncontrolled mode**: Let the component manage its own state using `defaultValue`.
|
|
10753
|
+
*
|
|
10754
|
+
* @example
|
|
10755
|
+
* ```typescript
|
|
10756
|
+
* // Single-select, controlled mode
|
|
10757
|
+
* let selected = 'left';
|
|
10758
|
+
* m(ToggleGroup, {
|
|
10759
|
+
* value: selected,
|
|
10760
|
+
* onchange: (v) => selected = v,
|
|
10761
|
+
* items: [
|
|
10762
|
+
* { value: 'left', iconName: 'format_align_left', tooltip: 'Align Left' },
|
|
10763
|
+
* { value: 'center', iconName: 'format_align_center', tooltip: 'Align Center' },
|
|
10764
|
+
* { value: 'right', iconName: 'format_align_right', tooltip: 'Align Right' }
|
|
10765
|
+
* ]
|
|
10766
|
+
* });
|
|
10767
|
+
*
|
|
10768
|
+
* // Multi-select, controlled mode
|
|
10769
|
+
* let selected = ['bold', 'italic'];
|
|
10770
|
+
* m(ToggleGroup, {
|
|
10771
|
+
* multiple: true,
|
|
10772
|
+
* value: selected,
|
|
10773
|
+
* onchange: (v) => selected = v,
|
|
10774
|
+
* items: [
|
|
10775
|
+
* { value: 'bold', iconName: 'format_bold', tooltip: 'Bold' },
|
|
10776
|
+
* { value: 'italic', iconName: 'format_italic', tooltip: 'Italic' },
|
|
10777
|
+
* { value: 'underline', iconName: 'format_underlined', tooltip: 'Underline' }
|
|
10778
|
+
* ]
|
|
10779
|
+
* });
|
|
10780
|
+
*
|
|
10781
|
+
* // Uncontrolled mode
|
|
10782
|
+
* m(ToggleGroup, {
|
|
10783
|
+
* defaultValue: 'left',
|
|
10784
|
+
* onchange: (v) => console.log('Changed to:', v),
|
|
10785
|
+
* items: [...]
|
|
10786
|
+
* });
|
|
10787
|
+
* ```
|
|
10788
|
+
*/
|
|
10789
|
+
const ToggleGroup = () => {
|
|
10790
|
+
let internalValue;
|
|
10791
|
+
const handleSelect = (attrs, item, currentValue) => {
|
|
10792
|
+
if (attrs.disabled || item.disabled) {
|
|
10793
|
+
return;
|
|
10794
|
+
}
|
|
10795
|
+
const { value, multiple, onchange } = attrs;
|
|
10796
|
+
const isControlled = value !== undefined;
|
|
10797
|
+
if (multiple) {
|
|
10798
|
+
const currentValues = (Array.isArray(currentValue) ? currentValue : currentValue !== undefined ? [currentValue] : []);
|
|
10799
|
+
const newValues = currentValues.includes(item.value)
|
|
10800
|
+
? currentValues.filter((v) => v !== item.value)
|
|
10801
|
+
: [...currentValues, item.value];
|
|
10802
|
+
if (!isControlled) {
|
|
10803
|
+
internalValue = newValues;
|
|
10804
|
+
}
|
|
10805
|
+
if (onchange) {
|
|
10806
|
+
onchange(newValues);
|
|
10807
|
+
}
|
|
10808
|
+
}
|
|
10809
|
+
else {
|
|
10810
|
+
const newValue = item.value;
|
|
10811
|
+
if (!isControlled) {
|
|
10812
|
+
internalValue = newValue;
|
|
10813
|
+
}
|
|
10814
|
+
if (onchange) {
|
|
10815
|
+
onchange(newValue);
|
|
10816
|
+
}
|
|
10817
|
+
}
|
|
10818
|
+
};
|
|
10819
|
+
return {
|
|
10820
|
+
oninit: ({ attrs }) => {
|
|
10821
|
+
internalValue = attrs.defaultValue;
|
|
10822
|
+
},
|
|
10823
|
+
view: ({ attrs }) => {
|
|
10824
|
+
const { value, items, multiple } = attrs;
|
|
10825
|
+
const isControlled = value !== undefined;
|
|
10826
|
+
const currentValue = isControlled ? value : internalValue;
|
|
10827
|
+
return m('.toggle-group', items.map((item) => m(ToggleButton, Object.assign(Object.assign({}, item), { checked: multiple && Array.isArray(currentValue)
|
|
10828
|
+
? currentValue.includes(item.value)
|
|
10829
|
+
: currentValue === item.value, onchange: () => handleSelect(attrs, item, currentValue) }))));
|
|
10830
|
+
},
|
|
10831
|
+
};
|
|
10832
|
+
};
|
|
10833
|
+
|
|
10714
10834
|
/**
|
|
10715
10835
|
* @fileoverview Core TypeScript utility types for mithril-materialized library
|
|
10716
10836
|
* These types improve type safety and developer experience across all components
|
|
@@ -10732,4 +10852,4 @@ const isValidationError = (result) => !isValidationSuccess(result);
|
|
|
10732
10852
|
// ============================================================================
|
|
10733
10853
|
// All types are already exported via individual export declarations above
|
|
10734
10854
|
|
|
10735
|
-
export { AnalogClock, AnchorItem, Autocomplete, Breadcrumb, BreadcrumbManager, Button, ButtonFactory, Carousel, CharacterCounter, Chips, CodeBlock, Collapsible, CollapsibleItem, Collection, CollectionMode, ColorInput, DataTable, DatePicker, DigitalClock, DoubleRangeSlider, Dropdown, EmailInput, FileInput, FileUpload, FlatButton, FloatingActionButton, HelperText, Icon, IconButton, ImageList, InputCheckbox, Label, LargeButton, ListItem, Mandatory, Masonry, MaterialBox, MaterialIcon, ModalPanel, NumberInput, Options, OptionsList, Pagination, PaginationControls, Parallax, PasswordInput, Pushpin, PushpinComponent, RadioButton, RadioButtons, RangeInput, Rating, RoundIconButton, SearchSelect, SecondaryContent, Select, Sidenav, SidenavItem, SidenavManager, SingleRangeSlider, SmallButton, Stepper, SubmitButton, Switch, Tabs, TextArea, TextInput, ThemeManager, ThemeSwitcher, ThemeToggle, TimePicker, TimeRangePicker, Timeline, Toast, ToastComponent, Tooltip, TooltipComponent, TreeView, UrlInput, Wizard, addLeadingZero, clearPortal, createBreadcrumb, formatTime, generateHourOptions, generateMinuteOptions, getDropdownStyles, getPortalContainer, initPushpins, initTooltips, isNumeric, isTimeDisabled, isValidationError, isValidationSuccess, padLeft, parseTime, range, releasePortalContainer, renderToPortal, scrollToValue, snapToNearestItem, sortOptions, timeToMinutes, toast, uniqueId, uuid4 };
|
|
10855
|
+
export { AnalogClock, AnchorItem, Autocomplete, Breadcrumb, BreadcrumbManager, Button, ButtonFactory, Carousel, CharacterCounter, Chips, CodeBlock, Collapsible, CollapsibleItem, Collection, CollectionMode, ColorInput, DataTable, DatePicker, DigitalClock, DoubleRangeSlider, Dropdown, EmailInput, FileInput, FileUpload, FlatButton, FloatingActionButton, HelperText, Icon, IconButton, ImageList, InputCheckbox, Label, LargeButton, ListItem, Mandatory, Masonry, MaterialBox, MaterialIcon, ModalPanel, NumberInput, Options, OptionsList, Pagination, PaginationControls, Parallax, PasswordInput, Pushpin, PushpinComponent, RadioButton, RadioButtons, RangeInput, Rating, RoundIconButton, SearchSelect, SecondaryContent, Select, Sidenav, SidenavItem, SidenavManager, SingleRangeSlider, SmallButton, Stepper, SubmitButton, Switch, Tabs, TextArea, TextInput, ThemeManager, ThemeSwitcher, ThemeToggle, TimePicker, TimeRangePicker, Timeline, Toast, ToastComponent, ToggleGroup, Tooltip, TooltipComponent, TreeView, UrlInput, Wizard, addLeadingZero, clearPortal, createBreadcrumb, formatTime, generateHourOptions, generateMinuteOptions, getDropdownStyles, getPortalContainer, initPushpins, initTooltips, isNumeric, isTimeDisabled, isValidationError, isValidationSuccess, padLeft, parseTime, range, releasePortalContainer, renderToPortal, scrollToValue, snapToNearestItem, sortOptions, timeToMinutes, toast, uniqueId, uuid4 };
|
package/dist/index.js
CHANGED
|
@@ -10713,6 +10713,126 @@ const Rating = () => {
|
|
|
10713
10713
|
};
|
|
10714
10714
|
};
|
|
10715
10715
|
|
|
10716
|
+
/**
|
|
10717
|
+
* ToggleButton component.
|
|
10718
|
+
*
|
|
10719
|
+
* A button that can be toggled on/off. Typically used within a ToggleGroup
|
|
10720
|
+
* to create grouped button controls where one or more buttons can be selected.
|
|
10721
|
+
*
|
|
10722
|
+
* @example
|
|
10723
|
+
* ```typescript
|
|
10724
|
+
* m(ToggleButton, {
|
|
10725
|
+
* value: 'bold',
|
|
10726
|
+
* iconName: 'format_bold',
|
|
10727
|
+
* checked: true,
|
|
10728
|
+
* tooltip: 'Bold',
|
|
10729
|
+
* onchange: () => console.log('Toggled')
|
|
10730
|
+
* })
|
|
10731
|
+
* ```
|
|
10732
|
+
*/
|
|
10733
|
+
const ToggleButton = () => {
|
|
10734
|
+
return {
|
|
10735
|
+
view: ({ attrs }) => {
|
|
10736
|
+
const { checked, iconName, icon, label, onchange, className, tooltip } = attrs, rest = __rest(attrs, ["checked", "iconName", "icon", "label", "onchange", "className", "tooltip"]);
|
|
10737
|
+
const classes = [className, checked ? 'checked' : ''].filter(Boolean).join(' ');
|
|
10738
|
+
return m('button.btn-flat.waves-effect.toggle-button', Object.assign(Object.assign({}, rest), { className: classes, title: tooltip, onclick: () => {
|
|
10739
|
+
if (onchange) {
|
|
10740
|
+
onchange();
|
|
10741
|
+
}
|
|
10742
|
+
}, onmousedown: WavesEffect.onMouseDown, onmouseup: WavesEffect.onMouseUp, onmouseleave: WavesEffect.onMouseLeave, ontouchstart: WavesEffect.onTouchStart, ontouchend: WavesEffect.onTouchEnd }), [icon, iconName && m(Icon, { iconName, className: attrs.iconClass }), label]);
|
|
10743
|
+
},
|
|
10744
|
+
};
|
|
10745
|
+
};
|
|
10746
|
+
|
|
10747
|
+
/**
|
|
10748
|
+
* ToggleGroup component.
|
|
10749
|
+
*
|
|
10750
|
+
* A group of toggle buttons that can operate in single-select or multi-select mode.
|
|
10751
|
+
* The component supports both controlled and uncontrolled modes.
|
|
10752
|
+
*
|
|
10753
|
+
* **Controlled mode**: Manage the state externally using the `value` prop.
|
|
10754
|
+
* **Uncontrolled mode**: Let the component manage its own state using `defaultValue`.
|
|
10755
|
+
*
|
|
10756
|
+
* @example
|
|
10757
|
+
* ```typescript
|
|
10758
|
+
* // Single-select, controlled mode
|
|
10759
|
+
* let selected = 'left';
|
|
10760
|
+
* m(ToggleGroup, {
|
|
10761
|
+
* value: selected,
|
|
10762
|
+
* onchange: (v) => selected = v,
|
|
10763
|
+
* items: [
|
|
10764
|
+
* { value: 'left', iconName: 'format_align_left', tooltip: 'Align Left' },
|
|
10765
|
+
* { value: 'center', iconName: 'format_align_center', tooltip: 'Align Center' },
|
|
10766
|
+
* { value: 'right', iconName: 'format_align_right', tooltip: 'Align Right' }
|
|
10767
|
+
* ]
|
|
10768
|
+
* });
|
|
10769
|
+
*
|
|
10770
|
+
* // Multi-select, controlled mode
|
|
10771
|
+
* let selected = ['bold', 'italic'];
|
|
10772
|
+
* m(ToggleGroup, {
|
|
10773
|
+
* multiple: true,
|
|
10774
|
+
* value: selected,
|
|
10775
|
+
* onchange: (v) => selected = v,
|
|
10776
|
+
* items: [
|
|
10777
|
+
* { value: 'bold', iconName: 'format_bold', tooltip: 'Bold' },
|
|
10778
|
+
* { value: 'italic', iconName: 'format_italic', tooltip: 'Italic' },
|
|
10779
|
+
* { value: 'underline', iconName: 'format_underlined', tooltip: 'Underline' }
|
|
10780
|
+
* ]
|
|
10781
|
+
* });
|
|
10782
|
+
*
|
|
10783
|
+
* // Uncontrolled mode
|
|
10784
|
+
* m(ToggleGroup, {
|
|
10785
|
+
* defaultValue: 'left',
|
|
10786
|
+
* onchange: (v) => console.log('Changed to:', v),
|
|
10787
|
+
* items: [...]
|
|
10788
|
+
* });
|
|
10789
|
+
* ```
|
|
10790
|
+
*/
|
|
10791
|
+
const ToggleGroup = () => {
|
|
10792
|
+
let internalValue;
|
|
10793
|
+
const handleSelect = (attrs, item, currentValue) => {
|
|
10794
|
+
if (attrs.disabled || item.disabled) {
|
|
10795
|
+
return;
|
|
10796
|
+
}
|
|
10797
|
+
const { value, multiple, onchange } = attrs;
|
|
10798
|
+
const isControlled = value !== undefined;
|
|
10799
|
+
if (multiple) {
|
|
10800
|
+
const currentValues = (Array.isArray(currentValue) ? currentValue : currentValue !== undefined ? [currentValue] : []);
|
|
10801
|
+
const newValues = currentValues.includes(item.value)
|
|
10802
|
+
? currentValues.filter((v) => v !== item.value)
|
|
10803
|
+
: [...currentValues, item.value];
|
|
10804
|
+
if (!isControlled) {
|
|
10805
|
+
internalValue = newValues;
|
|
10806
|
+
}
|
|
10807
|
+
if (onchange) {
|
|
10808
|
+
onchange(newValues);
|
|
10809
|
+
}
|
|
10810
|
+
}
|
|
10811
|
+
else {
|
|
10812
|
+
const newValue = item.value;
|
|
10813
|
+
if (!isControlled) {
|
|
10814
|
+
internalValue = newValue;
|
|
10815
|
+
}
|
|
10816
|
+
if (onchange) {
|
|
10817
|
+
onchange(newValue);
|
|
10818
|
+
}
|
|
10819
|
+
}
|
|
10820
|
+
};
|
|
10821
|
+
return {
|
|
10822
|
+
oninit: ({ attrs }) => {
|
|
10823
|
+
internalValue = attrs.defaultValue;
|
|
10824
|
+
},
|
|
10825
|
+
view: ({ attrs }) => {
|
|
10826
|
+
const { value, items, multiple } = attrs;
|
|
10827
|
+
const isControlled = value !== undefined;
|
|
10828
|
+
const currentValue = isControlled ? value : internalValue;
|
|
10829
|
+
return m('.toggle-group', items.map((item) => m(ToggleButton, Object.assign(Object.assign({}, item), { checked: multiple && Array.isArray(currentValue)
|
|
10830
|
+
? currentValue.includes(item.value)
|
|
10831
|
+
: currentValue === item.value, onchange: () => handleSelect(attrs, item, currentValue) }))));
|
|
10832
|
+
},
|
|
10833
|
+
};
|
|
10834
|
+
};
|
|
10835
|
+
|
|
10716
10836
|
/**
|
|
10717
10837
|
* @fileoverview Core TypeScript utility types for mithril-materialized library
|
|
10718
10838
|
* These types improve type safety and developer experience across all components
|
|
@@ -10808,6 +10928,7 @@ exports.TimeRangePicker = TimeRangePicker;
|
|
|
10808
10928
|
exports.Timeline = Timeline;
|
|
10809
10929
|
exports.Toast = Toast;
|
|
10810
10930
|
exports.ToastComponent = ToastComponent;
|
|
10931
|
+
exports.ToggleGroup = ToggleGroup;
|
|
10811
10932
|
exports.Tooltip = Tooltip;
|
|
10812
10933
|
exports.TooltipComponent = TooltipComponent;
|
|
10813
10934
|
exports.TreeView = TreeView;
|