mithril-materialized 2.0.0-beta.8 → 2.0.0-beta.9

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.esm.js CHANGED
@@ -166,9 +166,14 @@ const Mandatory = { view: ({ attrs }) => m('span.mandatory', attrs, '*') };
166
166
  const Label = () => {
167
167
  return {
168
168
  view: (_a) => {
169
- var _b = _a.attrs, { label, id, isMandatory, isActive, className } = _b, params = __rest(_b, ["label", "id", "isMandatory", "isActive", "className"]);
169
+ var _b = _a.attrs, { label, id, isMandatory, isActive, className, initialValue } = _b, params = __rest(_b, ["label", "id", "isMandatory", "isActive", "className", "initialValue"]);
170
170
  return label
171
- ? m('label', Object.assign(Object.assign({}, params), { className: [className, isActive ? 'active' : ''].filter(Boolean).join(' ').trim() || undefined, for: id }), [m.trust(label), isMandatory ? m(Mandatory) : undefined])
171
+ ? m('label', Object.assign(Object.assign({}, params), { className: [className, isActive ? 'active' : ''].filter(Boolean).join(' ').trim() || undefined, for: id, oncreate: ({ dom }) => {
172
+ if (!initialValue)
173
+ return;
174
+ const labelEl = dom;
175
+ labelEl.classList.add('active');
176
+ } }), [m.trust(label), isMandatory ? m(Mandatory) : undefined])
172
177
  : undefined;
173
178
  },
174
179
  };
@@ -2382,6 +2387,7 @@ const TextArea = () => {
2382
2387
  id,
2383
2388
  isMandatory,
2384
2389
  isActive: ((_a = state.textarea) === null || _a === void 0 ? void 0 : _a.value) || placeholder || state.active,
2390
+ initialValue: initialValue !== undefined,
2385
2391
  }),
2386
2392
  m(HelperText, {
2387
2393
  helperText,
@@ -2439,6 +2445,9 @@ const InputField = (type, defaultClass = '') => () => {
2439
2445
  const { className = 'col s12', dataError, dataSuccess, helperText, iconName, id = state.id, initialValue, placeholder, isMandatory, label, maxLength, newRow, oninput, onchange, onkeydown, onkeypress, onkeyup, style, validate } = attrs, params = __rest(attrs, ["className", "dataError", "dataSuccess", "helperText", "iconName", "id", "initialValue", "placeholder", "isMandatory", "label", "maxLength", "newRow", "oninput", "onchange", "onkeydown", "onkeypress", "onkeyup", "style", "validate"]);
2440
2446
  // const attributes = toAttrs(params);
2441
2447
  const cn = [newRow ? 'clear' : '', defaultClass, className].filter(Boolean).join(' ').trim();
2448
+ const isActive = state.active || ((_a = state.inputElement) === null || _a === void 0 ? void 0 : _a.value) || placeholder || type === 'color' || type === 'range'
2449
+ ? true
2450
+ : false;
2442
2451
  return m('.input-field', { className: cn, style }, [
2443
2452
  iconName ? m('i.material-icons.prefix', iconName) : undefined,
2444
2453
  m('input.validate', Object.assign(Object.assign({}, params), { type, tabindex: 0, id,
@@ -2558,14 +2567,8 @@ const InputField = (type, defaultClass = '') => () => {
2558
2567
  label,
2559
2568
  id,
2560
2569
  isMandatory,
2561
- isActive: state.active ||
2562
- ((_a = state.inputElement) === null || _a === void 0 ? void 0 : _a.value) ||
2563
- placeholder ||
2564
- type === 'number' ||
2565
- type === 'color' ||
2566
- type === 'range'
2567
- ? true
2568
- : false,
2570
+ isActive,
2571
+ initialValue: initialValue !== undefined,
2569
2572
  }),
2570
2573
  m(HelperText, {
2571
2574
  helperText,
package/dist/index.js CHANGED
@@ -168,9 +168,14 @@ const Mandatory = { view: ({ attrs }) => m('span.mandatory', attrs, '*') };
168
168
  const Label = () => {
169
169
  return {
170
170
  view: (_a) => {
171
- var _b = _a.attrs, { label, id, isMandatory, isActive, className } = _b, params = __rest(_b, ["label", "id", "isMandatory", "isActive", "className"]);
171
+ var _b = _a.attrs, { label, id, isMandatory, isActive, className, initialValue } = _b, params = __rest(_b, ["label", "id", "isMandatory", "isActive", "className", "initialValue"]);
172
172
  return label
173
- ? m('label', Object.assign(Object.assign({}, params), { className: [className, isActive ? 'active' : ''].filter(Boolean).join(' ').trim() || undefined, for: id }), [m.trust(label), isMandatory ? m(Mandatory) : undefined])
173
+ ? m('label', Object.assign(Object.assign({}, params), { className: [className, isActive ? 'active' : ''].filter(Boolean).join(' ').trim() || undefined, for: id, oncreate: ({ dom }) => {
174
+ if (!initialValue)
175
+ return;
176
+ const labelEl = dom;
177
+ labelEl.classList.add('active');
178
+ } }), [m.trust(label), isMandatory ? m(Mandatory) : undefined])
174
179
  : undefined;
175
180
  },
176
181
  };
@@ -2384,6 +2389,7 @@ const TextArea = () => {
2384
2389
  id,
2385
2390
  isMandatory,
2386
2391
  isActive: ((_a = state.textarea) === null || _a === void 0 ? void 0 : _a.value) || placeholder || state.active,
2392
+ initialValue: initialValue !== undefined,
2387
2393
  }),
2388
2394
  m(HelperText, {
2389
2395
  helperText,
@@ -2441,6 +2447,9 @@ const InputField = (type, defaultClass = '') => () => {
2441
2447
  const { className = 'col s12', dataError, dataSuccess, helperText, iconName, id = state.id, initialValue, placeholder, isMandatory, label, maxLength, newRow, oninput, onchange, onkeydown, onkeypress, onkeyup, style, validate } = attrs, params = __rest(attrs, ["className", "dataError", "dataSuccess", "helperText", "iconName", "id", "initialValue", "placeholder", "isMandatory", "label", "maxLength", "newRow", "oninput", "onchange", "onkeydown", "onkeypress", "onkeyup", "style", "validate"]);
2442
2448
  // const attributes = toAttrs(params);
2443
2449
  const cn = [newRow ? 'clear' : '', defaultClass, className].filter(Boolean).join(' ').trim();
2450
+ const isActive = state.active || ((_a = state.inputElement) === null || _a === void 0 ? void 0 : _a.value) || placeholder || type === 'color' || type === 'range'
2451
+ ? true
2452
+ : false;
2444
2453
  return m('.input-field', { className: cn, style }, [
2445
2454
  iconName ? m('i.material-icons.prefix', iconName) : undefined,
2446
2455
  m('input.validate', Object.assign(Object.assign({}, params), { type, tabindex: 0, id,
@@ -2560,14 +2569,8 @@ const InputField = (type, defaultClass = '') => () => {
2560
2569
  label,
2561
2570
  id,
2562
2571
  isMandatory,
2563
- isActive: state.active ||
2564
- ((_a = state.inputElement) === null || _a === void 0 ? void 0 : _a.value) ||
2565
- placeholder ||
2566
- type === 'number' ||
2567
- type === 'color' ||
2568
- type === 'range'
2569
- ? true
2570
- : false,
2572
+ isActive,
2573
+ initialValue: initialValue !== undefined,
2571
2574
  }),
2572
2575
  m(HelperText, {
2573
2576
  helperText,
package/dist/index.umd.js CHANGED
@@ -170,9 +170,14 @@
170
170
  const Label = () => {
171
171
  return {
172
172
  view: (_a) => {
173
- var _b = _a.attrs, { label, id, isMandatory, isActive, className } = _b, params = __rest(_b, ["label", "id", "isMandatory", "isActive", "className"]);
173
+ var _b = _a.attrs, { label, id, isMandatory, isActive, className, initialValue } = _b, params = __rest(_b, ["label", "id", "isMandatory", "isActive", "className", "initialValue"]);
174
174
  return label
175
- ? m('label', Object.assign(Object.assign({}, params), { className: [className, isActive ? 'active' : ''].filter(Boolean).join(' ').trim() || undefined, for: id }), [m.trust(label), isMandatory ? m(Mandatory) : undefined])
175
+ ? m('label', Object.assign(Object.assign({}, params), { className: [className, isActive ? 'active' : ''].filter(Boolean).join(' ').trim() || undefined, for: id, oncreate: ({ dom }) => {
176
+ if (!initialValue)
177
+ return;
178
+ const labelEl = dom;
179
+ labelEl.classList.add('active');
180
+ } }), [m.trust(label), isMandatory ? m(Mandatory) : undefined])
176
181
  : undefined;
177
182
  },
178
183
  };
@@ -2386,6 +2391,7 @@
2386
2391
  id,
2387
2392
  isMandatory,
2388
2393
  isActive: ((_a = state.textarea) === null || _a === void 0 ? void 0 : _a.value) || placeholder || state.active,
2394
+ initialValue: initialValue !== undefined,
2389
2395
  }),
2390
2396
  m(HelperText, {
2391
2397
  helperText,
@@ -2443,6 +2449,9 @@
2443
2449
  const { className = 'col s12', dataError, dataSuccess, helperText, iconName, id = state.id, initialValue, placeholder, isMandatory, label, maxLength, newRow, oninput, onchange, onkeydown, onkeypress, onkeyup, style, validate } = attrs, params = __rest(attrs, ["className", "dataError", "dataSuccess", "helperText", "iconName", "id", "initialValue", "placeholder", "isMandatory", "label", "maxLength", "newRow", "oninput", "onchange", "onkeydown", "onkeypress", "onkeyup", "style", "validate"]);
2444
2450
  // const attributes = toAttrs(params);
2445
2451
  const cn = [newRow ? 'clear' : '', defaultClass, className].filter(Boolean).join(' ').trim();
2452
+ const isActive = state.active || ((_a = state.inputElement) === null || _a === void 0 ? void 0 : _a.value) || placeholder || type === 'color' || type === 'range'
2453
+ ? true
2454
+ : false;
2446
2455
  return m('.input-field', { className: cn, style }, [
2447
2456
  iconName ? m('i.material-icons.prefix', iconName) : undefined,
2448
2457
  m('input.validate', Object.assign(Object.assign({}, params), { type, tabindex: 0, id,
@@ -2562,14 +2571,8 @@
2562
2571
  label,
2563
2572
  id,
2564
2573
  isMandatory,
2565
- isActive: state.active ||
2566
- ((_a = state.inputElement) === null || _a === void 0 ? void 0 : _a.value) ||
2567
- placeholder ||
2568
- type === 'number' ||
2569
- type === 'color' ||
2570
- type === 'range'
2571
- ? true
2572
- : false,
2574
+ isActive,
2575
+ initialValue: initialValue !== undefined,
2573
2576
  }),
2574
2577
  m(HelperText, {
2575
2578
  helperText,
package/dist/label.d.ts CHANGED
@@ -9,6 +9,8 @@ export interface LabelAttrs extends Attributes {
9
9
  isMandatory?: boolean;
10
10
  /** Add the active class to the label */
11
11
  isActive?: boolean | string;
12
+ /** Determines the initial value of its active state, only used during oncreate */
13
+ initialValue?: boolean;
12
14
  }
13
15
  /** Simple label element, used for most components. */
14
16
  export declare const Label: FactoryComponent<LabelAttrs>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mithril-materialized",
3
- "version": "2.0.0-beta.8",
3
+ "version": "2.0.0-beta.9",
4
4
  "description": "A materialize library for mithril.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",