@m3e/form-field 1.0.0-rc.2 → 1.0.0-rc.4

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/README.md CHANGED
@@ -27,7 +27,7 @@ Alternately, you can explicitly reference the `html-custom-data.json` and `css-c
27
27
  }
28
28
  ```
29
29
 
30
- ## 🚀 Browser Usage
30
+ ## 🚀 Native Module Support
31
31
 
32
32
  This package uses [JavaScript Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#module_specifiers). To use it directly in a browser without a bundler, use a module script similar to the following.
33
33
 
@@ -445,6 +445,9 @@
445
445
  {
446
446
  "name": "checkValidity",
447
447
  "default": "false",
448
+ "type": {
449
+ "text": "boolean"
450
+ },
448
451
  "description": "Whether to check validity.",
449
452
  "optional": true
450
453
  }
@@ -1646,25 +1649,6 @@
1646
1649
  "kind": "mixin",
1647
1650
  "description": "Mixin that adds support for custom event attributes.",
1648
1651
  "name": "EventAttribute",
1649
- "members": [
1650
- {
1651
- "kind": "method",
1652
- "name": "dispatchEvent",
1653
- "return": {
1654
- "type": {
1655
- "text": "boolean"
1656
- }
1657
- },
1658
- "parameters": [
1659
- {
1660
- "name": "event",
1661
- "type": {
1662
- "text": "Event"
1663
- }
1664
- }
1665
- ]
1666
- }
1667
- ],
1668
1652
  "parameters": [
1669
1653
  {
1670
1654
  "name": "base",
@@ -1962,6 +1946,17 @@
1962
1946
  "description": "Mixin to augment an element with behavior used to submit a form.",
1963
1947
  "name": "FormSubmitter",
1964
1948
  "members": [
1949
+ {
1950
+ "kind": "field",
1951
+ "name": "formAssociated",
1952
+ "type": {
1953
+ "text": "boolean"
1954
+ },
1955
+ "static": true,
1956
+ "readonly": true,
1957
+ "default": "true",
1958
+ "description": "Indicates that this custom element participates in form submission, validation, and form state restoration."
1959
+ },
1965
1960
  {
1966
1961
  "kind": "field",
1967
1962
  "name": "name",
@@ -2498,6 +2493,11 @@
2498
2493
  "kind": "javascript-module",
2499
2494
  "path": "../core/src/shared/mixins/Labelled.ts",
2500
2495
  "declarations": [
2496
+ {
2497
+ "kind": "variable",
2498
+ "name": "updateLabels",
2499
+ "description": "A symbol through which to update labels to reflect a control's current state."
2500
+ },
2501
2501
  {
2502
2502
  "kind": "function",
2503
2503
  "name": "isLabelledMixin",
@@ -2547,16 +2547,6 @@
2547
2547
  },
2548
2548
  "description": "The label elements that the element is associated with.",
2549
2549
  "readonly": true
2550
- },
2551
- {
2552
- "kind": "method",
2553
- "name": "[_updateLabels]",
2554
- "privacy": "private",
2555
- "return": {
2556
- "type": {
2557
- "text": "void"
2558
- }
2559
- }
2560
2550
  }
2561
2551
  ],
2562
2552
  "parameters": [
@@ -2571,6 +2561,14 @@
2571
2561
  }
2572
2562
  ],
2573
2563
  "exports": [
2564
+ {
2565
+ "kind": "js",
2566
+ "name": "updateLabels",
2567
+ "declaration": {
2568
+ "name": "updateLabels",
2569
+ "module": "../core/src/shared/mixins/Labelled.ts"
2570
+ }
2571
+ },
2574
2572
  {
2575
2573
  "kind": "js",
2576
2574
  "name": "isLabelledMixin",
@@ -4,7 +4,7 @@
4
4
  "tags": [
5
5
  {
6
6
  "name": "m3e-form-field",
7
- "description": "A container for form controls that applies Material Design styling and behavior.\n---\n\n\n### **Methods:**\n - **notifyControlStateChange(checkValidity): _void_** - Notifies the form field that the state of the hosted `control` has changed.\n\n### **Slots:**\n - _default_ - Renders the control of the field.\n- **prefix** - Renders content before the fields's control.\n- **prefix-text** - Renders text before the fields's control.\n- **suffix** - Renders content after the fields's control.\n- **suffix-text** - Renders text after the fields's control.\n- **hint** - Renders hint text in the fields's subscript, when the control is valid.\n- **error** - Renders error text in the fields's subscript, when the control is invalid.\n\n### **CSS Properties:**\n - **--m3e-form-field-font-size** - Font size for the form field container text. _(default: undefined)_\n- **--m3e-form-field-font-weight** - Font weight for the form field container text. _(default: undefined)_\n- **--m3e-form-field-line-height** - Line height for the form field container text. _(default: undefined)_\n- **--m3e-form-field-tracking** - Letter spacing for the form field container text. _(default: undefined)_\n- **--m3e-form-field-label-font-size** - Font size for the floating label. _(default: undefined)_\n- **--m3e-form-field-label-font-weight** - Font weight for the floating label. _(default: undefined)_\n- **--m3e-form-field-label-line-height** - Line height for the floating label. _(default: undefined)_\n- **--m3e-form-field-label-tracking** - Letter spacing for the floating label. _(default: undefined)_\n- **--m3e-form-field-subscript-font-size** - Font size for hint and error text. _(default: undefined)_\n- **--m3e-form-field-subscript-font-weight** - Font weight for hint and error text. _(default: undefined)_\n- **--m3e-form-field-subscript-line-height** - Line height for hint and error text. _(default: undefined)_\n- **--m3e-form-field-subscript-tracking** - Letter spacing for hint and error text. _(default: undefined)_\n- **--m3e-form-field-color** - Text color for the form field container. _(default: undefined)_\n- **--m3e-form-field-subscript-color** - Color for hint and error text. _(default: undefined)_\n- **--m3e-form-field-invalid-color** - Color used when the control is invalid. _(default: undefined)_\n- **--m3e-form-field-focused-outline-color** - Outline color when focused. _(default: undefined)_\n- **--m3e-form-field-focused-color** - Label color when focused. _(default: undefined)_\n- **--m3e-form-field-outline-color** - Outline color in outlined variant. _(default: undefined)_\n- **--m3e-form-field-container-color** - Background color in filled variant. _(default: undefined)_\n- **--m3e-form-field-hover-container-color** - Hover background color in filled variant. _(default: undefined)_\n- **--m3e-form-field-width** - Width of the form field container. _(default: undefined)_\n- **--m3e-form-field-icon-size** - Size of prefix and suffix icons. _(default: undefined)_\n- **--m3e-outlined-form-field-container-shape** - Corner radius for outlined container. _(default: undefined)_\n- **--m3e-form-field-container-shape** - Corner radius for filled container. _(default: undefined)_\n- **--m3e-form-field-hover-container-opacity** - Opacity for hover background in filled variant. _(default: undefined)_\n- **--m3e-form-field-disabled-opacity** - Opacity for disabled text. _(default: undefined)_\n- **--m3e-form-field-disabled-container-opacity** - Opacity for disabled container background. _(default: undefined)_",
7
+ "description": "A container for form controls that applies Material Design styling and behavior.\n---\n\n\n### **Methods:**\n - **notifyControlStateChange(checkValidity: _boolean_): _void_** - Notifies the form field that the state of the hosted `control` has changed.\n\n### **Slots:**\n - _default_ - Renders the control of the field.\n- **prefix** - Renders content before the fields's control.\n- **prefix-text** - Renders text before the fields's control.\n- **suffix** - Renders content after the fields's control.\n- **suffix-text** - Renders text after the fields's control.\n- **hint** - Renders hint text in the fields's subscript, when the control is valid.\n- **error** - Renders error text in the fields's subscript, when the control is invalid.\n\n### **CSS Properties:**\n - **--m3e-form-field-font-size** - Font size for the form field container text. _(default: undefined)_\n- **--m3e-form-field-font-weight** - Font weight for the form field container text. _(default: undefined)_\n- **--m3e-form-field-line-height** - Line height for the form field container text. _(default: undefined)_\n- **--m3e-form-field-tracking** - Letter spacing for the form field container text. _(default: undefined)_\n- **--m3e-form-field-label-font-size** - Font size for the floating label. _(default: undefined)_\n- **--m3e-form-field-label-font-weight** - Font weight for the floating label. _(default: undefined)_\n- **--m3e-form-field-label-line-height** - Line height for the floating label. _(default: undefined)_\n- **--m3e-form-field-label-tracking** - Letter spacing for the floating label. _(default: undefined)_\n- **--m3e-form-field-subscript-font-size** - Font size for hint and error text. _(default: undefined)_\n- **--m3e-form-field-subscript-font-weight** - Font weight for hint and error text. _(default: undefined)_\n- **--m3e-form-field-subscript-line-height** - Line height for hint and error text. _(default: undefined)_\n- **--m3e-form-field-subscript-tracking** - Letter spacing for hint and error text. _(default: undefined)_\n- **--m3e-form-field-color** - Text color for the form field container. _(default: undefined)_\n- **--m3e-form-field-subscript-color** - Color for hint and error text. _(default: undefined)_\n- **--m3e-form-field-invalid-color** - Color used when the control is invalid. _(default: undefined)_\n- **--m3e-form-field-focused-outline-color** - Outline color when focused. _(default: undefined)_\n- **--m3e-form-field-focused-color** - Label color when focused. _(default: undefined)_\n- **--m3e-form-field-outline-color** - Outline color in outlined variant. _(default: undefined)_\n- **--m3e-form-field-container-color** - Background color in filled variant. _(default: undefined)_\n- **--m3e-form-field-hover-container-color** - Hover background color in filled variant. _(default: undefined)_\n- **--m3e-form-field-width** - Width of the form field container. _(default: undefined)_\n- **--m3e-form-field-icon-size** - Size of prefix and suffix icons. _(default: undefined)_\n- **--m3e-outlined-form-field-container-shape** - Corner radius for outlined container. _(default: undefined)_\n- **--m3e-form-field-container-shape** - Corner radius for filled container. _(default: undefined)_\n- **--m3e-form-field-hover-container-opacity** - Opacity for hover background in filled variant. _(default: undefined)_\n- **--m3e-form-field-disabled-opacity** - Opacity for disabled text. _(default: undefined)_\n- **--m3e-form-field-disabled-container-opacity** - Opacity for disabled container background. _(default: undefined)_",
8
8
  "attributes": [
9
9
  {
10
10
  "name": "float-label",
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2025 matraic
4
4
  * See LICENSE file in the project root for full license text.
5
5
  */
6
- import { LitElement, nothing, html, unsafeCSS, css } from 'lit';
6
+ import { LitElement, nothing, html, css, unsafeCSS } from 'lit';
7
7
  import { AttachInternals, MutationController, ResizeController, FocusController, HoverController, PressedController, isReadOnlyMixin, DesignToken, hasAssignedNodes, getTextContent } from '@m3e/core';
8
8
  import { M3eAriaDescriber } from '@m3e/core/a11y';
9
9
 
@@ -299,7 +299,7 @@ let M3eFormFieldElement = class M3eFormFieldElement extends AttachInternals(LitE
299
299
  }
300
300
  /**
301
301
  * Notifies the form field that the state of the hosted `control` has changed.
302
- * @param [checkValidity=false] Whether to check validity.
302
+ * @param {boolean} [checkValidity=false] Whether to check validity.
303
303
  */
304
304
  notifyControlStateChange(checkValidity = false) {
305
305
  this._required = __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f")?.required === true;
@@ -506,6 +506,29 @@ _M3eFormFieldElement_handleErrorChange = function _M3eFormFieldElement_handleErr
506
506
  M3eAriaDescriber.describe(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f"), __classPrivateFieldGet(this, _M3eFormFieldElement_errorText, "f"));
507
507
  }
508
508
  };
509
+ (() => {
510
+ const lightDomStyle = new CSSStyleSheet();
511
+ lightDomStyle.replaceSync(css `
512
+ m3e-form-field input::placeholder,
513
+ m3e-form-field textarea::placeholder {
514
+ user-select: none;
515
+ color: currentColor;
516
+ transition: opacity ${DesignToken.motion.duration.extraLong1};
517
+ }
518
+ m3e-form-field[float-label="auto"]:not(.-float-label).-with-label input::placeholder,
519
+ m3e-form-field[float-label="auto"]:not(.-float-label).-with-label textarea::placeholder {
520
+ opacity: 0;
521
+ transition: opacity 0s;
522
+ }
523
+ @media (prefers-reduced-motion) {
524
+ m3e-form-field input::placeholder,
525
+ m3e-form-field textarea::placeholder {
526
+ transition: none !important;
527
+ }
528
+ }
529
+ `.toString());
530
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, lightDomStyle];
531
+ })();
509
532
  /** The styles of the element. */
510
533
  M3eFormFieldElement.styles = css `
511
534
  :host {
@@ -581,7 +604,7 @@ M3eFormFieldElement.styles = css `
581
604
  line-height ${DesignToken.motion.duration.short4}`)};
582
605
  }
583
606
  :host(.-with-select) .label {
584
- margin-right: 1.5rem;
607
+ margin-inline-end: 1.5rem;
585
608
  }
586
609
  ::slotted([slot="label"]) {
587
610
  white-space: nowrap;
@@ -654,41 +677,27 @@ M3eFormFieldElement.styles = css `
654
677
  :host([variant="outlined"]) ::slotted(m3e-input-chip-set) {
655
678
  margin-block: calc(calc(3.5rem + ${DesignToken.density.calc(-2)}) / 4);
656
679
  }
657
- ::slotted(:not([slot])::part(focus-ring)) {
658
- display: none;
659
- }
660
- ::slotted(input)::placeholder,
661
- ::slotted(textarea)::placeholder {
662
- user-select: none;
663
- color: currentColor;
664
- transition: opacity ${DesignToken.motion.duration.extraLong1};
665
- }
666
680
  :host([float-label="auto"]:not(.-float-label):not(.-pressed)) .label {
667
681
  font-size: inherit;
668
682
  }
669
- :host([float-label="auto"]:not(.-float-label).-with-label) ::slotted(input)::placeholder,
670
- :host([float-label="auto"]:not(.-float-label).-with-label) ::slotted(textarea)::placeholder,
683
+
671
684
  :host([float-label="auto"]:not(.-float-label).-with-label) .prefix-text,
672
685
  :host([float-label="auto"]:not(.-float-label).-with-label) .suffix-text {
673
686
  opacity: 0;
674
687
  transition: opacity 0s;
675
688
  }
676
689
  .prefix {
677
- margin-left: 1rem;
690
+ margin-inline-start: 1rem;
678
691
  }
679
692
  :host(.-with-prefix) .prefix {
680
- margin-right: 1rem;
681
- margin-left: 0.75rem;
682
- }
683
- .suffix {
684
- margin-right: 1rem;
693
+ margin-inline-end: 1rem;
694
+ margin-inline-start: 0.75rem;
685
695
  }
686
696
  :host(.-with-suffix) .suffix {
687
- margin-left: 1rem;
688
- margin-right: 0.75rem;
697
+ margin-inline-start: 0.25rem;
689
698
  }
690
699
  :host(.-with-suffix.-with-select) .suffix {
691
- margin-left: unset;
700
+ margin-inline-start: unset;
692
701
  }
693
702
  :host(.-with-select) .suffix-text {
694
703
  display: none;
@@ -707,17 +716,17 @@ M3eFormFieldElement.styles = css `
707
716
  }
708
717
  :host([variant="outlined"]) .pseudo-label {
709
718
  visibility: hidden;
710
- margin-right: 0.25rem;
719
+ margin-inline-end: 0.25rem;
711
720
  font-size: var(--_form-field-label-font-size);
712
721
  line-height: var(--_form-field-label-line-height);
713
722
  letter-spacing: var(--_form-field-label-tracking);
714
723
  max-width: 100%;
715
- transition-property: max-width, margin-right;
724
+ transition-property: max-width, margin-inline-end;
716
725
  transition-duration: 1ms;
717
726
  }
718
727
  :host([variant="outlined"][float-label="auto"]:not(.-float-label):not(.-pressed)) .pseudo-label {
719
728
  max-width: 0;
720
- margin-right: 0px;
729
+ margin-inline-end: 0px;
721
730
  transition-delay: ${DesignToken.motion.duration.short2};
722
731
  }
723
732
  :host([variant="outlined"]) .outline-start,
@@ -731,9 +740,6 @@ M3eFormFieldElement.styles = css `
731
740
  :host([variant="outlined"]:not(.-with-label)) .outline-notch {
732
741
  display: none;
733
742
  }
734
- :host([variant="outlined"].-with-suffix:not(.-with-select)) .outline-notch {
735
- margin-right: -0.75rem;
736
- }
737
743
  :host([variant="outlined"]) .outline-start {
738
744
  min-width: 0.75rem;
739
745
  border-top-style: solid;
@@ -917,9 +923,7 @@ M3eFormFieldElement.styles = css `
917
923
  .outline-start,
918
924
  .outline-notch,
919
925
  .outline-end,
920
- .pseudo-label,
921
- ::slotted(input)::placeholder,
922
- ::slotted(textarea)::placeholder {
926
+ .pseudo-label {
923
927
  transition: none !important;
924
928
  }
925
929
  }