diff --git a/package.json b/package.json index bf632e58a4..e3ba4f09cf 100644 --- a/package.json +++ b/package.json @@ -179,7 +179,7 @@ "typescript": "^4.5.3", "yargs": "^17.2.1" }, - "customElements": "projects/documentation/custom-elements.json", + "customElements": ".storybook/custom-elements.json", "workspaces": [ "packages/*", "projects/*", diff --git a/packages/textfield/src/Textfield.ts b/packages/textfield/src/Textfield.ts index df65cdb1f6..57df2e490e 100644 --- a/packages/textfield/src/Textfield.ts +++ b/packages/textfield/src/Textfield.ts @@ -219,7 +219,7 @@ export class TextfieldBase extends ManageHelpText(Focusable) { return html` ${this.grows && !this.quiet ? html` -
${this.value}
+
${this.value}​
` : nothing} diff --git a/packages/textfield/src/textfield.css b/packages/textfield/src/textfield.css index d319a6ca0e..e4fdbd42d3 100644 --- a/packages/textfield/src/textfield.css +++ b/packages/textfield/src/textfield.css @@ -34,6 +34,10 @@ textarea { resize: inherit; } +.input { + min-width: var(--spectrum-textfield-texticon-min-width); +} + :host([grows]) .input { position: absolute; top: 0; @@ -44,6 +48,8 @@ textarea { } :host([grows]) #sizer { + word-break: break-word; + white-space: pre-wrap; box-sizing: border-box; overflow-wrap: break-word; border: var(--spectrum-textfield-texticon-border-size) solid; @@ -81,3 +87,34 @@ textarea { .icon-workflow { pointer-events: none; } + +:host([multiline]) #textfield { + display: inline-grid; +} + +:host([multiline]) textarea { + transition: box-shadow var(--spectrum-global-animation-duration-100, 0.13s) + ease-in-out, + border-color var(--spectrum-global-animation-duration-100, 0.13s) + ease-in-out; +} + +:host([multiline][focused]:not([quiet])) textarea, +:host([multiline][focused]:not([quiet]):hover) textarea { + box-shadow: 0 0 0 + calc( + 0px + + var( + --spectrum-textfield-m-texticon-focus-ring-border-width, + var(--spectrum-alias-component-focusring-size) + ) + ) + var( + --spectrum-textfield-m-textonly-focus-ring-border-color-key-focus, + var(--spectrum-alias-focus-ring-color) + ) !important; +} + +:host([multiline]:not([quiet])) #textfield:after { + box-shadow: none; +} diff --git a/packages/textfield/stories/textarea.stories.ts b/packages/textfield/stories/textarea.stories.ts index 745525c576..9554343d6c 100644 --- a/packages/textfield/stories/textarea.stories.ts +++ b/packages/textfield/stories/textarea.stories.ts @@ -13,6 +13,7 @@ import { html, TemplateResult } from '@spectrum-web-components/base'; import '../sp-textfield.js'; import '@spectrum-web-components/field-label/sp-field-label.js'; +import '@spectrum-web-components/help-text/sp-help-text.js'; export default { component: 'sp-textfield', @@ -71,6 +72,17 @@ export const Default = (): TemplateResult => { `; }; +export const quiet = (): TemplateResult => html` + Enter your life story... + +`; + export const grows = (): TemplateResult => html` Enter your life story... html` > `; +export const growsEmpty = (): TemplateResult => html` + + This textfield hasn't been used yet + + + + Even empty Textfield display correctly while waiting for content. + + +`; + export const growsWithLargeWords = (): TemplateResult => html` Enter your life story with very long words... @@ -127,3 +156,20 @@ export const resizeControls = (): TemplateResult => html` placeholder="Horizontal resize control" > `; + +export const sized = (): TemplateResult => html` + + This textfield hasn't been used yet + + + + Even empty Textfield display correctly while waiting for content. + + +`; diff --git a/packages/textfield/stories/textfield.stories.ts b/packages/textfield/stories/textfield.stories.ts index 1083f6fe8e..70f16bff5c 100644 --- a/packages/textfield/stories/textfield.stories.ts +++ b/packages/textfield/stories/textfield.stories.ts @@ -12,6 +12,8 @@ governing permissions and limitations under the License. import { html, TemplateResult } from '@spectrum-web-components/base'; import '../sp-textfield.js'; +import '@spectrum-web-components/field-label/sp-field-label.js'; +import '@spectrum-web-components/help-text/sp-help-text.js'; export default { component: 'sp-textfield', @@ -50,6 +52,18 @@ export const Default = (): TemplateResult => { `; }; +export const quiet = (): TemplateResult => { + return html` + Enter your name + + `; +}; + export const notRequiredWithPattern = (): TemplateResult => { return html` html` placeholder="password" > `; + +export const empty = (): TemplateResult => html` + + This textfield hasn't been used yet + + + + Even empty Textfield display correctly while waiting for content. + + +`; + +export const sized = (): TemplateResult => html` + + This textfield hasn't been used yet + + + + Even empty Textfield display correctly while waiting for content. + + +`;