From 3e7eb707c05ab31d67082b96e5630f26baf4e0cf Mon Sep 17 00:00:00 2001 From: donskov Date: Wed, 28 Feb 2024 18:38:58 +0200 Subject: [PATCH] feat(react-components): add Autocomplete "label" prop support --- .../__snapshots__/autocomplete.test.tsx.snap | 934 ++++++++---------- .../src/Autocomplete/autocomplete.tsx | 80 +- .../src/hooks/use_autocomplete.ts | 7 + 3 files changed, 488 insertions(+), 533 deletions(-) diff --git a/packages/react-components/src/Autocomplete/__snapshots__/autocomplete.test.tsx.snap b/packages/react-components/src/Autocomplete/__snapshots__/autocomplete.test.tsx.snap index d2168b26..bb52bd04 100644 --- a/packages/react-components/src/Autocomplete/__snapshots__/autocomplete.test.tsx.snap +++ b/packages/react-components/src/Autocomplete/__snapshots__/autocomplete.test.tsx.snap @@ -3,15 +3,6 @@ exports[` should pass className 1`] = ` .emotion-0 { - position: relative; - display: -webkit-inline-box; - display: -webkit-inline-flex; - display: -ms-inline-flexbox; - display: inline-flex; - width: 100%; -} - -.emotion-1 { margin: 0; color: var(--pv-color-black); font-weight: var(--pv-text-b3-weight); @@ -43,53 +34,53 @@ exports[` should pass className 1`] = ` cursor: pointer; font-family: inherit; height: var(--pv-size-base-7); + position: relative; border-color: var(--pv-color-gray-8); } -.emotion-1:hover { +.emotion-0:hover { background-color: var(--pv-color-gray-3); border-color: var(--pv-color-gray-7); } -.emotion-1:disabled { +.emotion-0:disabled { cursor: not-allowed; background-color: var(--pv-color-gray-1); border-color: var(--pv-color-gray-5); color: var(--pv-color-gray-7); } -.emotion-1:not(:disabled) { +.emotion-0:not(:disabled) { color: var(--pv-color-black); } -.emotion-1:not(:disabled)[aria-placeholder] { +.emotion-0:not(:disabled)[aria-placeholder] { color: var(--pv-color-gray-9); } -.emotion-1:not(:disabled)[aria-invalid] { +.emotion-0:not(:disabled)[aria-invalid] { background-color: var(--pv-color-wrong-tint-5); border-color: var(--pv-color-wrong-tint-3); } -.emotion-1:not(:disabled):focus-visible { +.emotion-0:not(:disabled):focus-visible { background-color: var(--pv-color-secondary-tint-5); border-color: var(--pv-color-secondary-tint-3); } -.emotion-2 { +.emotion-1 { position: absolute; right: 0px; top: calc(50% - 12px); - pointer-events: none; margin: 0px var(--pv-size-base); color: var(--pv-color-gray-10); } -.emotion-2[aria-disabled="true"] { - color: var(--pv-color-gray-7); +.emotion-1[aria-disabled="true"] { + color: inherit; } -.emotion-3 { +.emotion-2 { bottom: 0; left: 0; height: 100%; @@ -101,56 +92,49 @@ exports[` should pass className 1`] = ` }
`; exports[` should pass error 1`] = ` .emotion-0 { - position: relative; - display: -webkit-inline-box; - display: -webkit-inline-flex; - display: -ms-inline-flexbox; - display: inline-flex; - width: 100%; -} - -.emotion-1 { margin: 0; color: var(--pv-color-black); font-weight: var(--pv-text-b3-weight); @@ -182,53 +166,53 @@ exports[` should pass error 1`] = ` cursor: pointer; font-family: inherit; height: var(--pv-size-base-7); + position: relative; border-color: var(--pv-color-gray-8); } -.emotion-1:hover { +.emotion-0:hover { background-color: var(--pv-color-gray-3); border-color: var(--pv-color-gray-7); } -.emotion-1:disabled { +.emotion-0:disabled { cursor: not-allowed; background-color: var(--pv-color-gray-1); border-color: var(--pv-color-gray-5); color: var(--pv-color-gray-7); } -.emotion-1:not(:disabled) { +.emotion-0:not(:disabled) { color: var(--pv-color-black); } -.emotion-1:not(:disabled)[aria-placeholder] { +.emotion-0:not(:disabled)[aria-placeholder] { color: var(--pv-color-gray-9); } -.emotion-1:not(:disabled)[aria-invalid] { +.emotion-0:not(:disabled)[aria-invalid] { background-color: var(--pv-color-wrong-tint-5); border-color: var(--pv-color-wrong-tint-3); } -.emotion-1:not(:disabled):focus-visible { +.emotion-0:not(:disabled):focus-visible { background-color: var(--pv-color-secondary-tint-5); border-color: var(--pv-color-secondary-tint-3); } -.emotion-2 { +.emotion-1 { position: absolute; right: 0px; top: calc(50% - 12px); - pointer-events: none; margin: 0px var(--pv-size-base); color: var(--pv-color-gray-10); } -.emotion-2[aria-disabled="true"] { - color: var(--pv-color-gray-7); +.emotion-1[aria-disabled="true"] { + color: inherit; } -.emotion-3 { +.emotion-2 { bottom: 0; left: 0; height: 100%; @@ -239,7 +223,7 @@ exports[` should pass error 1`] = ` box-sizing: border-box; } -.emotion-4 { +.emotion-3 { margin: 0; color: var(--pv-color-wrong); font-weight: var(--pv-text-c2-weight); @@ -249,7 +233,7 @@ exports[` should pass error 1`] = ` margin-top: 2px; } -.emotion-5 { +.emotion-4 { position: fixed; z-index: 1300; top: 0; @@ -258,7 +242,7 @@ exports[` should pass error 1`] = ` left: 0; } -.emotion-6 { +.emotion-5 { background: var(--pv-color-black); z-index: -1; position: fixed; @@ -270,7 +254,7 @@ exports[` should pass error 1`] = ` background-color: transparent; } -.emotion-7 { +.emotion-6 { outline: 0; max-width: calc(100% - 32px); min-width: 16px; @@ -282,17 +266,17 @@ exports[` should pass error 1`] = ` min-width: 240px; } -.emotion-8 { +.emotion-7 { border-color: var(--pv-color-gray-3); border-style: solid; border-width: 0px 0px 1px 0px; } -.emotion-9 { +.emotion-8 { padding: var(--pv-size-base-3) var(--pv-size-base-3) var(--pv-size-base-2); } -.emotion-10 { +.emotion-9 { margin: 0; color: var(--pv-color-black); font-weight: var(--pv-text-b3-weight); @@ -323,49 +307,49 @@ exports[` should pass error 1`] = ` border-color: var(--pv-color-gray-8); } -.emotion-10::-webkit-input-placeholder { +.emotion-9::-webkit-input-placeholder { color: var(--pv-color-gray-9); } -.emotion-10::-moz-placeholder { +.emotion-9::-moz-placeholder { color: var(--pv-color-gray-9); } -.emotion-10:-ms-input-placeholder { +.emotion-9:-ms-input-placeholder { color: var(--pv-color-gray-9); } -.emotion-10::placeholder { +.emotion-9::placeholder { color: var(--pv-color-gray-9); } -.emotion-10:hover { +.emotion-9:hover { background-color: var(--pv-color-gray-3); border-color: var(--pv-color-gray-7); } -.emotion-10:disabled { +.emotion-9:disabled { cursor: not-allowed; background-color: var(--pv-color-gray-1); border-color: var(--pv-color-gray-5); color: var(--pv-color-gray-7); } -.emotion-10:not(:disabled)[aria-invalid] { +.emotion-9:not(:disabled)[aria-invalid] { background-color: var(--pv-color-wrong-tint-5); border-color: var(--pv-color-wrong-tint-3); } -.emotion-10:not(:disabled):focus-visible { +.emotion-9:not(:disabled):focus-visible { background-color: var(--pv-color-secondary-tint-5); border-color: var(--pv-color-secondary-tint-3); } -.emotion-11 { +.emotion-10 { padding: var(--pv-size-base-3) var(--pv-size-base-2); } -.emotion-12 { +.emotion-11 { margin: 0; color: var(--pv-color-gray-10); font-weight: var(--pv-text-b2-weight); @@ -376,76 +360,77 @@ exports[` should pass error 1`] = `
-
+
-

- Error text -