mithril-materialized 3.5.4 → 3.5.5

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
@@ -7816,9 +7816,19 @@
7816
7816
 
7817
7817
  // List of MaterialIcon SVG icons that are available
7818
7818
  const materialIconSvgNames = [
7819
- 'caret', 'close', 'chevron', 'chevron_left', 'chevron_right', 'menu',
7820
- 'expand', 'collapse', 'check', 'radio_checked', 'radio_unchecked',
7821
- 'light_mode', 'dark_mode'
7819
+ 'caret',
7820
+ 'close',
7821
+ 'chevron',
7822
+ 'chevron_left',
7823
+ 'chevron_right',
7824
+ 'menu',
7825
+ 'expand',
7826
+ 'collapse',
7827
+ 'check',
7828
+ 'radio_checked',
7829
+ 'radio_unchecked',
7830
+ 'light_mode',
7831
+ 'dark_mode',
7822
7832
  ];
7823
7833
  /**
7824
7834
  * Helper function to render icons based on IconDefinition type
@@ -7848,31 +7858,42 @@
7848
7858
  return null;
7849
7859
  };
7850
7860
  /**
7851
- * Helper function to render a single sidenav item (for header/footer items)
7861
+ * Sidenav Header/Footer Item Component
7852
7862
  */
7853
- const renderSidenavItem = (item, isExpanded, position) => {
7854
- const { text, icon, onclick, href, className = '' } = item;
7855
- const isRightAligned = position === 'right';
7856
- const content = isRightAligned
7857
- ? [
7858
- isExpanded && m('span.sidenav-item-text', { style: { 'flex': '1', 'text-align': 'left', 'margin-right': '8px' } }, text),
7859
- renderIcon(icon, { 'min-width': '24px', 'width': '24px' }),
7860
- ]
7861
- : [
7862
- renderIcon(icon, { 'min-width': '24px', 'width': '24px' }),
7863
- isExpanded && m('span.sidenav-item-text', { style: { 'margin-left': '8px', 'flex': '1' } }, text),
7864
- ];
7865
- const linkStyle = {
7866
- display: 'flex',
7867
- 'align-items': 'center',
7868
- padding: isExpanded ? '12px 16px' : '12px 18px',
7869
- 'justify-content': isExpanded ? (isRightAligned ? 'flex-end' : 'flex-start') : 'center',
7870
- };
7871
- return m('li', { class: className }, m('a', {
7872
- href: href || '#!',
7873
- onclick: onclick,
7874
- style: linkStyle,
7875
- }, content));
7863
+ const SidenavHeaderFooterItem = () => {
7864
+ return {
7865
+ view: ({ attrs }) => {
7866
+ const { text, icon, onclick, href, className = '', _isExpanded = true, _position = 'left' } = attrs;
7867
+ const isRightAligned = _position === 'right';
7868
+ const handleClick = (e) => {
7869
+ if (onclick) {
7870
+ e.preventDefault();
7871
+ onclick(e);
7872
+ }
7873
+ };
7874
+ const content = isRightAligned
7875
+ ? [
7876
+ _isExpanded &&
7877
+ m('span.sidenav-item-text', { style: { flex: '1', 'text-align': 'left', 'margin-right': '8px' } }, text),
7878
+ renderIcon(icon, { 'min-width': '24px', width: '24px' }),
7879
+ ]
7880
+ : [
7881
+ renderIcon(icon, { 'min-width': '24px', width: '24px' }),
7882
+ _isExpanded && m('span.sidenav-item-text', { style: { 'margin-left': '8px', flex: '1' } }, text),
7883
+ ];
7884
+ const linkStyle = {
7885
+ display: 'flex',
7886
+ 'align-items': 'center',
7887
+ padding: _isExpanded ? '12px 16px' : '12px 18px',
7888
+ 'justify-content': _isExpanded ? (isRightAligned ? 'flex-end' : 'flex-start') : 'center',
7889
+ };
7890
+ return m('li', { class: className }, m('a', {
7891
+ href: href || '#!',
7892
+ onclick: handleClick,
7893
+ style: linkStyle,
7894
+ }, content));
7895
+ },
7896
+ };
7876
7897
  };
7877
7898
  /**
7878
7899
  * Sidenav Component
@@ -7997,7 +8018,8 @@
7997
8018
  style: { width: '24px', height: '24px' },
7998
8019
  })),
7999
8020
  // Header item (if provided, appears before expand/collapse toggle)
8000
- attrs.header && renderSidenavItem(attrs.header, isExpanded, position),
8021
+ attrs.header &&
8022
+ m(SidenavHeaderFooterItem, Object.assign(Object.assign({}, attrs.header), { _isExpanded: isExpanded, _position: position })),
8001
8023
  // Expand/collapse toggle button (if expandable, right below hamburger)
8002
8024
  expandable &&
8003
8025
  m('li.sidenav-expand-toggle', {
@@ -8012,8 +8034,12 @@
8012
8034
  onclick: () => toggleExpanded(attrs),
8013
8035
  }, m(MaterialIcon, {
8014
8036
  name: position === 'right'
8015
- ? (isExpanded ? 'chevron_right' : 'chevron_left')
8016
- : (isExpanded ? 'chevron_left' : 'chevron_right'),
8037
+ ? isExpanded
8038
+ ? 'chevron_right'
8039
+ : 'chevron_left'
8040
+ : isExpanded
8041
+ ? 'chevron_left'
8042
+ : 'chevron_right',
8017
8043
  style: { width: '24px', height: '24px' },
8018
8044
  })),
8019
8045
  // Children (menu items) - inject internal props
@@ -8027,7 +8053,8 @@
8027
8053
  })
8028
8054
  : children,
8029
8055
  // Footer item (if provided, appears at the bottom)
8030
- attrs.footer && renderSidenavItem(attrs.footer, isExpanded, position),
8056
+ attrs.footer &&
8057
+ m(SidenavHeaderFooterItem, Object.assign(Object.assign({}, attrs.footer), { _isExpanded: isExpanded, _position: position, className: 'sidenav-footer-item' })),
8031
8058
  ]),
8032
8059
  ];
8033
8060
  },
@@ -8060,7 +8087,7 @@
8060
8087
  const submenuContent = isRightAligned
8061
8088
  ? [
8062
8089
  // Right-aligned: text on left, icons on right
8063
- isExpanded && m('span', { style: { 'flex': '1', 'text-align': 'left' } }, text),
8090
+ isExpanded && m('span', { style: { flex: '1', 'text-align': 'left' } }, text),
8064
8091
  icon && isExpanded && renderIcon(icon, { 'font-size': '18px' }),
8065
8092
  indicatorIcon,
8066
8093
  ]
@@ -8104,12 +8131,7 @@
8104
8131
  return m('li.subheader', text || children);
8105
8132
  }
8106
8133
  const hasSubmenu = submenu && submenu.length > 0;
8107
- const itemClasses = [
8108
- active ? 'active' : '',
8109
- disabled ? 'disabled' : '',
8110
- hasSubmenu ? 'has-submenu' : '',
8111
- className,
8112
- ]
8134
+ const itemClasses = [active ? 'active' : '', disabled ? 'disabled' : '', hasSubmenu ? 'has-submenu' : '', className]
8113
8135
  .filter(Boolean)
8114
8136
  .join(' ') || undefined;
8115
8137
  const handleMainClick = (e) => {
@@ -8118,6 +8140,7 @@
8118
8140
  isSubmenuOpen = active ? !isSubmenuOpen : true;
8119
8141
  }
8120
8142
  if (onclick && !disabled) {
8143
+ e.preventDefault();
8121
8144
  onclick(e);
8122
8145
  }
8123
8146
  };
@@ -8130,13 +8153,14 @@
8130
8153
  const content = isRightAligned
8131
8154
  ? [
8132
8155
  // Right-aligned: text on left, icon on right
8133
- isExpanded && m('span.sidenav-item-text', { style: { 'flex': '1', 'text-align': 'left', 'margin-right': '8px' } }, text || children),
8134
- renderIcon(icon, { 'min-width': '24px', 'width': '24px' }),
8156
+ isExpanded &&
8157
+ m('span.sidenav-item-text', { style: { flex: '1', 'text-align': 'left', 'margin-right': '8px' } }, text || children),
8158
+ renderIcon(icon, { 'min-width': '24px', width: '24px' }),
8135
8159
  ]
8136
8160
  : [
8137
8161
  // Left-aligned: icon on left, text on right
8138
- renderIcon(icon, { 'min-width': '24px', 'width': '24px' }),
8139
- isExpanded && m('span.sidenav-item-text', { style: { 'margin-left': '8px', 'flex': '1' } }, text || children),
8162
+ renderIcon(icon, { 'min-width': '24px', width: '24px' }),
8163
+ isExpanded && m('span.sidenav-item-text', { style: { 'margin-left': '8px', flex: '1' } }, text || children),
8140
8164
  ];
8141
8165
  const linkStyle = {
8142
8166
  display: 'flex',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mithril-materialized",
3
- "version": "3.5.4",
3
+ "version": "3.5.5",
4
4
  "description": "A materialize library for mithril.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -130,6 +130,8 @@ ul.sidenav.right-aligned li > a:not(.btn):not(.btn-large):not(.btn-flat):not(.bt
130
130
  backface-visibility: hidden;
131
131
  transform: translateX(-105%);
132
132
  transition: transform 0.3s ease, left 0.3s ease, right 0.3s ease;
133
+ display: flex;
134
+ flex-direction: column;
133
135
 
134
136
  @extend .z-depth-1 !optional;
135
137
 
@@ -590,6 +592,11 @@ ul.sidenav.right-aligned li > a:not(.btn):not(.btn-large):not(.btn-flat):not(.bt
590
592
  }
591
593
  }
592
594
 
595
+ // Footer item positioning
596
+ .sidenav-footer-item {
597
+ margin-top: auto;
598
+ }
599
+
593
600
  // Animation for smooth width transitions
594
601
  .sidenav {
595
602
  transition: transform 0.3s ease, width 0.3s ease;