diff --git a/.changeset/quick-shoes-burn.md b/.changeset/quick-shoes-burn.md new file mode 100644 index 0000000000..6d892ca1d4 --- /dev/null +++ b/.changeset/quick-shoes-burn.md @@ -0,0 +1,5 @@ +--- +"@patternfly/pfe-core": patch +--- + +`InternalsController`: expose `form`, `validationMessage`, and `willValidate` getters. Previously returned `undefined` despite TypeScript accepting the access. Form-associated elements can read the associated form reference and validation state from the controller. diff --git a/.changeset/warm-birds-smile.md b/.changeset/warm-birds-smile.md new file mode 100644 index 0000000000..3fcc065460 --- /dev/null +++ b/.changeset/warm-birds-smile.md @@ -0,0 +1,29 @@ +--- +"@patternfly/elements": major +--- + +``: replaces `` with PatternFly v6 design specs. + +```html + + +``` + +**Breaking Changes from v5** + +- Renamed tag from `` to `` +- CSS custom properties renamed from `--pf-v5-c-form-control--*` to `--pf-v6-c-form-control--*` +- `left-truncated` attribute replaced by `truncated="start"` enum +- `icon` / `custom-icon-url` / `custom-icon-dimensions` attributes replaced by `icon` slot +- `validate-on` and `error-text` attributes removed + +**New features** + +- `referenceTarget` support for native cross-root label association +- `validated="error"` state with `aria-invalid` and `role="alert"` status message +- Constraint validation via `checkValidity()`, `reportValidity()`, `setCustomValidity()` +- `maxlength`, `minlength`, and `inputmode` attributes +- `select()` method +- `icon` slot for custom icon content +- Cancelable `change` event +- v6 design tokens and `light-dark()` support diff --git a/core/pfe-core/controllers/internals-controller.ts b/core/pfe-core/controllers/internals-controller.ts index 90eddcb560..fe5147c34f 100644 --- a/core/pfe-core/controllers/internals-controller.ts +++ b/core/pfe-core/controllers/internals-controller.ts @@ -74,13 +74,10 @@ type InternalsHost = ReactiveControllerHost & HTMLElement; export class InternalsController implements ReactiveController, ARIAMixin { private static instances = new WeakMap(); - declare readonly form: ElementInternals['form']; declare readonly shadowRoot: ElementInternals['shadowRoot']; // https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/states declare readonly states: unknown; - declare readonly willValidate: ElementInternals['willValidate']; - declare readonly validationMessage: ElementInternals['validationMessage']; public static getLabels(host: InternalsHost): Element[] { return Array.from(this.instances.get(host)?.internals.labels ?? []) as Element[]; @@ -232,6 +229,18 @@ export class InternalsController implements ReactiveController, ARIAMixin { return this.internals.validity; } + get form(): HTMLFormElement | null { + return this.internals.form; + } + + get validationMessage(): string { + return this.internals.validationMessage; + } + + get willValidate(): boolean { + return this.internals.willValidate; + } + /** A best-attempt based on observed behaviour in FireFox 115 on fedora 38 */ get computedLabelText(): string { return this.internals.ariaLabel diff --git a/docs/main.mjs b/docs/main.mjs index d56d42bf2d..c32e308ef8 100644 --- a/docs/main.mjs +++ b/docs/main.mjs @@ -24,7 +24,7 @@ import '@patternfly/elements/pf-v5-select/pf-v5-select.js'; import '@patternfly/elements/pf-v5-table/pf-v5-table.js'; import '@patternfly/elements/pf-v5-tabs/pf-v5-tabs.js'; import '@patternfly/elements/pf-v5-text-area/pf-v5-text-area.js'; -import '@patternfly/elements/pf-v5-text-input/pf-v5-text-input.js'; +import '@patternfly/elements/pf-v6-text-input/pf-v6-text-input.js'; import '@patternfly/elements/pf-v5-tile/pf-v5-tile.js'; import '@patternfly/elements/pf-v5-tooltip/pf-v5-tooltip.js'; diff --git a/elements/pf-v5-text-input/README.md b/elements/pf-v5-text-input/README.md deleted file mode 100644 index 4bc633db40..0000000000 --- a/elements/pf-v5-text-input/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Text Input -A **text input** is used to gather free-form text from a user. - -```html - -``` diff --git a/elements/pf-v5-text-input/demo/form-submission.html b/elements/pf-v5-text-input/demo/form-submission.html deleted file mode 100644 index de6ddf72a5..0000000000 --- a/elements/pf-v5-text-input/demo/form-submission.html +++ /dev/null @@ -1,24 +0,0 @@ -
- - -

Form status: unsubmitted

-
- - - - - - diff --git a/elements/pf-v5-text-input/demo/icon-variants.html b/elements/pf-v5-text-input/demo/icon-variants.html deleted file mode 100644 index 253c5cb328..0000000000 --- a/elements/pf-v5-text-input/demo/icon-variants.html +++ /dev/null @@ -1,23 +0,0 @@ -
- Icon variants - - - - - - - -
- - - - - diff --git a/elements/pf-v5-text-input/demo/index.html b/elements/pf-v5-text-input/demo/index.html deleted file mode 100644 index 206b1bfc17..0000000000 --- a/elements/pf-v5-text-input/demo/index.html +++ /dev/null @@ -1,12 +0,0 @@ -
- Text Input - - -
- - - - - diff --git a/elements/pf-v5-text-input/demo/invalid.html b/elements/pf-v5-text-input/demo/invalid.html deleted file mode 100644 index dc41b11b49..0000000000 --- a/elements/pf-v5-text-input/demo/invalid.html +++ /dev/null @@ -1,14 +0,0 @@ -
- Invalid - -
- - - - diff --git a/elements/pf-v5-text-input/demo/kitchen-sink.html b/elements/pf-v5-text-input/demo/kitchen-sink.html deleted file mode 100644 index 8e76175a32..0000000000 --- a/elements/pf-v5-text-input/demo/kitchen-sink.html +++ /dev/null @@ -1,81 +0,0 @@ -
- - -
- -
- Disabled - - -
- -
- Left Truncated - - -
- -
- Read only - - - -
- -
- Invalid - - -
- -
- Icon variants - - - - - - - -
- - - - - - diff --git a/elements/pf-v5-text-input/demo/left-truncated.html b/elements/pf-v5-text-input/demo/left-truncated.html deleted file mode 100644 index 0ca52a260e..0000000000 --- a/elements/pf-v5-text-input/demo/left-truncated.html +++ /dev/null @@ -1,11 +0,0 @@ -
- Left Truncated - -
- - - - diff --git a/elements/pf-v5-text-input/demo/read-only.html b/elements/pf-v5-text-input/demo/read-only.html deleted file mode 100644 index fdb42ce256..0000000000 --- a/elements/pf-v5-text-input/demo/read-only.html +++ /dev/null @@ -1,18 +0,0 @@ -
- Read only - - - -
- - - - diff --git a/elements/pf-v5-text-input/demo/status-icon-sprite.svg b/elements/pf-v5-text-input/demo/status-icon-sprite.svg deleted file mode 100644 index 8d69219a8a..0000000000 --- a/elements/pf-v5-text-input/demo/status-icon-sprite.svg +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/elements/pf-v5-text-input/demo/validation.html b/elements/pf-v5-text-input/demo/validation.html deleted file mode 100644 index a710e8ea87..0000000000 --- a/elements/pf-v5-text-input/demo/validation.html +++ /dev/null @@ -1,26 +0,0 @@ -
- Invalid - - - Validate -
- - - - diff --git a/elements/pf-v5-text-input/docs/pf-v5-text-input.md b/elements/pf-v5-text-input/docs/pf-v5-text-input.md deleted file mode 100644 index ce69fdc8a5..0000000000 --- a/elements/pf-v5-text-input/docs/pf-v5-text-input.md +++ /dev/null @@ -1,23 +0,0 @@ -{% renderOverview %} - -{% endrenderOverview %} - -{% band header="Usage" %} - ### Basic - {% htmlexample %} - - - {% endhtmlexample %} -{% endband %} - -{% renderSlots %}{% endrenderSlots %} - -{% renderAttributes %}{% endrenderAttributes %} - -{% renderMethods %}{% endrenderMethods %} - -{% renderEvents %}{% endrenderEvents %} - -{% renderCssCustomProperties %}{% endrenderCssCustomProperties %} - -{% renderCssParts %}{% endrenderCssParts %} diff --git a/elements/pf-v5-text-input/docs/screenshot.png b/elements/pf-v5-text-input/docs/screenshot.png deleted file mode 100644 index 52afb9bfed..0000000000 Binary files a/elements/pf-v5-text-input/docs/screenshot.png and /dev/null differ diff --git a/elements/pf-v5-text-input/pf-v5-text-input.css b/elements/pf-v5-text-input/pf-v5-text-input.css deleted file mode 100644 index ca74047b38..0000000000 --- a/elements/pf-v5-text-input/pf-v5-text-input.css +++ /dev/null @@ -1,393 +0,0 @@ -:host { - /** Form control text color */ - --pf-v5-c-form-control--Color: var(--pf-global--Color--100, #151515); - /** Form control font size */ - --pf-v5-c-form-control--FontSize: var(--pf-global--FontSize--md, 1rem); - /** Form control line height */ - --pf-v5-c-form-control--LineHeight: var(--pf-global--LineHeight--md, 1.5); - /** Form control border width */ - --pf-v5-c-form-control--BorderWidth: var(--pf-global--BorderWidth--sm, 1px); - /** Form control top border color */ - --pf-v5-c-form-control--BorderTopColor: var(--pf-global--BorderColor--300, #f0f0f0); - /** Form control right border color */ - --pf-v5-c-form-control--BorderRightColor: var(--pf-global--BorderColor--300, #f0f0f0); - /** Form control bottom border color */ - --pf-v5-c-form-control--BorderBottomColor: var(--pf-global--BorderColor--200, #8a8d90); - /** Form control left border color */ - --pf-v5-c-form-control--BorderLeftColor: var(--pf-global--BorderColor--300, #f0f0f0); - /** Form control border radius */ - --pf-v5-c-form-control--BorderRadius: 0; - /** Form control background color */ - --pf-v5-c-form-control--BackgroundColor: var(--pf-global--BackgroundColor--100, #fff); - /** Form control width */ - --pf-v5-c-form-control--Width: 100%; - /** Form control height */ - --pf-v5-c-form-control--Height: calc(var(--pf-v5-c-form-control--FontSize) * var(--pf-v5-c-form-control--LineHeight) + var(--pf-v5-c-form-control--BorderWidth) * 2 + var(--pf-v5-c-form-control--PaddingTop) + var(--pf-v5-c-form-control--PaddingBottom)); - /** Form control base inset */ - --pf-v5-c-form-control--inset--base: var(--pf-global--spacer--sm, 0.5rem); - /** Form control top padding */ - --pf-v5-c-form-control--PaddingTop: calc(var(--pf-global--spacer--form-element, 0.375rem) - var(--pf-global--BorderWidth--sm, 1px)); - /** Form control bottom padding */ - --pf-v5-c-form-control--PaddingBottom: calc(var(--pf-global--spacer--form-element, 0.375rem) - var(--pf-global--BorderWidth--sm, 1px)); - /** Form control right padding */ - --pf-v5-c-form-control--PaddingRight: var(--pf-v5-c-form-control--inset--base); - /** Form control left padding */ - --pf-v5-c-form-control--PaddingLeft: var(--pf-v5-c-form-control--inset--base); - /** Form control hover bottom border color */ - --pf-v5-c-form-control--hover--BorderBottomColor: var(--pf-global--primary-color--100, #06c); - /** Form control focus bottom border width */ - --pf-v5-c-form-control--focus--BorderBottomWidth: var(--pf-global--BorderWidth--md, 2px); - /** Form control focus bottom padding */ - --pf-v5-c-form-control--focus--PaddingBottom: calc(var(--pf-global--spacer--form-element, 0.375rem) - var(--pf-v5-c-form-control--focus--BorderBottomWidth)); - /** Form control focus bottom border color */ - --pf-v5-c-form-control--focus--BorderBottomColor: var(--pf-global--primary-color--100, #06c); - /** Form control expanded bottom border width */ - --pf-v5-c-form-control--m-expanded--BorderBottomWidth: var(--pf-global--BorderWidth--md, 2px); - /** Form control expanded bottom padding */ - --pf-v5-c-form-control--m-expanded--PaddingBottom: calc(var(--pf-global--spacer--form-element, 0.375rem) - var(--pf-v5-c-form-control--focus--BorderBottomWidth)); - /** Form control expanded bottom border color */ - --pf-v5-c-form-control--m-expanded--BorderBottomColor: var(--pf-global--primary-color--100, #06c); - /** Form control placeholder color */ - --pf-v5-c-form-control--placeholder--Color: var(--pf-global--Color--dark-200, #6a6e73); - /** Form control placeholder child color */ - --pf-v5-c-form-control--placeholder--child--Color: var(--pf-global--Color--100, #151515); - /** Form control disabled color */ - --pf-v5-c-form-control--disabled--Color: var(--pf-global--disabled-color--100, #6a6e73); - /** Form control disabled background color */ - --pf-v5-c-form-control--disabled--BackgroundColor: var(--pf-global--disabled-color--300, #f0f0f0); - /** Form control disabled border color */ - --pf-v5-c-form-control--disabled--BorderColor: transparent; - /** Form control readonly background color */ - --pf-v5-c-form-control--readonly--BackgroundColor: var(--pf-global--disabled-color--300, #f0f0f0); - /** Form control readonly hover bottom border color */ - --pf-v5-c-form-control--readonly--hover--BorderBottomColor: var(--pf-global--BorderColor--200, #8a8d90); - /** Form control readonly focus bottom padding */ - --pf-v5-c-form-control--readonly--focus--PaddingBottom: calc(var(--pf-global--spacer--form-element, 0.375rem) - var(--pf-global--BorderWidth--sm, 1px)); - /** Form control readonly focus bottom border width */ - --pf-v5-c-form-control--readonly--focus--BorderBottomWidth: var(--pf-global--BorderWidth--sm, 1px); - /** Form control readonly focus bottom border color */ - --pf-v5-c-form-control--readonly--focus--BorderBottomColor: var(--pf-global--BorderColor--200, #8a8d90); - /** Form control readonly plain background color */ - --pf-v5-c-form-control--readonly--m-plain--BackgroundColor: transparent; - /** Form control readonly plain base inset */ - --pf-v5-c-form-control--readonly--m-plain--inset--base: 0; - /** Form control success bottom border width */ - --pf-v5-c-form-control--success--BorderBottomWidth: var(--pf-global--BorderWidth--md, 2px); - /** Form control success bottom padding */ - --pf-v5-c-form-control--success--PaddingBottom: calc(var(--pf-global--spacer--form-element, 0.375rem) - var(--pf-v5-c-form-control--success--BorderBottomWidth)); - /** Form control success bottom border color */ - --pf-v5-c-form-control--success--BorderBottomColor: var(--pf-global--success-color--100, #3e8635); - /** Form control success right padding */ - --pf-v5-c-form-control--success--PaddingRight: var(--pf-global--spacer--xl, 2rem); - /** Form control success background X position */ - --pf-v5-c-form-control--success--BackgroundPositionX: calc(100% - var(--pf-v5-c-form-control--PaddingLeft)); - /** Form control success background Y position */ - --pf-v5-c-form-control--success--BackgroundPositionY: center; - /** Form control success background position */ - --pf-v5-c-form-control--success--BackgroundPosition: var(--pf-v5-c-form-control--success--BackgroundPositionX) var(--pf-v5-c-form-control--success--BackgroundPositionY); - /** Form control success background X size */ - --pf-v5-c-form-control--success--BackgroundSizeX: var(--pf-v5-c-form-control--FontSize); - /** Form control success background Y size */ - --pf-v5-c-form-control--success--BackgroundSizeY: var(--pf-v5-c-form-control--FontSize); - /** Form control success background size */ - --pf-v5-c-form-control--success--BackgroundSize: var(--pf-v5-c-form-control--success--BackgroundSizeX) var(--pf-v5-c-form-control--success--BackgroundSizeY); - /** Form control success background URL */ - --pf-v5-c-form-control--success--BackgroundUrl: url('data:image/svg+xml;charset=utf8,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"%3E%3Cpath fill="%235ba352" d="M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z"/%3E%3C/svg%3E'); - /** Form control warning bottom border width */ - --pf-v5-c-form-control--m-warning--BorderBottomWidth: var(--pf-global--BorderWidth--md, 2px); - /** Form control warning bottom padding */ - --pf-v5-c-form-control--m-warning--PaddingBottom: calc(var(--pf-global--spacer--form-element, 0.375rem) - var(--pf-v5-c-form-control--m-warning--BorderBottomWidth)); - /** Form control warning bottom border color */ - --pf-v5-c-form-control--m-warning--BorderBottomColor: var(--pf-global--warning-color--100, #f0ab00); - /** Form control warning right padding */ - --pf-v5-c-form-control--m-warning--PaddingRight: var(--pf-global--spacer--xl, 2rem); - /** Form control warning background X position */ - --pf-v5-c-form-control--m-warning--BackgroundPositionX: calc(100% - calc(var(--pf-v5-c-form-control--PaddingLeft) - 0.0625rem)); - /** Form control warning background Y position */ - --pf-v5-c-form-control--m-warning--BackgroundPositionY: center; - /** Form control warning background position */ - --pf-v5-c-form-control--m-warning--BackgroundPosition: var(--pf-v5-c-form-control--m-warning--BackgroundPositionX) var(--pf-v5-c-form-control--m-warning--BackgroundPositionY); - /** Form control warning background X size */ - --pf-v5-c-form-control--m-warning--BackgroundSizeX: 1.25rem; - /** Form control warning background Y size */ - --pf-v5-c-form-control--m-warning--BackgroundSizeY: var(--pf-v5-c-form-control--FontSize); - /** Form control warning background size */ - --pf-v5-c-form-control--m-warning--BackgroundSize: var(--pf-v5-c-form-control--m-warning--BackgroundSizeX) var(--pf-v5-c-form-control--m-warning--BackgroundSizeY); - /** Form control warning background URL */ - --pf-v5-c-form-control--m-warning--BackgroundUrl: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='%23f0ab00' d='M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z'/%3E%3C/svg%3E"); - /** Form control invalid bottom border width */ - --pf-v5-c-form-control--invalid--BorderBottomWidth: var(--pf-global--BorderWidth--md, 2px); - /** Form control invalid bottom padding */ - --pf-v5-c-form-control--invalid--PaddingBottom: calc(var(--pf-global--spacer--form-element, 0.375rem) - var(--pf-v5-c-form-control--invalid--BorderBottomWidth)); - /** Form control invalid bottom border color */ - --pf-v5-c-form-control--invalid--BorderBottomColor: var(--pf-global--danger-color--100, #c9190b); - /** Form control invalid right padding */ - --pf-v5-c-form-control--invalid--PaddingRight: var(--pf-global--spacer--xl, 2rem); - /** Form control invalid background X position */ - --pf-v5-c-form-control--invalid--BackgroundPositionX: calc(100% - var(--pf-v5-c-form-control--PaddingLeft)); - /** Form control invalid background Y position */ - --pf-v5-c-form-control--invalid--BackgroundPositionY: center; - /** Form control invalid background position */ - --pf-v5-c-form-control--invalid--BackgroundPosition: var(--pf-v5-c-form-control--invalid--BackgroundPositionX) var(--pf-v5-c-form-control--invalid--BackgroundPositionY); - /** Form control invalid background X size */ - --pf-v5-c-form-control--invalid--BackgroundSizeX: var(--pf-v5-c-form-control--FontSize); - /** Form control invalid background Y size */ - --pf-v5-c-form-control--invalid--BackgroundSizeY: var(--pf-v5-c-form-control--FontSize); - /** Form control invalid background size */ - --pf-v5-c-form-control--invalid--BackgroundSize: var(--pf-v5-c-form-control--invalid--BackgroundSizeX) var(--pf-v5-c-form-control--invalid--BackgroundSizeY); - /** Form control invalid background URL */ - --pf-v5-c-form-control--invalid--BackgroundUrl: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='%23fe5142' d='M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z'/%3E%3C/svg%3E"); - /** Form control invalid exclamation background */ - --pf-v5-c-form-control--invalid--exclamation--Background: var(--pf-v5-c-form-control--invalid--BackgroundUrl) var(--pf-v5-c-form-control--invalid--BackgroundPosition) / var(--pf-v5-c-form-control--invalid--BackgroundSize) no-repeat; - /** Form control invalid background */ - --pf-v5-c-form-control--invalid--Background: var(--pf-v5-c-form-control--BackgroundColor) var(--pf-v5-c-form-control--invalid--exclamation--Background); - /** Form control search left padding */ - --pf-v5-c-form-control--m-search--PaddingLeft: var(--pf-global--spacer--xl, 2rem); - /** Form control search background position */ - --pf-v5-c-form-control--m-search--BackgroundPosition: var(--pf-v5-c-form-control--PaddingRight); - /** Form control search background size */ - --pf-v5-c-form-control--m-search--BackgroundSize: var(--pf-v5-c-form-control--FontSize) var(--pf-v5-c-form-control--FontSize); - /** Form control search background URL */ - --pf-v5-c-form-control--m-search--BackgroundUrl: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='%23aaabac' d='M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z'/%3E%3C/svg%3E"); - /** Form control icon right padding */ - --pf-v5-c-form-control--m-icon--PaddingRight: calc(var(--pf-v5-c-form-control--inset--base) + var(--pf-v5-c-form-control--m-icon--BackgroundSizeX) + var(--pf-v5-c-form-control--m-icon--icon--spacer)); - /** Form control icon background URL */ - --pf-v5-c-form-control--m-icon--BackgroundUrl: none; - /** Form control icon background X position */ - --pf-v5-c-form-control--m-icon--BackgroundPositionX: calc(100% - var(--pf-v5-c-form-control--inset--base)); - /** Form control icon background Y position */ - --pf-v5-c-form-control--m-icon--BackgroundPositionY: center; - /** Form control icon background X size */ - --pf-v5-c-form-control--m-icon--BackgroundSizeX: var(--pf-v5-c-form-control--FontSize); - /** Form control icon background Y size */ - --pf-v5-c-form-control--m-icon--BackgroundSizeY: var(--pf-v5-c-form-control--FontSize); - /** Form control icon spacer */ - --pf-v5-c-form-control--m-icon--icon--spacer: var(--pf-global--spacer--sm, 0.5rem); - /** Form control icon right padding with validation */ - --pf-v5-c-form-control--m-icon--icon--PaddingRight: calc(var(--pf-v5-c-form-control--inset--base) + var(--pf-v5-c-form-control--invalid--BackgroundSizeX) + var(--pf-v5-c-form-control--m-icon--icon--spacer) + var(--pf-v5-c-form-control--m-icon--BackgroundSizeX) + var(--pf-v5-c-form-control--m-icon--icon--spacer)); - /** Form control icon background X position with validation */ - --pf-v5-c-form-control--m-icon--icon--BackgroundPositionX: calc(var(--pf-v5-c-form-control--m-icon--BackgroundPositionX) - var(--pf-v5-c-form-control--m-icon--icon--spacer) - var(--pf-v5-c-form-control--invalid--BackgroundSizeX)); - /** Form control icon invalid background URL */ - --pf-v5-c-form-control--m-icon--invalid--BackgroundUrl: var(--pf-v5-c-form-control--invalid--BackgroundUrl), var(--pf-v5-c-form-control--m-icon--BackgroundUrl); - /** Form control icon invalid background position */ - --pf-v5-c-form-control--m-icon--invalid--BackgroundPosition: var(--pf-v5-c-form-control--invalid--BackgroundPosition), var(--pf-v5-c-form-control--m-icon--icon--BackgroundPositionX) var(--pf-v5-c-form-control--m-icon--BackgroundPositionY); - /** Form control icon invalid background size */ - --pf-v5-c-form-control--m-icon--invalid--BackgroundSize: var(--pf-v5-c-form-control--invalid--BackgroundSize), var(--pf-v5-c-form-control--m-icon--BackgroundSizeX) var(--pf-v5-c-form-control--m-icon--BackgroundSizeY); - /** Form control icon success background URL */ - --pf-v5-c-form-control--m-icon--success--BackgroundUrl: var(--pf-v5-c-form-control--success--BackgroundUrl), var(--pf-v5-c-form-control--m-icon--BackgroundUrl); - /** Form control icon success background position */ - --pf-v5-c-form-control--m-icon--success--BackgroundPosition: var(--pf-v5-c-form-control--success--BackgroundPosition), var(--pf-v5-c-form-control--m-icon--icon--BackgroundPositionX) var(--pf-v5-c-form-control--m-icon--BackgroundPositionY); - /** Form control icon success background size */ - --pf-v5-c-form-control--m-icon--success--BackgroundSize: var(--pf-v5-c-form-control--success--BackgroundSize), var(--pf-v5-c-form-control--m-icon--BackgroundSizeX) var(--pf-v5-c-form-control--m-icon--BackgroundSizeY); - /** Form control icon warning background URL */ - --pf-v5-c-form-control--m-icon--m-warning--BackgroundUrl: var(--pf-v5-c-form-control--m-warning--BackgroundUrl), var(--pf-v5-c-form-control--m-icon--BackgroundUrl); - /** Form control icon warning background position */ - --pf-v5-c-form-control--m-icon--m-warning--BackgroundPosition: var(--pf-v5-c-form-control--m-warning--BackgroundPosition), var(--pf-v5-c-form-control--m-icon--icon--BackgroundPositionX) var(--pf-v5-c-form-control--m-icon--BackgroundPositionY); - /** Form control icon warning background size */ - --pf-v5-c-form-control--m-icon--m-warning--BackgroundSize: var(--pf-v5-c-form-control--m-warning--BackgroundSize), var(--pf-v5-c-form-control--m-icon--BackgroundSizeX) var(--pf-v5-c-form-control--m-icon--BackgroundSizeY); - /** Form control calendar background URL */ - --pf-v5-c-form-control--m-calendar--BackgroundUrl: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='%23aaabac' d='M0 464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V192H0v272zm320-196c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zm0 128c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zM192 268c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zm0 128c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zM64 268c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H76c-6.6 0-12-5.4-12-12v-40zm0 128c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H76c-6.6 0-12-5.4-12-12v-40zM400 64h-48V16c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v48H160V16c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v48H48C21.5 64 0 85.5 0 112v48h448v-48c0-26.5-21.5-48-48-48z'/%3E%3C/svg%3E"); - /** Form control clock background URL */ - --pf-v5-c-form-control--m-clock--BackgroundUrl: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='%23aaabac' d='M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200zm61.8-104.4l-84.9-61.7c-3.1-2.3-4.9-5.9-4.9-9.7V116c0-6.6 5.4-12 12-12h32c6.6 0 12 5.4 12 12v141.7l66.8 48.6c5.4 3.9 6.5 11.4 2.6 16.8L334.6 349c-3.9 5.3-11.4 6.5-16.8 2.6z'/%3E%3C/svg%3E"); - /** Select right padding */ - --pf-v5-c-form-control__select--PaddingRight: calc(var(--pf-global--spacer--lg, 1.5rem) + var(--pf-v5-c-form-control--BorderWidth) + var(--pf-v5-c-form-control--BorderWidth)); - /** Select left padding */ - --pf-v5-c-form-control__select--PaddingLeft: calc(var(--pf-global--spacer--sm, 0.5rem) - var(--pf-v5-c-form-control--BorderWidth)); - /** Select background URL */ - --pf-v5-c-form-control__select--BackgroundUrl: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 512'%3E%3Cpath fill='%23urrentColor' d='M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z'/%3E%3C/svg%3E"); - /** Select background size */ - --pf-v5-c-form-control__select--BackgroundSize: .625em; - /** Select background X position */ - --pf-v5-c-form-control__select--BackgroundPositionX: calc(100% - var(--pf-global--spacer--md, 1rem) + 1px); - /** Select background Y position */ - --pf-v5-c-form-control__select--BackgroundPositionY: center; - /** Select background position */ - --pf-v5-c-form-control__select--BackgroundPosition: var(--pf-v5-c-form-control__select--BackgroundPositionX) var(--pf-v5-c-form-control__select--BackgroundPositionY); - /** Select success right padding */ - --pf-v5-c-form-control__select--success--PaddingRight: var(--pf-global--spacer--3xl, 4rem); - /** Select success background position */ - --pf-v5-c-form-control__select--success--BackgroundPosition: calc(var(--pf-v5-c-form-control__select--BackgroundPositionX) - var(--pf-global--spacer--lg, 1.5rem)); - /** Select warning right padding */ - --pf-v5-c-form-control__select--m-warning--PaddingRight: var(--pf-global--spacer--3xl, 4rem); - /** Select warning background position */ - --pf-v5-c-form-control__select--m-warning--BackgroundPosition: calc(var(--pf-v5-c-form-control__select--BackgroundPositionX) - var(--pf-global--spacer--lg, 1.5rem) + 0.0625rem); - /** Select invalid right padding */ - --pf-v5-c-form-control__select--invalid--PaddingRight: var(--pf-global--spacer--3xl, 4rem); - /** Select invalid background position */ - --pf-v5-c-form-control__select--invalid--BackgroundPosition: calc(var(--pf-v5-c-form-control__select--BackgroundPositionX) - var(--pf-global--spacer--lg, 1.5rem)); - /** Textarea width */ - --pf-v5-c-form-control--textarea--Width: var(--pf-v5-c-form-control--Width); - /** Textarea height */ - --pf-v5-c-form-control--textarea--Height: auto; - /** Textarea success background Y position */ - --pf-v5-c-form-control--textarea--success--BackgroundPositionY: var(--pf-v5-c-form-control--PaddingLeft); - /** Textarea warning background Y position */ - --pf-v5-c-form-control--textarea--m-warning--BackgroundPositionY: var(--pf-v5-c-form-control--PaddingLeft); - /** Textarea invalid background Y position */ - --pf-v5-c-form-control--textarea--invalid--BackgroundPositionY: var(--pf-v5-c-form-control--PaddingLeft); - /** Icon sprite success background URL */ - --pf-v5-c-form-control--m-icon-sprite--success--BackgroundUrl: url(/v4/images/status-icon-sprite.4fee9fefc3971799d2dd4de0a15617f0.svg#success); - /** Icon sprite warning background URL */ - --pf-v5-c-form-control--m-icon-sprite--m-warning--BackgroundUrl: url(/v4/images/status-icon-sprite.4fee9fefc3971799d2dd4de0a15617f0.svg#warning); - /** Icon sprite invalid background URL */ - --pf-v5-c-form-control--m-icon-sprite--invalid--BackgroundUrl: url(/v4/images/status-icon-sprite.4fee9fefc3971799d2dd4de0a15617f0.svg#invalid); - /** Icon sprite select background URL */ - --pf-v5-c-form-control--m-icon-sprite__select--BackgroundUrl: url(/v4/images/status-icon-sprite.4fee9fefc3971799d2dd4de0a15617f0.svg#select); - /** Icon sprite search background URL */ - --pf-v5-c-form-control--m-icon-sprite--m-search--BackgroundUrl: url(/v4/images/status-icon-sprite.4fee9fefc3971799d2dd4de0a15617f0.svg#search); - /** Icon sprite calendar background URL */ - --pf-v5-c-form-control--m-icon-sprite--m-calendar--BackgroundUrl: url(/v4/images/status-icon-sprite.4fee9fefc3971799d2dd4de0a15617f0.svg#calendar); - /** Icon sprite clock background URL */ - --pf-v5-c-form-control--m-icon-sprite--m-clock--BackgroundUrl: url(/v4/images/status-icon-sprite.4fee9fefc3971799d2dd4de0a15617f0.svg#clock); - /** Icon sprite select background size */ - --pf-v5-c-form-control--m-icon-sprite__select--BackgroundSize: var(--pf-v5-c-form-control--FontSize); - /** Icon sprite select background X position */ - --pf-v5-c-form-control--m-icon-sprite__select--BackgroundPositionX: calc(100% - var(--pf-global--spacer--md, 1rem) + 7px); - /** Icon sprite select success background position */ - --pf-v5-c-form-control--m-icon-sprite__select--success--BackgroundPosition: calc(100% - var(--pf-global--spacer--md, 1rem) + 1px - var(--pf-global--spacer--lg, 1.5rem)); - /** Icon sprite select warning background position */ - --pf-v5-c-form-control--m-icon-sprite__select--m-warning--BackgroundPosition: calc(100% - var(--pf-global--spacer--md, 1rem) - var(--pf-global--spacer--lg, 1.5rem) + 0.0625rem); - /** Icon sprite select invalid background position */ - --pf-v5-c-form-control--m-icon-sprite__select--invalid--BackgroundPosition: calc(100% - var(--pf-global--spacer--md, 1rem) - var(--pf-global--spacer--lg, 1.5rem)); - /* NB: this var doesn't exist in pf react */ - /** Error text status color */ - --pf-v5-c-form-control__error-text--m-status--Color: var(--pf-global--danger-color--100, #c9190b); - - display: inline-block; - /* adjust the host to fit the input */ - max-width: calc(100% - var(--pf-v5-c-form-control--PaddingRight) - var(--pf-v5-c-form-control--PaddingLeft)); -} - -input { - color: var(--pf-v5-c-form-control--Color); - width: var(--pf-v5-c-form-control--Width); - padding: var(--pf-v5-c-form-control--PaddingTop) var(--pf-v5-c-form-control--PaddingRight) var(--pf-v5-c-form-control--PaddingBottom) var(--pf-v5-c-form-control--PaddingLeft); - font-size: var(--pf-v5-c-form-control--FontSize); - line-height: var(--pf-v5-c-form-control--LineHeight); - background-color: var(--pf-v5-c-form-control--BackgroundColor); - background-repeat: no-repeat; - border: var(--pf-v5-c-form-control--BorderWidth) solid; - border-color: var(--pf-v5-c-form-control--BorderTopColor) var(--pf-v5-c-form-control--BorderRightColor) var(--pf-v5-c-form-control--BorderBottomColor) var(--pf-v5-c-form-control--BorderLeftColor); - border-radius: var(--pf-v5-c-form-control--BorderRadius); - height: var(--pf-v5-c-form-control--Height); - text-overflow: ellipsis; - appearance: none; - -moz-appearance: none; - -webkit-appearance: none; -} - -input:disabled { - --pf-v5-c-form-control--BackgroundColor: var(--pf-v5-c-form-control--disabled--BackgroundColor); - color: var(--pf-v5-c-form-control--disabled--Color); - cursor: not-allowed; - border-color: var(--pf-v5-c-form-control--disabled--BorderColor); -} - -input:hover { - --pf-v5-c-form-control--BorderBottomColor: var(--pf-v5-c-form-control--hover--BorderBottomColor); -} - -input::placeholder { - color: var(--pf-v5-c-form-control--placeholder--Color); -} - -#error-text { - color: var(--pf-v5-c-form-control__error-text--m-status--Color); -} - -:host([left-truncated]) { - position: relative; -} - -:host([left-truncated]) input:not(:focus) { - direction: rtl; - text-overflow: ellipsis; -} - -:host([readonly]) input { - background-color: var(--pf-v5-c-form-control--readonly--BackgroundColor); -} - -:host([readonly][plain]) { - --pf-v5-c-form-control--readonly--BackgroundColor: var(--pf-v5-c-form-control--readonly--m-plain--BackgroundColor); - --pf-v5-c-form-control--inset--base: var(--pf-v5-c-form-control--readonly--m-plain--inset--base); -} - -:host([readonly][plain]) input { - border-color: transparent; -} - -:host(:invalid) { - --pf-v5-c-form-control--PaddingRight: var(--pf-v5-c-form-control--invalid--PaddingRight); - --pf-v5-c-form-control--BorderBottomColor: var(--pf-v5-c-form-control--invalid--BorderBottomColor); -} - -:host(:invalid) input { - padding-bottom: var(--pf-v5-c-form-control--invalid--PaddingBottom); - background-image: var(--pf-v5-c-form-control--invalid--BackgroundUrl); - background-position: var(--pf-v5-c-form-control--invalid--BackgroundPosition); - background-size: var(--pf-v5-c-form-control--invalid--BackgroundSize); - border-bottom-width: var(--pf-v5-c-form-control--invalid--BorderBottomWidth); -} - -:host([icon]), -:host([custom-icon-url]) { - --pf-v5-c-form-control--PaddingRight: var(--pf-v5-c-form-control--m-icon--PaddingRight); -} -:host([icon]) input, -:host([custom-icon-url]) input { - background-image: var(--pf-v5-c-form-control--m-icon--BackgroundUrl); - background-position: var(--pf-v5-c-form-control--m-icon--BackgroundPositionX) var(--pf-v5-c-form-control--m-icon--BackgroundPositionY); - background-size: var(--pf-v5-c-form-control--m-icon--BackgroundSizeX) var(--pf-v5-c-form-control--m-icon--BackgroundSizeY); -} - -:host([icon="calendar"]) { - --pf-v5-c-form-control--m-icon--BackgroundUrl: var(--pf-v5-c-form-control--m-calendar--BackgroundUrl); -} - -:host([icon="clock"]) { - --pf-v5-c-form-control--m-icon--BackgroundUrl: var(--pf-v5-c-form-control--m-clock--BackgroundUrl); -} - -:host([validated="success"]) { - --pf-v5-c-form-control--PaddingRight: var(--pf-v5-c-form-control--success--PaddingRight); - --pf-v5-c-form-control--BorderBottomColor: var(--pf-v5-c-form-control--success--BorderBottomColor); -} - -:host([validated="success"]) input { - padding-bottom: var(--pf-v5-c-form-control--success--PaddingBottom); - background-image: var(--pf-v5-c-form-control--success--BackgroundUrl); - background-position: var(--pf-v5-c-form-control--success--BackgroundPosition); - background-size: var(--pf-v5-c-form-control--success--BackgroundSize); - border-bottom-width: var(--pf-v5-c-form-control--success--BorderBottomWidth); -} - -:host([validated="warning"]) { - --pf-v5-c-form-control--PaddingRight: var(--pf-v5-c-form-control--m-warning--PaddingRight); - --pf-v5-c-form-control--BorderBottomColor: var(--pf-v5-c-form-control--m-warning--BorderBottomColor); -} - -:host([validated="warning"]) input { - padding-bottom: var(--pf-v5-c-form-control--m-warning--PaddingBottom); - background-image: var(--pf-v5-c-form-control--m-warning--BackgroundUrl); - background-position: var(--pf-v5-c-form-control--m-warning--BackgroundPosition); - background-size: var(--pf-v5-c-form-control--m-warning--BackgroundSize); - border-bottom-width: var(--pf-v5-c-form-control--m-warning--BorderBottomWidth); -} - -/* TBD if we'll implement this -:host([icon-sprite]) { - --pf-v5-c-form-control--success--BackgroundUrl: var(--pf-v5-c-form-control--m-icon-sprite--success--BackgroundUrl); - --pf-v5-c-form-control--m-warning--BackgroundUrl: var(--pf-v5-c-form-control--m-icon-sprite--m-warning--BackgroundUrl); - --pf-v5-c-form-control--invalid--BackgroundUrl: var(--pf-v5-c-form-control--m-icon-sprite--invalid--BackgroundUrl); - --pf-v5-c-form-control__select--BackgroundUrl: var(--pf-v5-c-form-control--m-icon-sprite__select--BackgroundUrl); - --pf-v5-c-form-control--m-search--BackgroundUrl: var(--pf-v5-c-form-control--m-icon-sprite--m-search--BackgroundUrl); - --pf-v5-c-form-control--m-calendar--BackgroundUrl: var(--pf-v5-c-form-control--m-icon-sprite--m-calendar--BackgroundUrl); - --pf-v5-c-form-control--m-clock--BackgroundUrl: var(--pf-v5-c-form-control--m-icon-sprite--m-clock--BackgroundUrl); - --pf-v5-c-form-control__select--BackgroundSize: var(--pf-v5-c-form-control--m-icon-sprite__select--BackgroundSize); - --pf-v5-c-form-control__select--BackgroundPositionX: var(--pf-v5-c-form-control--m-icon-sprite__select--BackgroundPositionX); - --pf-v5-c-form-control__select--success--BackgroundPosition: var(--pf-v5-c-form-control--m-icon-sprite__select--success--BackgroundPosition); - --pf-v5-c-form-control__select--m-warning--BackgroundPosition: var(--pf-v5-c-form-control--m-icon-sprite__select--m-warning--BackgroundPosition); - --pf-v5-c-form-control__select--invalid--BackgroundPosition: var(--pf-v5-c-form-control--m-icon-sprite__select--invalid--BackgroundPosition); -} -*/ diff --git a/elements/pf-v5-text-input/pf-v5-text-input.ts b/elements/pf-v5-text-input/pf-v5-text-input.ts deleted file mode 100644 index 761aafe566..0000000000 --- a/elements/pf-v5-text-input/pf-v5-text-input.ts +++ /dev/null @@ -1,205 +0,0 @@ -import { LitElement, html, isServer, type TemplateResult } from 'lit'; -import { customElement } from 'lit/decorators/custom-element.js'; -import { property } from 'lit/decorators/property.js'; -import { ifDefined } from 'lit/directives/if-defined.js'; -import { styleMap } from 'lit/directives/style-map.js'; - -import { InternalsController } from '@patternfly/pfe-core/controllers/internals-controller.js'; - -import styles from './pf-v5-text-input.css'; - -/** - * A **text input** is used to gather free-form text from a user. - * @alias Text Input - */ -@customElement('pf-v5-text-input') -export class PfV5TextInput extends LitElement { - static readonly styles: CSSStyleSheet[] = [styles]; - - static readonly formAssociated = true; - - static override readonly shadowRootOptions: ShadowRootInit = { - ...LitElement.shadowRootOptions, - delegatesFocus: true, - }; - - /** Trim text on left */ - @property({ type: Boolean, reflect: true, attribute: 'left-truncated' }) leftTruncated = false; - - /** - * Value to indicate if the input is modified to show that validation state. - * If set to success, input will be modified to indicate valid state. - * If set to warning, input will be modified to indicate warning state. - * Invalid inputs will display an error state - */ - @property({ reflect: true }) validated?: 'success' | 'warning'; - - /** icon variant */ - @property({ reflect: true }) icon?: 'calendar' | 'clock' | 'search'; - - /** Accessible label for the input when no `