mithril-materialized 2.0.1 → 3.0.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/button.d.ts CHANGED
@@ -21,16 +21,16 @@ export interface HtmlAttrs {
21
21
  *
22
22
  * // Submit button with icon
23
23
  * m(Button, {
24
- * variant: { type: 'submit' },
24
+ * variant: 'submit',
25
25
  * label: 'Save',
26
26
  * iconName: 'save',
27
27
  * iconClass: 'small left'
28
28
  * })
29
29
  *
30
- * // Modal trigger button
30
+ * // Reset button
31
31
  * m(Button, {
32
- * variant: { type: 'modal', modalId: 'my-modal' },
33
- * label: 'Open Modal'
32
+ * variant: 'reset',
33
+ * label: 'Clear Form'
34
34
  * })
35
35
  * ```
36
36
  */
@@ -45,19 +45,21 @@ export interface ButtonAttrs extends Attributes {
45
45
  */
46
46
  iconClass?: IconClass;
47
47
  /**
48
- * Button behavior variant - determines button type and behavior
48
+ * Button type - determines the HTML button behavior
49
+ * @default 'button'
49
50
  * @example
50
- * { type: 'button' } - Standard button
51
- * { type: 'submit' } - Form submit button
52
- * { type: 'modal', modalId: 'my-modal' } - Modal trigger
53
- * { type: 'reset' } - Form reset button
51
+ * ```typescript
52
+ * // Standard clickable button (default)
53
+ * variant: 'button'
54
+ *
55
+ * // Form submission button
56
+ * variant: 'submit'
57
+ *
58
+ * // Form reset button
59
+ * variant: 'reset'
60
+ * ```
54
61
  */
55
62
  variant?: ButtonVariant;
56
- /**
57
- * @deprecated Use variant instead
58
- * If the button is intended to open a modal, specify its modal id so we can trigger it
59
- */
60
- modalId?: string;
61
63
  /**
62
64
  * @deprecated Use native HTML attributes directly instead
63
65
  * Some additional HTML attributes that can be attached to the button
package/dist/index.esm.js CHANGED
@@ -416,22 +416,17 @@ const ButtonFactory = (element, defaultClassNames, type = '') => {
416
416
  return () => {
417
417
  return {
418
418
  view: ({ attrs }) => {
419
- const { modalId, tooltip, tooltipPosition, tooltipPostion, // Keep for backwards compatibility
420
- iconName, iconClass, label, className, attr, variant } = attrs, params = __rest(attrs, ["modalId", "tooltip", "tooltipPosition", "tooltipPostion", "iconName", "iconClass", "label", "className", "attr", "variant"]);
421
- // Handle both new variant prop and legacy modalId/type
422
- const buttonType = (variant === null || variant === void 0 ? void 0 : variant.type) || (modalId ? 'modal' : type || 'button');
423
- const modalTarget = (variant === null || variant === void 0 ? void 0 : variant.type) === 'modal' ? variant.modalId : modalId;
424
- const cn = [modalTarget ? 'modal-trigger' : '', tooltip ? 'tooltipped' : '', defaultClassNames, className]
419
+ const { tooltip, tooltipPosition, tooltipPostion, // Keep for backwards compatibility
420
+ iconName, iconClass, label, className, variant } = attrs, params = __rest(attrs, ["tooltip", "tooltipPosition", "tooltipPostion", "iconName", "iconClass", "label", "className", "variant"]);
421
+ // Use variant or fallback to factory type
422
+ const buttonType = variant || type || 'button';
423
+ const cn = [tooltip ? 'tooltipped' : '', defaultClassNames, className]
425
424
  .filter(Boolean)
426
425
  .join(' ')
427
426
  .trim();
428
427
  // Use tooltipPosition if available, fallback to legacy tooltipPostion
429
428
  const position = tooltipPosition || tooltipPostion || 'top';
430
- return m(element, Object.assign(Object.assign(Object.assign({}, params), attr), { className: cn, href: modalTarget ? `#${modalTarget}` : undefined, 'data-position': tooltip ? position : undefined, 'data-tooltip': tooltip || undefined, type: buttonType === 'modal' ? 'button' : buttonType }),
431
- // `${dca}${modalId ? `.modal-trigger[href=#${modalId}]` : ''}${
432
- // tooltip ? `.tooltipped[data-position=${tooltipPostion || 'top'}][data-tooltip=${tooltip}]` : ''
433
- // }${toAttributeString(attr)}`, {}
434
- iconName ? m(Icon, { iconName, className: iconClass || 'left' }) : undefined, label ? label : undefined);
429
+ return m(element, Object.assign(Object.assign({}, params), { className: cn, 'data-position': tooltip ? position : undefined, 'data-tooltip': tooltip || undefined, type: buttonType }), iconName ? m(Icon, { iconName, className: iconClass || 'left' }) : undefined, label ? label : undefined);
435
430
  },
436
431
  };
437
432
  };
package/dist/index.js CHANGED
@@ -418,22 +418,17 @@ const ButtonFactory = (element, defaultClassNames, type = '') => {
418
418
  return () => {
419
419
  return {
420
420
  view: ({ attrs }) => {
421
- const { modalId, tooltip, tooltipPosition, tooltipPostion, // Keep for backwards compatibility
422
- iconName, iconClass, label, className, attr, variant } = attrs, params = __rest(attrs, ["modalId", "tooltip", "tooltipPosition", "tooltipPostion", "iconName", "iconClass", "label", "className", "attr", "variant"]);
423
- // Handle both new variant prop and legacy modalId/type
424
- const buttonType = (variant === null || variant === void 0 ? void 0 : variant.type) || (modalId ? 'modal' : type || 'button');
425
- const modalTarget = (variant === null || variant === void 0 ? void 0 : variant.type) === 'modal' ? variant.modalId : modalId;
426
- const cn = [modalTarget ? 'modal-trigger' : '', tooltip ? 'tooltipped' : '', defaultClassNames, className]
421
+ const { tooltip, tooltipPosition, tooltipPostion, // Keep for backwards compatibility
422
+ iconName, iconClass, label, className, variant } = attrs, params = __rest(attrs, ["tooltip", "tooltipPosition", "tooltipPostion", "iconName", "iconClass", "label", "className", "variant"]);
423
+ // Use variant or fallback to factory type
424
+ const buttonType = variant || type || 'button';
425
+ const cn = [tooltip ? 'tooltipped' : '', defaultClassNames, className]
427
426
  .filter(Boolean)
428
427
  .join(' ')
429
428
  .trim();
430
429
  // Use tooltipPosition if available, fallback to legacy tooltipPostion
431
430
  const position = tooltipPosition || tooltipPostion || 'top';
432
- return m(element, Object.assign(Object.assign(Object.assign({}, params), attr), { className: cn, href: modalTarget ? `#${modalTarget}` : undefined, 'data-position': tooltip ? position : undefined, 'data-tooltip': tooltip || undefined, type: buttonType === 'modal' ? 'button' : buttonType }),
433
- // `${dca}${modalId ? `.modal-trigger[href=#${modalId}]` : ''}${
434
- // tooltip ? `.tooltipped[data-position=${tooltipPostion || 'top'}][data-tooltip=${tooltip}]` : ''
435
- // }${toAttributeString(attr)}`, {}
436
- iconName ? m(Icon, { iconName, className: iconClass || 'left' }) : undefined, label ? label : undefined);
431
+ return m(element, Object.assign(Object.assign({}, params), { className: cn, 'data-position': tooltip ? position : undefined, 'data-tooltip': tooltip || undefined, type: buttonType }), iconName ? m(Icon, { iconName, className: iconClass || 'left' }) : undefined, label ? label : undefined);
437
432
  },
438
433
  };
439
434
  };
package/dist/index.umd.js CHANGED
@@ -420,22 +420,17 @@
420
420
  return () => {
421
421
  return {
422
422
  view: ({ attrs }) => {
423
- const { modalId, tooltip, tooltipPosition, tooltipPostion, // Keep for backwards compatibility
424
- iconName, iconClass, label, className, attr, variant } = attrs, params = __rest(attrs, ["modalId", "tooltip", "tooltipPosition", "tooltipPostion", "iconName", "iconClass", "label", "className", "attr", "variant"]);
425
- // Handle both new variant prop and legacy modalId/type
426
- const buttonType = (variant === null || variant === void 0 ? void 0 : variant.type) || (modalId ? 'modal' : type || 'button');
427
- const modalTarget = (variant === null || variant === void 0 ? void 0 : variant.type) === 'modal' ? variant.modalId : modalId;
428
- const cn = [modalTarget ? 'modal-trigger' : '', tooltip ? 'tooltipped' : '', defaultClassNames, className]
423
+ const { tooltip, tooltipPosition, tooltipPostion, // Keep for backwards compatibility
424
+ iconName, iconClass, label, className, variant } = attrs, params = __rest(attrs, ["tooltip", "tooltipPosition", "tooltipPostion", "iconName", "iconClass", "label", "className", "variant"]);
425
+ // Use variant or fallback to factory type
426
+ const buttonType = variant || type || 'button';
427
+ const cn = [tooltip ? 'tooltipped' : '', defaultClassNames, className]
429
428
  .filter(Boolean)
430
429
  .join(' ')
431
430
  .trim();
432
431
  // Use tooltipPosition if available, fallback to legacy tooltipPostion
433
432
  const position = tooltipPosition || tooltipPostion || 'top';
434
- return m(element, Object.assign(Object.assign(Object.assign({}, params), attr), { className: cn, href: modalTarget ? `#${modalTarget}` : undefined, 'data-position': tooltip ? position : undefined, 'data-tooltip': tooltip || undefined, type: buttonType === 'modal' ? 'button' : buttonType }),
435
- // `${dca}${modalId ? `.modal-trigger[href=#${modalId}]` : ''}${
436
- // tooltip ? `.tooltipped[data-position=${tooltipPostion || 'top'}][data-tooltip=${tooltip}]` : ''
437
- // }${toAttributeString(attr)}`, {}
438
- iconName ? m(Icon, { iconName, className: iconClass || 'left' }) : undefined, label ? label : undefined);
433
+ return m(element, Object.assign(Object.assign({}, params), { className: cn, 'data-position': tooltip ? position : undefined, 'data-tooltip': tooltip || undefined, type: buttonType }), iconName ? m(Icon, { iconName, className: iconClass || 'left' }) : undefined, label ? label : undefined);
439
434
  },
440
435
  };
441
436
  };
package/dist/types.d.ts CHANGED
@@ -96,24 +96,20 @@ export declare const isValidationSuccess: (result: ValidationResult) => result i
96
96
  */
97
97
  export declare const isValidationError: (result: ValidationResult) => result is ValidationError;
98
98
  /**
99
- * Button variant discriminated union for type-safe button configurations
99
+ * Button type - determines the HTML button behavior
100
+ * @example
101
+ * ```typescript
102
+ * // Standard clickable button (default)
103
+ * variant: 'button'
104
+ *
105
+ * // Form submission button
106
+ * variant: 'submit'
107
+ *
108
+ * // Form reset button
109
+ * variant: 'reset'
110
+ * ```
100
111
  */
101
- export type ButtonVariant = {
102
- type: 'button';
103
- submit?: never;
104
- modalId?: never;
105
- } | {
106
- type: 'submit';
107
- modalId?: never;
108
- } | {
109
- type: 'modal';
110
- modalId: string;
111
- submit?: never;
112
- } | {
113
- type: 'reset';
114
- modalId?: never;
115
- submit?: never;
116
- };
112
+ export type ButtonVariant = 'button' | 'submit' | 'reset';
117
113
  /**
118
114
  * Input type union with proper HTML input types
119
115
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mithril-materialized",
3
- "version": "2.0.1",
3
+ "version": "3.0.0",
4
4
  "description": "A materialize library for mithril.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",