draft-components 4.20.0 → 4.21.1

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.
@@ -3156,215 +3156,256 @@
3156
3156
  color-scheme: dark;
3157
3157
  }
3158
3158
 
3159
- .dc-search-select-button-label {
3159
+ .dc-search-select {
3160
+ --button-height: 36px;
3161
+ --button-padding-left: 12px;
3162
+ --button-slot-width: 32px;
3163
+ --button-font-size: 14px;
3164
+ --button-font-weight: 400;
3165
+ --button-line-height: 20px;
3166
+ --button-color: var(--dc-neutral-900);
3167
+ --button-background: var(--dc-white);
3168
+ --button-border-width: 1px;
3169
+ --button-border-style: solid;
3170
+ --button-border-color: var(--dc-neutral-300);
3171
+ --button-border-color-error: var(--dc-red-500);
3172
+ --button-border-radius: 7px;
3173
+ --button-focus-ring-color: var(--dc-focus-ring-color);
3174
+ --popup-min-width: 240px;
3175
+ --popup-max-width: 720px;
3176
+ --popup-offset: 4px;
3177
+ --popup-color: var(--dc-neutral-900);
3178
+ --popup-background: var(--dc-white);
3179
+ --popup-border-width: 1px;
3180
+ --popup-border-style: solid;
3181
+ --popup-border-color: var(--dc-neutral-300);
3182
+ --popup-border-radius: 7px;
3183
+ --popup-shadow:
3184
+ 0 2px 4px 0 rgb(var(--dc-neutral-950-rgb) / 5%),
3185
+ 0 2px 10px 0 rgb(var(--dc-neutral-950-rgb) / 10%);
3186
+ --input-padding: 8px 12px;
3187
+ --input-font-size: 14px;
3188
+ --input-font-weight: 400;
3189
+ --input-line-height: 1;
3190
+ --input-border-width: 1px;
3191
+ --input-border-style: solid;
3192
+ --input-border-color: var(--dc-neutral-300);
3193
+ --list-box-max-height: 256px;
3194
+ --list-box-padding: 4px;
3195
+ --option-padding: 4px 8px;
3196
+ --option-font: var(--dc-text-sm);
3197
+ --option-scroll-margin-block: 4px;
3198
+ --option-scroll-border-radius: 4px;
3199
+ --option-color: var(--dc-neutral-900);
3200
+ --option-background: none;
3201
+ --option-color-selected: var(--dc-neutral-950);
3202
+ --option-background-selected: rgb(var(--dc-neutral-950-rgb) / 12%);
3203
+ --option-color-checked: var(--dc-white);
3204
+ --option-background-checked: var(--dc-blue-500);
3205
+ --option-label-font: 600 var(--dc-text-sm);
3206
+ --option-label-color: inherit;
3207
+ --option-caption-font: var(--dc-text-sm);
3208
+ --option-caption-color: inherit;
3209
+ --empty-state-padding: 16px;
3210
+ --empty-state-font: var(--dc-text-sm);
3211
+ --empty-state-text-align: center;
3212
+ --empty-state-color: var(--dc-neutral-600);
3213
+ --empty-state-color-error: var(--dc-red-600);
3214
+
3215
+ position: relative;
3216
+ box-sizing: border-box;
3160
3217
  display: inline-flex;
3161
- gap: 0.5em;
3162
- align-items: center;
3218
+ font-family: var(--dc-primary-font);
3219
+ color-scheme: light;
3163
3220
  }
3164
3221
 
3165
- .dc-search-select-button-label > b {
3166
- font-weight: 700;
3222
+ .dc-search-select_full-width {
3223
+ display: flex;
3224
+ width: 100%;
3167
3225
  }
3168
3226
 
3169
- .dc-search-select-option {
3227
+ .dc-search-select__button {
3170
3228
  box-sizing: border-box;
3171
3229
  display: flex;
3172
- flex-direction: column;
3173
- justify-content: center;
3174
- min-height: 28px;
3175
- padding: 4px 8px;
3176
- font-size: 14px;
3177
- line-height: 1.25;
3178
- color: inherit;
3230
+ align-items: center;
3231
+ width: 100%;
3232
+ height: var(--button-height);
3233
+ padding: 0;
3234
+ font-size: var(--button-font-size);
3235
+ font-weight: var(--button-font-weight);
3236
+ line-height: var(--button-line-height);
3237
+ color: var(--button-color);
3238
+ text-align: left;
3179
3239
  cursor: default;
3180
- border-radius: 5px;
3181
- }
3182
-
3183
- .dc-search-select-option_highlighted {
3184
- color: var(--dc-neutral-900);
3185
- background: var(--dc-neutral-300);
3186
- }
3187
-
3188
- .dark .dc-search-select-option_highlighted {
3189
- color: var(--dc-white);
3190
- background: var(--dc-neutral-600);
3240
+ background: var(--button-background);
3241
+ border: var(--button-border-width) var(--button-border-style)
3242
+ var(--button-border-color);
3243
+ border-radius: var(--button-border-radius);
3191
3244
  }
3192
3245
 
3193
- .dc-search-select-option_selected {
3194
- color: var(--dc-white);
3195
- background: var(--dc-blue-500);
3246
+ .dc-search-select__button[data-invalid="true"] {
3247
+ --button-border-color: var(--button-border-color-error);
3196
3248
  }
3197
3249
 
3198
- .dark .dc-search-select-option_selected {
3199
- color: var(--dc-white);
3200
- background: var(--dc-blue-500);
3201
- }
3250
+ .dc-search-select__button:focus,
3251
+ .dc-search-select__button[aria-expanded="true"] {
3252
+ --button-border-color: var(--button-focus-ring-color);
3202
3253
 
3203
- .dc-search-select-option__caption {
3204
- font-size: 80%;
3205
- opacity: 0.75;
3254
+ outline: 1px solid var(--button-focus-ring-color);
3206
3255
  }
3207
3256
 
3208
- .dc-search-select-separator {
3209
- display: flex;
3210
- align-items: center;
3211
- width: 100%;
3212
- padding: 8px 0;
3257
+ .dc-search-select__button:disabled {
3258
+ opacity: var(--dc-disabled-state-opacity);
3213
3259
  }
3214
3260
 
3215
- .dc-search-select-separator::before,
3216
- .dc-search-select-separator::after {
3217
- display: block;
3218
- height: 1px;
3219
- content: "";
3220
- background: var(--dc-neutral-300);
3261
+ .dc-search-select__button_size_sm {
3262
+ --button-font-size: 13px;
3263
+ --button-height: 32px;
3264
+ --button-padding-left: 8px;
3265
+ --button-slot-width: 28px;
3266
+ --button-border-radius: 6px;
3221
3267
  }
3222
3268
 
3223
- .dc-search-select-separator::before {
3224
- flex-shrink: 0;
3225
- width: 12px;
3269
+ .dc-search-select__button_size_lg {
3270
+ --button-font-size: 15px;
3271
+ --button-height: 40px;
3272
+ --button-padding-left: 16px;
3273
+ --button-slot-width: 40px;
3274
+ --button-border-radius: 8px;
3226
3275
  }
3227
3276
 
3228
- .dc-search-select-separator::after {
3277
+ .dc-search-select__button-label {
3229
3278
  flex-grow: 1;
3230
3279
  }
3231
3280
 
3232
- .dark .dc-search-select-separator::before,
3233
- .dark .dc-search-select-separator::after {
3234
- background: var(--dc-neutral-600);
3235
- }
3236
-
3237
- .dc-search-select-separator__label {
3238
- padding: 0 8px;
3239
- font-size: 12px;
3240
- color: var(--dc-neutral-500);
3241
- }
3242
-
3243
- .dark .dc-search-select-separator__label {
3244
- color: var(--dc-neutral-400);
3281
+ .dc-search-select__button-label:first-child {
3282
+ padding-left: var(--button-padding-left);
3245
3283
  }
3246
3284
 
3247
- .dc-search-select {
3248
- --font-size: 14px;
3249
- --color: var(--dc-black-950);
3250
- --height: 36px;
3251
- --padding-x: 12px;
3252
- --radius: 7px;
3253
- --border-color: var(--dc-neutral-300);
3254
- --border-color-error: var(--dc-red-500);
3255
- --background: var(--dc-white);
3256
- --focus-ring-color: var(--dc-focus-ring-color);
3257
-
3258
- position: relative;
3259
- box-sizing: border-box;
3285
+ .dc-search-select__button-slot {
3260
3286
  display: inline-flex;
3287
+ flex-shrink: 0;
3261
3288
  align-items: center;
3262
- max-width: 100%;
3263
- height: var(--height);
3264
- padding: 0 var(--padding-x);
3265
- padding-right: calc(var(--height) + 0.15em);
3266
- font-family: var(--dc-primary-font);
3267
- font-size: var(--font-size);
3268
- font-weight: 400;
3269
- line-height: 1.25;
3270
- vertical-align: middle;
3271
- color: var(--color);
3272
- color-scheme: light;
3273
- background: var(--background);
3274
- border: 1px solid var(--border-color);
3275
- border-radius: var(--radius);
3289
+ justify-content: center;
3290
+ width: var(--button-slot-width);
3276
3291
  }
3277
3292
 
3278
- .dc-search-select:focus {
3279
- outline: none;
3280
- border-color: var(--focus-ring-color);
3281
- box-shadow: 0 0 0 1px var(--focus-ring-color);
3293
+ .dc-search-select__caret {
3294
+ opacity: 0.65;
3295
+ transform: translateY(10%);
3282
3296
  }
3283
3297
 
3284
- .dc-search-select_loading,
3285
- .dc-search-select_disabled {
3286
- pointer-events: none;
3298
+ .dc-search-select__popup {
3299
+ position: absolute;
3300
+ top: 100%;
3301
+ left: 0;
3302
+ z-index: var(--dc-overlay-z-index);
3303
+ width: 100%;
3304
+ min-width: var(--popup-min-width);
3305
+ max-width: var(--popup-max-width);
3306
+ margin-top: var(--popup-offset);
3307
+ overflow: hidden;
3308
+ color: var(--popup-color);
3309
+ background: var(--popup-background);
3310
+ border: var(--popup-border-width) var(--popup-border-style)
3311
+ var(--popup-border-color);
3312
+ border-radius: var(--popup-border-radius);
3313
+ box-shadow: var(--popup-shadow);
3287
3314
  }
3288
3315
 
3289
- .dc-search-select_disabled {
3290
- opacity: var(--dc-disabled-state-opacity);
3316
+ .dc-search-select__input {
3317
+ box-sizing: border-box;
3318
+ width: 100%;
3319
+ padding: var(--input-padding);
3320
+ margin: 0;
3321
+ font-family: inherit;
3322
+ font-size: var(--input-font-size);
3323
+ font-weight: var(--input-font-weight);
3324
+ line-height: var(--input-line-height);
3325
+ -webkit-appearance: none;
3326
+ -moz-appearance: none;
3327
+ appearance: none;
3328
+ background: none;
3329
+ border: none;
3330
+ border-bottom: var(--input-border-width) var(--input-border-style)
3331
+ var(--input-border-color);
3291
3332
  }
3292
3333
 
3293
- .dc-search-select_invalid {
3294
- border-color: var(--border-color-error);
3334
+ .dc-search-select__input::-moz-placeholder {
3335
+ color: inherit;
3336
+ opacity: 0.4;
3295
3337
  }
3296
3338
 
3297
- .dc-search-select_full-width {
3298
- display: flex;
3299
- width: 100%;
3339
+ .dc-search-select__input::placeholder {
3340
+ color: inherit;
3341
+ opacity: 0.4;
3300
3342
  }
3301
3343
 
3302
- .dc-search-select_size_sm {
3303
- --font-size: 13px;
3304
- --height: 32px;
3305
- --padding-x: 8px;
3306
- --radius: 6px;
3344
+ .dc-search-select__input:focus {
3345
+ outline: none;
3307
3346
  }
3308
3347
 
3309
- .dc-search-select_size_lg {
3310
- --font-size: 15px;
3311
- --height: 40px;
3312
- --padding-x: 16px;
3313
- --radius: 8px;
3348
+ .dc-search-select__content {
3349
+ font: var(--dc-text-sm);
3314
3350
  }
3315
3351
 
3316
- .dc-search-select__slot-right {
3317
- position: absolute;
3318
- top: 0;
3319
- right: 0;
3320
- display: inline-flex;
3321
- flex-shrink: 0;
3322
- align-items: center;
3323
- justify-content: center;
3324
- width: var(--height);
3325
- height: var(--height);
3326
- pointer-events: none;
3352
+ .dc-search-select__list-box {
3353
+ box-sizing: border-box;
3354
+ display: grid;
3355
+ max-height: var(--list-box-max-height);
3356
+ padding: var(--list-box-padding);
3357
+ margin: 0;
3358
+ overflow-y: auto;
3359
+ overscroll-behavior: contain;
3360
+ contain: content;
3361
+ list-style: none;
3362
+ scrollbar-width: thin;
3327
3363
  }
3328
3364
 
3329
- .dc-search-select__arrow {
3330
- transform: translateY(5%);
3365
+ .dc-search-select__option {
3366
+ box-sizing: border-box;
3367
+ display: flex;
3368
+ flex-direction: column;
3369
+ padding: var(--option-padding);
3370
+ font: var(--option-font);
3371
+ color: var(--option-color);
3372
+ cursor: default;
3373
+ scroll-margin-top: var(--option-scroll-margin-block);
3374
+ scroll-margin-bottom: var(--option-scroll-margin-block);
3375
+ background: var(--option-background);
3376
+ border-radius: var(--option-scroll-border-radius);
3331
3377
  }
3332
3378
 
3333
- .dc-search-select__popover {
3334
- --popover-padding: 8px;
3335
- --popover-radius: 8px;
3336
-
3337
- padding: 0;
3338
- padding-bottom: var(--popover-padding);
3339
- border-radius: var(--popover-radius);
3379
+ .dc-search-select__option[aria-selected="true"] {
3380
+ color: var(--option-color-selected);
3381
+ background: var(--option-background-selected);
3340
3382
  }
3341
3383
 
3342
- .dc-search-select__textbox {
3343
- padding: var(--popover-padding);
3384
+ .dc-search-select__option[aria-checked="true"] {
3385
+ color: var(--option-color-checked);
3386
+ background: var(--option-background-checked);
3344
3387
  }
3345
3388
 
3346
- .dc-search-select__listbox {
3347
- max-height: 352px;
3348
- padding: 0 var(--popover-padding);
3349
- margin: 0;
3350
- overflow-y: auto;
3351
- list-style: none;
3352
- border-bottom-right-radius: inherit;
3353
- border-bottom-left-radius: inherit;
3389
+ .dc-search-select__option-label {
3390
+ font: var(--option-label-font);
3391
+ color: var(--option-label-color);
3354
3392
  }
3355
3393
 
3356
- .dc-search-select__listbox > [role="option"] + [role="option"] {
3357
- margin-top: 2px;
3394
+ .dc-search-select__option-caption {
3395
+ font: var(--option-caption-font);
3396
+ color: var(--option-caption-color);
3358
3397
  }
3359
3398
 
3360
- .dark .dc-search-select,
3361
- .dark.dc-search-select {
3362
- --color: var(--dc-white);
3363
- --border-color: var(--dc-neutral-600);
3364
- --border-color-error: var(--dc-red-400);
3365
- --background: var(--dc-neutral-800);
3399
+ .dc-search-select__empty-state {
3400
+ box-sizing: border-box;
3401
+ padding: var(--empty-state-padding);
3402
+ font: var(--empty-state-font);
3403
+ color: var(--empty-state-color);
3404
+ text-align: var(--empty-state-text-align);
3405
+ }
3366
3406
 
3367
- color-scheme: dark;
3407
+ .dc-search-select__empty-state_error {
3408
+ color: var(--empty-state-color-error);
3368
3409
  }
3369
3410
 
3370
3411
  .dc-switch {
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
3
3
  import { classNames, tryToFocusElement } from '../../lib/react-helpers.js';
4
- import { useRefCallback } from '../../hooks/use-ref-callback.js';
4
+ import { useCallbackRef } from '../../hooks/use-callback-ref.js';
5
5
  import { useCloseOnEsc } from '../../hooks/use-close-on-esc.js';
6
6
  import { useLockBodyScroll } from '../../hooks/use-lock-body-scroll.js';
7
7
  import { useFocusTrap } from '../../hooks/use-focus-trap.js';
@@ -17,12 +17,12 @@ export function Dialog(props) {
17
17
  const defaultId = useId();
18
18
  const modalRef = useRef(null);
19
19
  const backdropRef = useRef(null);
20
- const close = useRefCallback(() => {
20
+ const close = useCallbackRef(() => {
21
21
  if (typeof onClose === 'function') {
22
22
  onClose();
23
23
  }
24
24
  });
25
- const unmount = useRefCallback(() => {
25
+ const unmount = useCallbackRef(() => {
26
26
  setIsMounted(false);
27
27
  if (typeof onUnmount === 'function') {
28
28
  onUnmount();
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useId, useState, } from 'react';
3
3
  import { classNames, tryToFocusElement } from '../../lib/react-helpers.js';
4
4
  import { KeyboardKey } from '../../lib/keyboard-key.js';
5
- import { useRefCallback } from '../../hooks/use-ref-callback.js';
5
+ import { useCallbackRef } from '../../hooks/use-callback-ref.js';
6
6
  import { Popover } from '../popover/index.js';
7
7
  import { MenuItem } from './menu-item.js';
8
8
  import { MenuSeparator } from './menu-separator.js';
@@ -11,13 +11,13 @@ export function Menu({ defaultIsOpen = false, shouldRenderBackdrop = false, plac
11
11
  const menuId = props.id || id;
12
12
  const buttonId = `menu-button-${menuId}`;
13
13
  const [isOpen, setIsOpen] = useState(defaultIsOpen);
14
- const open = useRefCallback(() => {
14
+ const open = useCallbackRef(() => {
15
15
  setIsOpen(true);
16
16
  if (typeof onOpen === 'function') {
17
17
  onOpen();
18
18
  }
19
19
  });
20
- const close = useRefCallback(() => {
20
+ const close = useCallbackRef(() => {
21
21
  setIsOpen(false);
22
22
  if (typeof onClose === 'function') {
23
23
  onClose();
@@ -4,7 +4,7 @@ import { observeElementMove } from '../../lib/observe-element-move.js';
4
4
  import { observeElementChange } from '../../lib/observe-element-change.js';
5
5
  import { calcElementPosition } from '../../lib/calc-element-position.js';
6
6
  import { deleteKeys } from '../../lib/helpers.js';
7
- import { useRefCallback } from '../../hooks/use-ref-callback.js';
7
+ import { useCallbackRef } from '../../hooks/use-callback-ref.js';
8
8
  import { useFocusTrap } from '../../hooks/use-focus-trap.js';
9
9
  import { useLockBodyScroll } from '../../hooks/use-lock-body-scroll.js';
10
10
  import { useCloseOnEsc } from '../../hooks/use-close-on-esc.js';
@@ -24,12 +24,12 @@ export function Popover({ className, role = 'dialog', 'aria-modal': ariaModal =
24
24
  else {
25
25
  anchorRef = defaultAnchorRef;
26
26
  }
27
- const close = useRefCallback(() => {
27
+ const close = useCallbackRef(() => {
28
28
  if (typeof onClose === 'function') {
29
29
  onClose();
30
30
  }
31
31
  });
32
- const unmount = useRefCallback(() => {
32
+ const unmount = useCallbackRef(() => {
33
33
  setIsMounted(false);
34
34
  if (typeof onUnmount === 'function') {
35
35
  onUnmount();