mithril-materialized 3.5.8 → 3.5.10

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.js CHANGED
@@ -1411,19 +1411,18 @@ const CollapsibleItem = () => {
1411
1411
  onclick: onToggle,
1412
1412
  }, [
1413
1413
  iconName ? m('i.material-icons', iconName) : undefined,
1414
- header ? (typeof header === 'string' ? m('span', header) : header) : undefined,
1414
+ header
1415
+ ? typeof header === 'string'
1416
+ ? m('span.collapsible-header-text', header)
1417
+ : m('.collapsible-header-content', header)
1418
+ : undefined,
1415
1419
  ])
1416
1420
  : undefined,
1417
1421
  m('.collapsible-body', {
1418
1422
  style: {
1419
1423
  display: isActive ? 'block' : 'none',
1420
- transition: 'display 0.3s ease',
1421
1424
  },
1422
- }, [
1423
- m('.collapsible-body-content', {
1424
- style: { padding: '2rem' },
1425
- }, body ? (typeof body === 'string' ? m('div', { innerHTML: body }) : body) : undefined),
1426
- ]),
1425
+ }, body ? (typeof body === 'string' ? m('div', { innerHTML: body }) : body) : undefined),
1427
1426
  ]);
1428
1427
  },
1429
1428
  };
@@ -1446,7 +1445,7 @@ const Collapsible = () => {
1446
1445
  });
1447
1446
  },
1448
1447
  view: ({ attrs }) => {
1449
- const { items, accordion = true, class: c, className, style, id } = attrs;
1448
+ const { items, header, accordion = true, class: c, className, style, id } = attrs;
1450
1449
  const toggleItem = (index) => {
1451
1450
  if (accordion) {
1452
1451
  // Accordion mode: only one item can be active
@@ -1468,12 +1467,22 @@ const Collapsible = () => {
1468
1467
  }
1469
1468
  }
1470
1469
  };
1470
+ const collapsibleItems = items.map((item, index) => m(CollapsibleItem, Object.assign(Object.assign({}, item), { key: index, isActive: state.activeItems.has(index), onToggle: () => toggleItem(index) })));
1471
1471
  return items && items.length > 0
1472
- ? m('ul.collapsible', {
1473
- class: c || className,
1474
- style: Object.assign({ border: '1px solid #ddd', borderRadius: '2px', margin: '0.5rem 0 1rem 0' }, style),
1475
- id,
1476
- }, items.map((item, index) => m(CollapsibleItem, Object.assign(Object.assign({}, item), { key: index, isActive: state.activeItems.has(index), onToggle: () => toggleItem(index) }))))
1472
+ ? header
1473
+ ? m('ul.collapsible.with-header', {
1474
+ class: c || className,
1475
+ style,
1476
+ id,
1477
+ }, [
1478
+ m('li.collapsible-main-header', m('h4', typeof header === 'string' ? header : header)),
1479
+ collapsibleItems,
1480
+ ])
1481
+ : m('ul.collapsible', {
1482
+ class: c || className,
1483
+ style,
1484
+ id,
1485
+ }, collapsibleItems)
1477
1486
  : undefined;
1478
1487
  },
1479
1488
  };
@@ -1577,7 +1586,7 @@ const Collection = () => {
1577
1586
  };
1578
1587
  };
1579
1588
 
1580
- const defaultI18n$2 = {
1589
+ const defaultI18n$3 = {
1581
1590
  cancel: 'Cancel',
1582
1591
  clear: 'Clear',
1583
1592
  done: 'Ok',
@@ -1685,9 +1694,9 @@ const DatePicker = () => {
1685
1694
  else if (attrs.displayFormat) {
1686
1695
  finalFormat = attrs.displayFormat;
1687
1696
  }
1688
- const merged = Object.assign({ autoClose: false, format: finalFormat, parse: null, defaultDate: null, setDefaultDate: false, disableWeekends: false, disableDayFn: null, firstDay: 0, minDate: null, maxDate: null, yearRange, showClearBtn: false, showWeekNumbers: false, weekNumbering: 'iso', i18n: defaultI18n$2, onSelect: null, onOpen: null, onClose: null }, attrs);
1697
+ const merged = Object.assign({ autoClose: false, format: finalFormat, parse: null, defaultDate: null, setDefaultDate: false, disableWeekends: false, disableDayFn: null, firstDay: 0, minDate: null, maxDate: null, yearRange, showClearBtn: false, showWeekNumbers: false, weekNumbering: 'iso', i18n: defaultI18n$3, onSelect: null, onOpen: null, onClose: null }, attrs);
1689
1698
  // Merge i18n properly
1690
- merged.i18n = Object.assign(Object.assign({}, defaultI18n$2), attrs.i18n);
1699
+ merged.i18n = Object.assign(Object.assign({}, defaultI18n$3), attrs.i18n);
1691
1700
  return merged;
1692
1701
  };
1693
1702
  const toString = (date, format) => {
@@ -2138,11 +2147,11 @@ const DatePicker = () => {
2138
2147
  prevMonth();
2139
2148
  },
2140
2149
  }, m('svg', {
2141
- fill: '#000000',
2142
2150
  height: '24',
2143
2151
  viewBox: '0 0 24 24',
2144
2152
  width: '24',
2145
2153
  xmlns: 'http://www.w3.org/2000/svg',
2154
+ style: 'fill: var(--mm-text-primary, rgba(0, 0, 0, 0.87));',
2146
2155
  }, [
2147
2156
  m('path', { d: 'M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z' }),
2148
2157
  m('path', { d: 'M0-.5h24v24H0z', fill: 'none' }),
@@ -2204,11 +2213,11 @@ const DatePicker = () => {
2204
2213
  nextMonth();
2205
2214
  },
2206
2215
  }, m('svg', {
2207
- fill: '#000000',
2208
2216
  height: '24',
2209
2217
  viewBox: '0 0 24 24',
2210
2218
  width: '24',
2211
2219
  xmlns: 'http://www.w3.org/2000/svg',
2220
+ style: 'fill: var(--mm-text-primary, rgba(0, 0, 0, 0.87));',
2212
2221
  }, [
2213
2222
  m('path', { d: 'M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z' }),
2214
2223
  m('path', { d: 'M0-.25h24v24H0z', fill: 'none' }),
@@ -3221,19 +3230,29 @@ const TextArea = () => {
3221
3230
  if (!controlled && attrs.defaultValue !== undefined) {
3222
3231
  textarea.value = String(attrs.defaultValue);
3223
3232
  }
3224
- // Height will be calculated by hidden div
3225
3233
  // Update character count state for counter component
3226
3234
  if (maxLength) {
3227
3235
  state.currentLength = textarea.value.length;
3228
3236
  }
3237
+ // Calculate initial height after DOM is fully ready
3238
+ // Use requestAnimationFrame to ensure layout is complete
3239
+ if (state.hiddenDiv) {
3240
+ requestAnimationFrame(() => {
3241
+ if (state.hiddenDiv) {
3242
+ updateHeight(textarea, state.hiddenDiv);
3243
+ m.redraw();
3244
+ }
3245
+ });
3246
+ }
3229
3247
  }, onupdate: ({ dom }) => {
3230
3248
  const textarea = dom;
3231
- if (state.height)
3232
- textarea.style.height = state.height;
3233
- // Trigger height recalculation when value changes programmatically
3249
+ // Recalculate and apply height
3234
3250
  if (state.hiddenDiv) {
3235
3251
  updateHeight(textarea, state.hiddenDiv);
3236
3252
  }
3253
+ if (state.height) {
3254
+ textarea.style.height = state.height;
3255
+ }
3237
3256
  }, onfocus: () => {
3238
3257
  state.active = true;
3239
3258
  }, oninput: (e) => {
@@ -4774,7 +4793,7 @@ const FloatingActionButton = () => {
4774
4793
 
4775
4794
  /**
4776
4795
  * Pure TypeScript MaterialBox - creates an image lightbox that fills the screen when clicked
4777
- * No MaterializeCSS dependencies
4796
+ * Uses CSS classes from _materialbox.scss
4778
4797
  */
4779
4798
  const MaterialBox = () => {
4780
4799
  const state = {
@@ -4790,21 +4809,11 @@ const MaterialBox = () => {
4790
4809
  state.originalImage = img;
4791
4810
  if (attrs.onOpenStart)
4792
4811
  attrs.onOpenStart();
4812
+ const inDuration = attrs.inDuration || 275;
4793
4813
  // Create overlay
4794
4814
  const overlay = document.createElement('div');
4795
4815
  overlay.className = 'materialbox-overlay';
4796
- overlay.style.cssText = `
4797
- position: fixed;
4798
- top: 0;
4799
- left: 0;
4800
- right: 0;
4801
- bottom: 0;
4802
- background-color: rgba(0, 0, 0, 0.85);
4803
- z-index: 1000;
4804
- opacity: 0;
4805
- transition: opacity ${attrs.inDuration || 275}ms ease;
4806
- cursor: zoom-out;
4807
- `;
4816
+ overlay.style.transition = `opacity ${inDuration}ms ease`;
4808
4817
  // Create enlarged image
4809
4818
  const enlargedImg = document.createElement('img');
4810
4819
  enlargedImg.src = img.src;
@@ -4825,36 +4834,18 @@ const MaterialBox = () => {
4825
4834
  finalWidth = maxHeight * aspectRatio;
4826
4835
  }
4827
4836
  // Set initial position and size (same as original image)
4828
- enlargedImg.style.cssText = `
4829
- position: fixed;
4830
- top: ${imgRect.top}px;
4831
- left: ${imgRect.left}px;
4832
- width: ${imgRect.width}px;
4833
- height: ${imgRect.height}px;
4834
- transition: all ${attrs.inDuration || 275}ms ease;
4835
- cursor: zoom-out;
4836
- max-width: none;
4837
- z-index: 1001;
4838
- `;
4837
+ enlargedImg.style.top = `${imgRect.top}px`;
4838
+ enlargedImg.style.left = `${imgRect.left}px`;
4839
+ enlargedImg.style.width = `${imgRect.width}px`;
4840
+ enlargedImg.style.height = `${imgRect.height}px`;
4841
+ enlargedImg.style.transition = `all ${inDuration}ms ease`;
4839
4842
  // Add caption if provided
4840
4843
  let caption = null;
4841
4844
  if (attrs.caption) {
4842
4845
  caption = document.createElement('div');
4843
4846
  caption.className = 'materialbox-caption';
4844
4847
  caption.textContent = attrs.caption;
4845
- caption.style.cssText = `
4846
- position: fixed;
4847
- bottom: 20px;
4848
- left: 50%;
4849
- transform: translateX(-50%);
4850
- color: white;
4851
- font-size: 16px;
4852
- text-align: center;
4853
- opacity: 0;
4854
- transition: opacity ${attrs.inDuration || 275}ms ease ${attrs.inDuration || 275}ms;
4855
- z-index: 1002;
4856
- pointer-events: none;
4857
- `;
4848
+ caption.style.transition = `opacity ${inDuration}ms ease ${inDuration}ms`;
4858
4849
  }
4859
4850
  // Add to DOM
4860
4851
  document.body.appendChild(overlay);
@@ -4889,7 +4880,7 @@ const MaterialBox = () => {
4889
4880
  setTimeout(() => {
4890
4881
  if (attrs.onOpenEnd)
4891
4882
  attrs.onOpenEnd();
4892
- }, attrs.inDuration || 275);
4883
+ }, inDuration);
4893
4884
  };
4894
4885
  const closeBox = (attrs) => {
4895
4886
  if (!state.isOpen || !state.originalImage || !state.overlay || !state.overlayImage)
@@ -4946,8 +4937,14 @@ const MaterialBox = () => {
4946
4937
  },
4947
4938
  view: ({ attrs }) => {
4948
4939
  const { src, alt, width, height, caption, className, style } = attrs, otherAttrs = __rest(attrs, ["src", "alt", "width", "height", "caption", "className", "style"]);
4940
+ // Build style attribute - handle both string and object styles
4941
+ let imgStyle = style || {};
4942
+ if (typeof style !== 'string') {
4943
+ // If style is an object or undefined, add default styles as object
4944
+ imgStyle = Object.assign({ cursor: 'zoom-in', transition: 'opacity 200ms ease' }, (style || {}));
4945
+ }
4949
4946
  return m('img.materialboxed', Object.assign(Object.assign({}, otherAttrs), { src, alt: alt || '', width,
4950
- height, className: ['materialboxed', className].filter(Boolean).join(' ') || undefined, style: Object.assign({ cursor: 'zoom-in', transition: 'opacity 200ms ease' }, style), onclick: (e) => {
4947
+ height, className: ['materialboxed', className].filter(Boolean).join(' ') || undefined, style: imgStyle, onclick: (e) => {
4951
4948
  e.preventDefault();
4952
4949
  openBox(e.target, attrs);
4953
4950
  } }));
@@ -5020,7 +5017,7 @@ const ModalPanel = () => {
5020
5017
  closeModal(attrs);
5021
5018
  }
5022
5019
  }
5023
- const { id, title, description, fixedFooter, bottomSheet, buttons, richContent, className, showCloseButton = true, closeOnBackdropClick = true, closeOnButtonClick = true, } = attrs;
5020
+ const { id, title, description, fixedFooter, bottomSheet, buttons, richContent, className, showCloseButton = true, closeOnBackdropClick = true, closeOnButtonClick = false, } = attrs;
5024
5021
  const modalClasses = [
5025
5022
  'modal',
5026
5023
  className || '',
@@ -5277,6 +5274,11 @@ const Parallax = () => {
5277
5274
  };
5278
5275
  };
5279
5276
 
5277
+ const defaultI18n$2 = {
5278
+ cancel: 'Cancel',
5279
+ clear: 'Clear',
5280
+ done: 'Ok',
5281
+ };
5280
5282
  const defaultOptions = {
5281
5283
  dialRadius: 135,
5282
5284
  outerRadius: 105,
@@ -5287,11 +5289,7 @@ const defaultOptions = {
5287
5289
  defaultTime: 'now',
5288
5290
  fromNow: 0,
5289
5291
  showClearBtn: false,
5290
- i18n: {
5291
- cancel: 'Cancel',
5292
- clear: 'Clear',
5293
- done: 'Ok',
5294
- },
5292
+ i18n: defaultI18n$2,
5295
5293
  autoClose: false,
5296
5294
  twelveHour: true,
5297
5295
  vibrate: true,
@@ -5441,7 +5439,7 @@ const TimePicker = () => {
5441
5439
  state.hours = hours;
5442
5440
  state.minutes = minutes;
5443
5441
  if (state.spanHours) {
5444
- state.spanHours.innerHTML = state.hours.toString();
5442
+ state.spanHours.innerHTML = addLeadingZero(state.hours);
5445
5443
  }
5446
5444
  if (state.spanMinutes) {
5447
5445
  state.spanMinutes.innerHTML = addLeadingZero(state.minutes);
@@ -5549,7 +5547,7 @@ const TimePicker = () => {
5549
5547
  }
5550
5548
  state[state.currentView] = value;
5551
5549
  if (isHours && state.spanHours) {
5552
- state.spanHours.innerHTML = value.toString();
5550
+ state.spanHours.innerHTML = addLeadingZero(value);
5553
5551
  }
5554
5552
  else if (!isHours && state.spanMinutes) {
5555
5553
  state.spanMinutes.innerHTML = addLeadingZero(value);
@@ -5683,7 +5681,7 @@ const TimePicker = () => {
5683
5681
  const TimepickerModal = () => {
5684
5682
  return {
5685
5683
  view: ({ attrs }) => {
5686
- const { showClearBtn, clearLabel, closeLabel, doneLabel } = attrs;
5684
+ const { i18n, showClearBtn } = attrs;
5687
5685
  return [
5688
5686
  m('.modal-content.timepicker-container', [
5689
5687
  m('.timepicker-digital-display', [
@@ -5695,7 +5693,7 @@ const TimePicker = () => {
5695
5693
  oncreate: (vnode) => {
5696
5694
  state.spanHours = vnode.dom;
5697
5695
  },
5698
- }, state.hours.toString()),
5696
+ }, addLeadingZero(state.hours)),
5699
5697
  ':',
5700
5698
  m('span.timepicker-span-minutes', {
5701
5699
  class: state.currentView === 'minutes' ? 'text-primary' : '',
@@ -5775,18 +5773,18 @@ const TimePicker = () => {
5775
5773
  tabindex: options.twelveHour ? '3' : '1',
5776
5774
  style: showClearBtn ? '' : 'visibility: hidden;',
5777
5775
  onclick: () => clear(),
5778
- }, clearLabel),
5776
+ }, i18n.clear),
5779
5777
  m('.confirmation-btns', [
5780
5778
  m('button.btn-flat.timepicker-close.waves-effect', {
5781
5779
  type: 'button',
5782
5780
  tabindex: options.twelveHour ? '3' : '1',
5783
5781
  onclick: () => close(),
5784
- }, closeLabel),
5782
+ }, i18n.cancel),
5785
5783
  m('button.btn-flat.timepicker-close.waves-effect', {
5786
5784
  type: 'button',
5787
5785
  tabindex: options.twelveHour ? '3' : '1',
5788
5786
  onclick: () => done(),
5789
- }, doneLabel),
5787
+ }, i18n.done),
5790
5788
  ]),
5791
5789
  ]),
5792
5790
  ]),
@@ -5803,7 +5801,6 @@ const TimePicker = () => {
5803
5801
  }
5804
5802
  };
5805
5803
  const renderPickerToPortal = (attrs) => {
5806
- const { showClearBtn = false, clearLabel = 'Clear', closeLabel = 'Cancel' } = attrs;
5807
5804
  const pickerModal = m('.timepicker-modal-wrapper', {
5808
5805
  style: {
5809
5806
  position: 'fixed',
@@ -5846,10 +5843,8 @@ const TimePicker = () => {
5846
5843
  },
5847
5844
  }, [
5848
5845
  m(TimepickerModal, {
5849
- showClearBtn,
5850
- clearLabel,
5851
- closeLabel,
5852
- doneLabel: 'OK',
5846
+ i18n: options.i18n,
5847
+ showClearBtn: options.showClearBtn,
5853
5848
  }),
5854
5849
  ]),
5855
5850
  ]);
@@ -5909,7 +5904,7 @@ const TimePicker = () => {
5909
5904
  }
5910
5905
  },
5911
5906
  view: ({ attrs }) => {
5912
- const { id = state.id, label, placeholder, disabled, readonly, required, iconName, helperText, onchange, oninput, useModal = true, showClearBtn = false, clearLabel = 'Clear', closeLabel = 'Cancel', twelveHour, className: cn1, class: cn2, } = attrs;
5907
+ const { id = state.id, label, placeholder, disabled, readonly, required, iconName, helperText, onchange, oninput, useModal = true, twelveHour, className: cn1, class: cn2, } = attrs;
5913
5908
  const className = cn1 || cn2 || 'col s12';
5914
5909
  // Format time value for display
5915
5910
  const formatTime = (hours, minutes, use12Hour) => {
@@ -6355,7 +6350,7 @@ const Select = () => {
6355
6350
  // Render ungrouped options first
6356
6351
  attrs.options
6357
6352
  .filter((option) => !option.group)
6358
- .map((option) => m('li', Object.assign({ class: option.disabled ? 'disabled' : state.focusedIndex === attrs.options.indexOf(option) ? 'focused' : '' }, (option.disabled
6353
+ .map((option) => m('li', Object.assign({ class: `${option.disabled ? 'disabled' : ''}${isSelected(option.id, selectedIds) ? ' selected' : ''}${state.focusedIndex === attrs.options.indexOf(option) ? ' focused' : ''}` }, (option.disabled
6359
6354
  ? {}
6360
6355
  : {
6361
6356
  onclick: () => {