@m3e/form-field 1.0.0-rc.1 → 1.0.0-rc.3

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.
@@ -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,8 +3,8 @@
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';
7
- import { AttachInternals, Role, MutationController, ResizeController, FocusController, HoverController, PressedController, isReadOnlyMixin, DesignToken, hasAssignedNodes, getTextContent } from '@m3e/core';
6
+ import { LitElement, nothing, html, css, unsafeCSS } from 'lit';
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
 
10
10
  /**
@@ -145,7 +145,6 @@ const e$1=(e,t,c)=>(c.configurable=true,c.enumerable=true,Reflect.decorate&&"obj
145
145
  */
146
146
  var _M3eFormFieldElement_instances, _M3eFormFieldElement_control, _M3eFormFieldElement_formResetHandler, _M3eFormFieldElement_controlInvalidHandler, _M3eFormFieldElement_controlMutationController, _M3eFormFieldElement_resizeController, _M3eFormFieldElement_focusController, _M3eFormFieldElement_hintMutationController, _M3eFormFieldElement_errorMutationController, _M3eFormFieldElement_focused, _M3eFormFieldElement_hintText, _M3eFormFieldElement_errorText, _M3eFormFieldElement_shouldFloatLabel_get, _M3eFormFieldElement_stopPropagation, _M3eFormFieldElement_handleLabelSlotChange, _M3eFormFieldElement_handlePrefixSlotChange, _M3eFormFieldElement_handleSuffixSlotChange, _M3eFormFieldElement_handlePrefixResize, _M3eFormFieldElement_handleSlotChange, _M3eFormFieldElement_handleContainerClick, _M3eFormFieldElement_handleControlInvalid, _M3eFormFieldElement_handleControlChange, _M3eFormFieldElement_handleFormReset, _M3eFormFieldElement_changeControl, _M3eFormFieldElement_handleHintChange, _M3eFormFieldElement_handleErrorChange;
147
147
  /**
148
- * @summary
149
148
  * A container for form controls that applies Material Design styling and behavior.
150
149
  *
151
150
  * @description
@@ -216,7 +215,7 @@ var _M3eFormFieldElement_instances, _M3eFormFieldElement_control, _M3eFormFieldE
216
215
  * @cssprop --m3e-form-field-disabled-opacity - Opacity for disabled text.
217
216
  * @cssprop --m3e-form-field-disabled-container-opacity - Opacity for disabled container background.
218
217
  */
219
- let M3eFormFieldElement = class M3eFormFieldElement extends AttachInternals(Role(LitElement, "none")) {
218
+ let M3eFormFieldElement = class M3eFormFieldElement extends AttachInternals(LitElement) {
220
219
  constructor() {
221
220
  super();
222
221
  _M3eFormFieldElement_instances.add(this);
@@ -300,7 +299,7 @@ let M3eFormFieldElement = class M3eFormFieldElement extends AttachInternals(Role
300
299
  }
301
300
  /**
302
301
  * Notifies the form field that the state of the hosted `control` has changed.
303
- * @param [checkValidity=false] Whether to check validity.
302
+ * @param {boolean} [checkValidity=false] Whether to check validity.
304
303
  */
305
304
  notifyControlStateChange(checkValidity = false) {
306
305
  this._required = __classPrivateFieldGet(this, _M3eFormFieldElement_control, "f")?.required === true;
@@ -507,6 +506,29 @@ _M3eFormFieldElement_handleErrorChange = function _M3eFormFieldElement_handleErr
507
506
  M3eAriaDescriber.describe(__classPrivateFieldGet(this, _M3eFormFieldElement_control, "f"), __classPrivateFieldGet(this, _M3eFormFieldElement_errorText, "f"));
508
507
  }
509
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
+ })();
510
532
  /** The styles of the element. */
511
533
  M3eFormFieldElement.styles = css `
512
534
  :host {
@@ -582,7 +604,7 @@ M3eFormFieldElement.styles = css `
582
604
  line-height ${DesignToken.motion.duration.short4}`)};
583
605
  }
584
606
  :host(.-with-select) .label {
585
- margin-right: 1.5rem;
607
+ margin-inline-end: 1.5rem;
586
608
  }
587
609
  ::slotted([slot="label"]) {
588
610
  white-space: nowrap;
@@ -655,41 +677,27 @@ M3eFormFieldElement.styles = css `
655
677
  :host([variant="outlined"]) ::slotted(m3e-input-chip-set) {
656
678
  margin-block: calc(calc(3.5rem + ${DesignToken.density.calc(-2)}) / 4);
657
679
  }
658
- ::slotted(:not([slot])::part(focus-ring)) {
659
- display: none;
660
- }
661
- ::slotted(input)::placeholder,
662
- ::slotted(textarea)::placeholder {
663
- user-select: none;
664
- color: currentColor;
665
- transition: opacity ${DesignToken.motion.duration.extraLong1};
666
- }
667
680
  :host([float-label="auto"]:not(.-float-label):not(.-pressed)) .label {
668
681
  font-size: inherit;
669
682
  }
670
- :host([float-label="auto"]:not(.-float-label).-with-label) ::slotted(input)::placeholder,
671
- :host([float-label="auto"]:not(.-float-label).-with-label) ::slotted(textarea)::placeholder,
683
+
672
684
  :host([float-label="auto"]:not(.-float-label).-with-label) .prefix-text,
673
685
  :host([float-label="auto"]:not(.-float-label).-with-label) .suffix-text {
674
686
  opacity: 0;
675
687
  transition: opacity 0s;
676
688
  }
677
689
  .prefix {
678
- margin-left: 1rem;
690
+ margin-inline-start: 1rem;
679
691
  }
680
692
  :host(.-with-prefix) .prefix {
681
- margin-right: 1rem;
682
- margin-left: 0.75rem;
683
- }
684
- .suffix {
685
- margin-right: 1rem;
693
+ margin-inline-end: 1rem;
694
+ margin-inline-start: 0.75rem;
686
695
  }
687
696
  :host(.-with-suffix) .suffix {
688
- margin-left: 1rem;
689
- margin-right: 0.75rem;
697
+ margin-inline-start: 0.25rem;
690
698
  }
691
699
  :host(.-with-suffix.-with-select) .suffix {
692
- margin-left: unset;
700
+ margin-inline-start: unset;
693
701
  }
694
702
  :host(.-with-select) .suffix-text {
695
703
  display: none;
@@ -708,17 +716,17 @@ M3eFormFieldElement.styles = css `
708
716
  }
709
717
  :host([variant="outlined"]) .pseudo-label {
710
718
  visibility: hidden;
711
- margin-right: 0.25rem;
719
+ margin-inline-end: 0.25rem;
712
720
  font-size: var(--_form-field-label-font-size);
713
721
  line-height: var(--_form-field-label-line-height);
714
722
  letter-spacing: var(--_form-field-label-tracking);
715
723
  max-width: 100%;
716
- transition-property: max-width, margin-right;
724
+ transition-property: max-width, margin-inline-end;
717
725
  transition-duration: 1ms;
718
726
  }
719
727
  :host([variant="outlined"][float-label="auto"]:not(.-float-label):not(.-pressed)) .pseudo-label {
720
728
  max-width: 0;
721
- margin-right: 0px;
729
+ margin-inline-end: 0px;
722
730
  transition-delay: ${DesignToken.motion.duration.short2};
723
731
  }
724
732
  :host([variant="outlined"]) .outline-start,
@@ -732,9 +740,6 @@ M3eFormFieldElement.styles = css `
732
740
  :host([variant="outlined"]:not(.-with-label)) .outline-notch {
733
741
  display: none;
734
742
  }
735
- :host([variant="outlined"].-with-suffix:not(.-with-select)) .outline-notch {
736
- margin-right: -0.75rem;
737
- }
738
743
  :host([variant="outlined"]) .outline-start {
739
744
  min-width: 0.75rem;
740
745
  border-top-style: solid;
@@ -918,9 +923,7 @@ M3eFormFieldElement.styles = css `
918
923
  .outline-start,
919
924
  .outline-notch,
920
925
  .outline-end,
921
- .pseudo-label,
922
- ::slotted(input)::placeholder,
923
- ::slotted(textarea)::placeholder {
926
+ .pseudo-label {
924
927
  transition: none !important;
925
928
  }
926
929
  }