mithril-materialized 3.5.0 → 3.5.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.
package/dist/index.umd.js CHANGED
@@ -3300,9 +3300,11 @@
3300
3300
  ? true
3301
3301
  : false;
3302
3302
  const rangeType = type === 'range' && !attrs.minmax;
3303
+ // Only add validate class if input is interactive and validation is needed
3304
+ const shouldValidate = !isNonInteractive && (validate || type === 'email' || type === 'url' || isNumeric);
3303
3305
  return m('.input-field', { className: cn, style }, [
3304
3306
  iconName ? m('i.material-icons.prefix', iconName) : undefined,
3305
- m('input.validate', Object.assign(Object.assign({}, params), { type, tabindex: 0, id,
3307
+ m('input', Object.assign(Object.assign({ class: shouldValidate ? 'validate' : undefined }, params), { type, tabindex: 0, id,
3306
3308
  placeholder, value: controlled ? value : undefined, class: type === 'range' && attrs.vertical ? 'range-slider vertical' : undefined, style: type === 'range' && attrs.vertical
3307
3309
  ? {
3308
3310
  height: attrs.height || '200px',
@@ -3383,6 +3385,17 @@
3383
3385
  state.active = false;
3384
3386
  const target = e.target;
3385
3387
  state.hasInteracted = true;
3388
+ // Skip validation for readonly/disabled inputs
3389
+ if (attrs.readonly || attrs.disabled) {
3390
+ // Call original onblur if provided
3391
+ if (attrs.onblur) {
3392
+ attrs.onblur(e);
3393
+ }
3394
+ if (onchange && state.inputElement) {
3395
+ onchange(getValue(state.inputElement));
3396
+ }
3397
+ return;
3398
+ }
3386
3399
  if (target && validate) {
3387
3400
  const value = getValue(target);
3388
3401
  // Only validate if user has entered some text
@@ -6293,7 +6306,7 @@
6293
6306
  view: ({ attrs }) => {
6294
6307
  var _a;
6295
6308
  const controlled = isControlled(attrs);
6296
- const { newRow, className = 'col s12', key, options, multiple = false, label, helperText, placeholder = '', isMandatory, iconName, style, disabled, } = attrs;
6309
+ const { newRow, className = 'col s12', key, options = [], multiple = false, label, helperText, placeholder = '', isMandatory, iconName, style, disabled, } = attrs;
6297
6310
  state.isMultiple = multiple;
6298
6311
  // Get selected IDs from props or internal state
6299
6312
  let selectedIds;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mithril-materialized",
3
- "version": "3.5.0",
3
+ "version": "3.5.2",
4
4
  "description": "A materialize library for mithril.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -76,32 +76,32 @@ textarea.materialize-textarea {
76
76
  }
77
77
 
78
78
  // Valid Input Style
79
- &.valid,
80
- &:focus.valid {
79
+ &.valid:not([readonly]):not([disabled]),
80
+ &:focus.valid:not([readonly]):not([disabled]) {
81
81
  @extend %valid-input-style !optional;
82
82
  }
83
83
 
84
84
  // Custom Success Message
85
- &.valid ~ .helper-text:after,
86
- &:focus.valid ~ .helper-text:after {
85
+ &.valid:not([readonly]):not([disabled]) ~ .helper-text:after,
86
+ &:focus.valid:not([readonly]):not([disabled]) ~ .helper-text:after {
87
87
  @extend %custom-success-message !optional;
88
88
  }
89
- &:focus.valid ~ label {
89
+ &:focus.valid:not([readonly]):not([disabled]) ~ label {
90
90
  color: variables.$input-success-color;
91
91
  }
92
92
 
93
93
  // Invalid Input Style
94
- &.invalid,
95
- &:focus.invalid {
94
+ &.invalid:not([readonly]):not([disabled]),
95
+ &:focus.invalid:not([readonly]):not([disabled]) {
96
96
  @extend %invalid-input-style !optional;
97
97
  }
98
98
 
99
99
  // Custom Error message
100
- &.invalid ~ .helper-text:after,
101
- &:focus.invalid ~ .helper-text:after {
100
+ &.invalid:not([readonly]):not([disabled]) ~ .helper-text:after,
101
+ &:focus.invalid:not([readonly]):not([disabled]) ~ .helper-text:after {
102
102
  @extend %custom-error-message !optional;
103
103
  }
104
- &:focus.invalid ~ label {
104
+ &:focus.invalid:not([readonly]):not([disabled]) ~ label {
105
105
  color: variables.$input-error-color;
106
106
  }
107
107