@mrpelz/uikit-ish 7.13.1 → 7.29.0
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.
- package/dist/components/accordion/style.css +0 -3
- package/dist/components/action-sheet/main.d.ts.map +1 -1
- package/dist/components/action-sheet/main.js +9 -6
- package/dist/components/action-sheet/main.js.map +1 -1
- package/dist/components/action-sheet/props.d.ts +2 -1
- package/dist/components/action-sheet/props.d.ts.map +1 -1
- package/dist/components/activity-view/style.css +17 -17
- package/dist/components/alert/main.d.ts.map +1 -1
- package/dist/components/alert/main.js +12 -4
- package/dist/components/alert/main.js.map +1 -1
- package/dist/components/alert/props.d.ts +2 -1
- package/dist/components/alert/props.d.ts.map +1 -1
- package/dist/components/alert/style.css +39 -15
- package/dist/components/avatar/style.css +2 -2
- package/dist/components/badge/style.css +1 -1
- package/dist/components/button/main.js +1 -1
- package/dist/components/button/main.js.map +1 -1
- package/dist/components/button/props.d.ts +3 -2
- package/dist/components/button/props.d.ts.map +1 -1
- package/dist/components/button/style.css +18 -29
- package/dist/components/card/buttons.d.ts +35 -0
- package/dist/components/card/buttons.d.ts.map +1 -0
- package/dist/components/card/buttons.js +60 -0
- package/dist/components/card/buttons.js.map +1 -0
- package/dist/components/card/channels.d.ts +43 -0
- package/dist/components/card/channels.d.ts.map +1 -0
- package/dist/components/card/channels.js +321 -0
- package/dist/components/card/channels.js.map +1 -0
- package/dist/components/card/color.d.ts +21 -0
- package/dist/components/card/color.d.ts.map +1 -0
- package/dist/components/card/color.js +100 -0
- package/dist/components/card/color.js.map +1 -0
- package/dist/components/card/main.d.ts +81 -0
- package/dist/components/card/main.d.ts.map +1 -0
- package/dist/components/card/main.js +91 -0
- package/dist/components/card/main.js.map +1 -0
- package/dist/components/card/parts.css +769 -0
- package/dist/components/card/press.d.ts +25 -0
- package/dist/components/card/press.d.ts.map +1 -0
- package/dist/components/card/press.js +111 -0
- package/dist/components/card/press.js.map +1 -0
- package/dist/components/card/progress.d.ts +43 -0
- package/dist/components/card/progress.d.ts.map +1 -0
- package/dist/components/card/progress.js +122 -0
- package/dist/components/card/progress.js.map +1 -0
- package/dist/components/card/props.d.ts +393 -0
- package/dist/components/card/props.d.ts.map +1 -0
- package/dist/components/card/props.js +2 -0
- package/dist/components/card/props.js.map +1 -0
- package/dist/components/card/root.d.ts +100 -0
- package/dist/components/card/root.d.ts.map +1 -0
- package/dist/components/card/root.js +388 -0
- package/dist/components/card/root.js.map +1 -0
- package/dist/components/card/rows.d.ts +19 -0
- package/dist/components/card/rows.d.ts.map +1 -0
- package/dist/components/card/rows.js +185 -0
- package/dist/components/card/rows.js.map +1 -0
- package/dist/components/card/segmented.d.ts +61 -0
- package/dist/components/card/segmented.d.ts.map +1 -0
- package/dist/components/card/segmented.js +289 -0
- package/dist/components/card/segmented.js.map +1 -0
- package/dist/components/card/shared.d.ts +55 -0
- package/dist/components/card/shared.d.ts.map +1 -0
- package/dist/components/card/shared.js +80 -0
- package/dist/components/card/shared.js.map +1 -0
- package/dist/components/card/slider.d.ts +16 -0
- package/dist/components/card/slider.d.ts.map +1 -0
- package/dist/components/card/slider.js +48 -0
- package/dist/components/card/slider.js.map +1 -0
- package/dist/components/card/stages.d.ts +18 -0
- package/dist/components/card/stages.d.ts.map +1 -0
- package/dist/components/card/stages.js +37 -0
- package/dist/components/card/stages.js.map +1 -0
- package/dist/components/card/style.css +959 -0
- package/dist/components/checkbox/style.css +10 -5
- package/dist/components/collapsible/style.css +0 -3
- package/dist/components/color-picker/color.d.ts +2 -2
- package/dist/components/color-picker/color.d.ts.map +1 -1
- package/dist/components/color-picker/color.js +7 -7
- package/dist/components/color-picker/color.js.map +1 -1
- package/dist/components/color-picker/main.d.ts +11 -5
- package/dist/components/color-picker/main.d.ts.map +1 -1
- package/dist/components/color-picker/main.js +147 -89
- package/dist/components/color-picker/main.js.map +1 -1
- package/dist/components/color-picker/props.d.ts +216 -6
- package/dist/components/color-picker/props.d.ts.map +1 -1
- package/dist/components/color-picker/style.css +12 -31
- package/dist/components/contextual-menu/main.d.ts +6 -2
- package/dist/components/contextual-menu/main.d.ts.map +1 -1
- package/dist/components/contextual-menu/main.js +67 -43
- package/dist/components/contextual-menu/main.js.map +1 -1
- package/dist/components/contextual-menu/props.d.ts +2 -1
- package/dist/components/contextual-menu/props.d.ts.map +1 -1
- package/dist/components/contextual-menu/style.css +64 -2
- package/dist/components/control-cards/main.d.ts +38 -0
- package/dist/components/control-cards/main.d.ts.map +1 -0
- package/dist/components/control-cards/main.js +196 -0
- package/dist/components/control-cards/main.js.map +1 -0
- package/dist/components/control-cards/props.d.ts +238 -0
- package/dist/components/control-cards/props.d.ts.map +1 -0
- package/dist/components/control-cards/props.js +2 -0
- package/dist/components/control-cards/props.js.map +1 -0
- package/dist/components/control-cards/style.css +2 -0
- package/dist/components/date-picker/main.d.ts +8 -3
- package/dist/components/date-picker/main.d.ts.map +1 -1
- package/dist/components/date-picker/main.js +73 -30
- package/dist/components/date-picker/main.js.map +1 -1
- package/dist/components/date-picker/pager.d.ts.map +1 -1
- package/dist/components/date-picker/pager.js +9 -2
- package/dist/components/date-picker/pager.js.map +1 -1
- package/dist/components/date-picker/props.d.ts +81 -5
- package/dist/components/date-picker/props.d.ts.map +1 -1
- package/dist/components/date-picker/style.css +25 -17
- package/dist/components/drawer/style.css +6 -0
- package/dist/components/edit-menu/main.d.ts +2 -1
- package/dist/components/edit-menu/main.d.ts.map +1 -1
- package/dist/components/edit-menu/main.js +8 -4
- package/dist/components/edit-menu/main.js.map +1 -1
- package/dist/components/edit-menu/style.css +2 -2
- package/dist/components/glass/backdrop.d.ts +75 -0
- package/dist/components/glass/backdrop.d.ts.map +1 -0
- package/dist/components/glass/backdrop.js +608 -0
- package/dist/components/glass/backdrop.js.map +1 -0
- package/dist/components/glass/gradient.d.ts +17 -0
- package/dist/components/glass/gradient.d.ts.map +1 -0
- package/dist/components/glass/gradient.js +233 -0
- package/dist/components/glass/gradient.js.map +1 -0
- package/dist/components/glass/main.d.ts +60 -6
- package/dist/components/glass/main.d.ts.map +1 -1
- package/dist/components/glass/main.js +100 -122
- package/dist/components/glass/main.js.map +1 -1
- package/dist/components/glass/marker.d.ts +66 -0
- package/dist/components/glass/marker.d.ts.map +1 -0
- package/dist/components/glass/marker.js +268 -0
- package/dist/components/glass/marker.js.map +1 -0
- package/dist/components/glass/props.d.ts +33 -7
- package/dist/components/glass/props.d.ts.map +1 -1
- package/dist/components/glass/style.css +172 -75
- package/dist/components/grid/dashes.d.ts +15 -0
- package/dist/components/grid/dashes.d.ts.map +1 -0
- package/dist/components/grid/dashes.js +37 -0
- package/dist/components/grid/dashes.js.map +1 -0
- package/dist/components/grid/edit.d.ts +11 -0
- package/dist/components/grid/edit.d.ts.map +1 -0
- package/dist/components/grid/edit.js +1066 -0
- package/dist/components/grid/edit.js.map +1 -0
- package/dist/components/grid/handle.d.ts +123 -0
- package/dist/components/grid/handle.d.ts.map +1 -0
- package/dist/components/grid/handle.js +194 -0
- package/dist/components/grid/handle.js.map +1 -0
- package/dist/components/grid/icons.d.ts +40 -0
- package/dist/components/grid/icons.d.ts.map +1 -0
- package/dist/components/grid/icons.js +140 -0
- package/dist/components/grid/icons.js.map +1 -0
- package/dist/components/grid/layout.d.ts +111 -0
- package/dist/components/grid/layout.d.ts.map +1 -0
- package/dist/components/grid/layout.js +1257 -0
- package/dist/components/grid/layout.js.map +1 -0
- package/dist/components/grid/main.d.ts +63 -0
- package/dist/components/grid/main.d.ts.map +1 -0
- package/dist/components/grid/main.js +1977 -0
- package/dist/components/grid/main.js.map +1 -0
- package/dist/components/grid/overlay.d.ts +24 -0
- package/dist/components/grid/overlay.d.ts.map +1 -0
- package/dist/components/grid/overlay.js +312 -0
- package/dist/components/grid/overlay.js.map +1 -0
- package/dist/components/grid/plan.d.ts +78 -0
- package/dist/components/grid/plan.d.ts.map +1 -0
- package/dist/components/grid/plan.js +249 -0
- package/dist/components/grid/plan.js.map +1 -0
- package/dist/components/grid/props.d.ts +579 -0
- package/dist/components/grid/props.d.ts.map +1 -0
- package/dist/components/grid/props.js +2 -0
- package/dist/components/grid/props.js.map +1 -0
- package/dist/components/grid/reshape.d.ts +60 -0
- package/dist/components/grid/reshape.d.ts.map +1 -0
- package/dist/components/grid/reshape.js +214 -0
- package/dist/components/grid/reshape.js.map +1 -0
- package/dist/components/grid/style.css +1323 -0
- package/dist/components/header/main.d.ts.map +1 -1
- package/dist/components/header/main.js +97 -10
- package/dist/components/header/main.js.map +1 -1
- package/dist/components/header/props.d.ts +2 -2
- package/dist/components/header/props.d.ts.map +1 -1
- package/dist/components/header/style.css +40 -49
- package/dist/components/index.d.ts +16 -10
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +11 -5
- package/dist/components/index.js.map +1 -1
- package/dist/components/island/main.d.ts +2 -2
- package/dist/components/island/main.d.ts.map +1 -1
- package/dist/components/island/main.js +193 -41
- package/dist/components/island/main.js.map +1 -1
- package/dist/components/island/props.d.ts +4 -2
- package/dist/components/island/props.d.ts.map +1 -1
- package/dist/components/island/style.css +50 -3
- package/dist/components/layout/main.d.ts +3 -6
- package/dist/components/layout/main.d.ts.map +1 -1
- package/dist/components/layout/main.js +225 -56
- package/dist/components/layout/main.js.map +1 -1
- package/dist/components/layout/props.d.ts +43 -2
- package/dist/components/layout/props.d.ts.map +1 -1
- package/dist/components/layout/style.css +81 -23
- package/dist/components/list/main.d.ts +8 -6
- package/dist/components/list/main.d.ts.map +1 -1
- package/dist/components/list/main.js +132 -24
- package/dist/components/list/main.js.map +1 -1
- package/dist/components/list/props.d.ts +25 -0
- package/dist/components/list/props.d.ts.map +1 -1
- package/dist/components/list/reorder.d.ts +50 -2
- package/dist/components/list/reorder.d.ts.map +1 -1
- package/dist/components/list/reorder.js +40 -17
- package/dist/components/list/reorder.js.map +1 -1
- package/dist/components/list/style.css +160 -75
- package/dist/components/menu/main.d.ts +9 -5
- package/dist/components/menu/main.d.ts.map +1 -1
- package/dist/components/menu/main.js +87 -9
- package/dist/components/menu/main.js.map +1 -1
- package/dist/components/menu/props.d.ts +14 -0
- package/dist/components/menu/props.d.ts.map +1 -1
- package/dist/components/menu/style.css +41 -31
- package/dist/components/navigation/main.d.ts.map +1 -1
- package/dist/components/navigation/main.js +35 -13
- package/dist/components/navigation/main.js.map +1 -1
- package/dist/components/navigation/style.css +7 -0
- package/dist/components/page/main.d.ts.map +1 -1
- package/dist/components/page/main.js +6 -3
- package/dist/components/page/main.js.map +1 -1
- package/dist/components/page/props.d.ts +3 -2
- package/dist/components/page/props.d.ts.map +1 -1
- package/dist/components/page/style.css +8 -4
- package/dist/components/page-control/main.d.ts.map +1 -1
- package/dist/components/page-control/main.js +32 -15
- package/dist/components/page-control/main.js.map +1 -1
- package/dist/components/page-control/props.d.ts +9 -3
- package/dist/components/page-control/props.d.ts.map +1 -1
- package/dist/components/page-control/style.css +36 -0
- package/dist/components/pager/main.d.ts +12 -0
- package/dist/components/pager/main.d.ts.map +1 -0
- package/dist/components/pager/main.js +368 -0
- package/dist/components/pager/main.js.map +1 -0
- package/dist/components/pager/props.d.ts +36 -0
- package/dist/components/pager/props.d.ts.map +1 -0
- package/dist/components/pager/props.js +2 -0
- package/dist/components/pager/props.js.map +1 -0
- package/dist/components/pager/style.css +42 -0
- package/dist/components/popover/main.d.ts +10 -4
- package/dist/components/popover/main.d.ts.map +1 -1
- package/dist/components/popover/main.js +30 -19
- package/dist/components/popover/main.js.map +1 -1
- package/dist/components/popover/props.d.ts +2 -0
- package/dist/components/popover/props.d.ts.map +1 -1
- package/dist/components/popover/style.css +6 -2
- package/dist/components/progress/main.d.ts.map +1 -1
- package/dist/components/progress/main.js +3 -2
- package/dist/components/progress/main.js.map +1 -1
- package/dist/components/progress/style.css +4 -10
- package/dist/components/roll/main.d.ts.map +1 -1
- package/dist/components/roll/main.js +5 -3
- package/dist/components/roll/main.js.map +1 -1
- package/dist/components/roll/style.css +2 -2
- package/dist/components/segmented/main.d.ts.map +1 -1
- package/dist/components/segmented/main.js +4 -4
- package/dist/components/segmented/main.js.map +1 -1
- package/dist/components/segmented/props.d.ts +5 -2
- package/dist/components/segmented/props.d.ts.map +1 -1
- package/dist/components/segmented/style.css +17 -8
- package/dist/components/settings/main.d.ts +48 -1
- package/dist/components/settings/main.d.ts.map +1 -1
- package/dist/components/settings/main.js +311 -66
- package/dist/components/settings/main.js.map +1 -1
- package/dist/components/settings/props.d.ts +46 -4
- package/dist/components/settings/props.d.ts.map +1 -1
- package/dist/components/settings/region.d.ts +3 -0
- package/dist/components/settings/region.d.ts.map +1 -0
- package/dist/components/settings/region.js +120 -0
- package/dist/components/settings/region.js.map +1 -0
- package/dist/components/settings/style.css +2 -2
- package/dist/components/sheet/main.d.ts.map +1 -1
- package/dist/components/sheet/main.js +156 -45
- package/dist/components/sheet/main.js.map +1 -1
- package/dist/components/sheet/props.d.ts +4 -2
- package/dist/components/sheet/props.d.ts.map +1 -1
- package/dist/components/sheet/snap.d.ts +54 -0
- package/dist/components/sheet/snap.d.ts.map +1 -1
- package/dist/components/sheet/snap.js +261 -23
- package/dist/components/sheet/snap.js.map +1 -1
- package/dist/components/sheet/style.css +171 -20
- package/dist/components/sidebar/main.d.ts +2 -1
- package/dist/components/sidebar/main.d.ts.map +1 -1
- package/dist/components/sidebar/main.js +18 -6
- package/dist/components/sidebar/main.js.map +1 -1
- package/dist/components/sidebar/props.d.ts +2 -1
- package/dist/components/sidebar/props.d.ts.map +1 -1
- package/dist/components/sidebar/style.css +78 -0
- package/dist/components/slider/main.d.ts.map +1 -1
- package/dist/components/slider/main.js +55 -10
- package/dist/components/slider/main.js.map +1 -1
- package/dist/components/slider/props.d.ts +1 -0
- package/dist/components/slider/props.d.ts.map +1 -1
- package/dist/components/slider/style.css +15 -6
- package/dist/components/stack/main.d.ts +8 -0
- package/dist/components/stack/main.d.ts.map +1 -0
- package/dist/components/stack/main.js +25 -0
- package/dist/components/stack/main.js.map +1 -0
- package/dist/components/stack/props.d.ts +42 -0
- package/dist/components/stack/props.d.ts.map +1 -0
- package/dist/components/stack/props.js +2 -0
- package/dist/components/stack/props.js.map +1 -0
- package/dist/components/stack/style.css +68 -0
- package/dist/components/stepper/main.d.ts +3 -1
- package/dist/components/stepper/main.d.ts.map +1 -1
- package/dist/components/stepper/main.js +4 -0
- package/dist/components/stepper/main.js.map +1 -1
- package/dist/components/stepper/style.css +2 -2
- package/dist/components/switch/main.d.ts.map +1 -1
- package/dist/components/switch/main.js +9 -3
- package/dist/components/switch/main.js.map +1 -1
- package/dist/components/switch/props.d.ts +4 -1
- package/dist/components/switch/props.d.ts.map +1 -1
- package/dist/components/symbol/main.d.ts.map +1 -1
- package/dist/components/symbol/main.js +5 -1
- package/dist/components/symbol/main.js.map +1 -1
- package/dist/components/symbol/props.d.ts +10 -0
- package/dist/components/symbol/props.d.ts.map +1 -1
- package/dist/components/symbol/style.css +21 -3
- package/dist/components/tab-bar/main.d.ts.map +1 -1
- package/dist/components/tab-bar/main.js +8 -5
- package/dist/components/tab-bar/main.js.map +1 -1
- package/dist/components/tab-bar/props.d.ts +16 -12
- package/dist/components/tab-bar/props.d.ts.map +1 -1
- package/dist/components/tab-bar/style.css +38 -21
- package/dist/components/text-field/main.d.ts.map +1 -1
- package/dist/components/text-field/main.js +6 -3
- package/dist/components/text-field/main.js.map +1 -1
- package/dist/components/text-field/style.css +28 -17
- package/dist/components/toolbar/main.d.ts +5 -2
- package/dist/components/toolbar/main.d.ts.map +1 -1
- package/dist/components/toolbar/main.js +19 -1
- package/dist/components/toolbar/main.js.map +1 -1
- package/dist/components/toolbar/props.d.ts +18 -3
- package/dist/components/toolbar/props.d.ts.map +1 -1
- package/dist/components/toolbar/style.css +127 -11
- package/dist/components/tooltip/main.d.ts +6 -1
- package/dist/components/tooltip/main.d.ts.map +1 -1
- package/dist/components/tooltip/main.js +13 -7
- package/dist/components/tooltip/main.js.map +1 -1
- package/dist/components/tooltip/style.css +2 -2
- package/dist/components/typography/main.d.ts +1 -0
- package/dist/components/typography/main.d.ts.map +1 -1
- package/dist/components/typography/main.js +1 -0
- package/dist/components/typography/main.js.map +1 -1
- package/dist/components/typography/sizes.css +456 -0
- package/dist/components/typography/style.css +24 -456
- package/dist/components/utils/main.d.ts +50 -4
- package/dist/components/utils/main.d.ts.map +1 -1
- package/dist/components/utils/main.js +113 -3
- package/dist/components/utils/main.js.map +1 -1
- package/dist/components/viewport/current.d.ts +15 -0
- package/dist/components/viewport/current.d.ts.map +1 -0
- package/dist/components/viewport/current.js +74 -0
- package/dist/components/viewport/current.js.map +1 -0
- package/dist/components/viewport/edge-effect.d.ts.map +1 -1
- package/dist/components/viewport/edge-effect.js +58 -26
- package/dist/components/viewport/edge-effect.js.map +1 -1
- package/dist/components/viewport/edge.d.ts +7 -4
- package/dist/components/viewport/edge.d.ts.map +1 -1
- package/dist/components/viewport/edge.js +21 -7
- package/dist/components/viewport/edge.js.map +1 -1
- package/dist/components/viewport/focus-scroll.d.ts +21 -0
- package/dist/components/viewport/focus-scroll.d.ts.map +1 -0
- package/dist/components/viewport/focus-scroll.js +273 -0
- package/dist/components/viewport/focus-scroll.js.map +1 -0
- package/dist/components/viewport/input.d.ts +39 -1
- package/dist/components/viewport/input.d.ts.map +1 -1
- package/dist/components/viewport/input.js +122 -13
- package/dist/components/viewport/input.js.map +1 -1
- package/dist/components/viewport/main.d.ts +16 -1
- package/dist/components/viewport/main.d.ts.map +1 -1
- package/dist/components/viewport/main.js +276 -50
- package/dist/components/viewport/main.js.map +1 -1
- package/dist/components/viewport/padding.d.ts +1 -1
- package/dist/components/viewport/padding.d.ts.map +1 -1
- package/dist/components/viewport/padding.js +2 -2
- package/dist/components/viewport/props.d.ts +12 -2
- package/dist/components/viewport/props.d.ts.map +1 -1
- package/dist/components/viewport/status-bar.d.ts +9 -0
- package/dist/components/viewport/status-bar.d.ts.map +1 -0
- package/dist/components/viewport/status-bar.js +131 -0
- package/dist/components/viewport/status-bar.js.map +1 -0
- package/dist/components/viewport/style.css +67 -16
- package/dist/styles.css +371 -279
- package/package.json +5 -4
|
@@ -15,7 +15,7 @@ import { List } from '../list/main.js';
|
|
|
15
15
|
import { Menu } from '../menu/main.js';
|
|
16
16
|
import { PageControl } from '../page-control/main.js';
|
|
17
17
|
import { Segmented } from '../segmented/main.js';
|
|
18
|
-
import { Checkmark, cn, useForwardedRef, useTouchHold, withStyle, } from '../utils/main.js';
|
|
18
|
+
import { Checkmark, cn, createLabels, smoothScrollOf, useForwardedRef, useTouchHold, withStyle, } from '../utils/main.js';
|
|
19
19
|
import { Viewport } from '../viewport/main.js';
|
|
20
20
|
import { codeGroups, parseCssColor } from './color.js';
|
|
21
21
|
import { cssNamedColors } from './named-colors.js';
|
|
@@ -23,15 +23,19 @@ import { cssNamedColors } from './named-colors.js';
|
|
|
23
23
|
// or sheet (compact), its header the app's (a `Toolbar`: the eyedropper,
|
|
24
24
|
// “Colors”, close; in the popup's header, `Popover.Header` or
|
|
25
25
|
// `Sheet.Header`, the panel scrolling under it, behind its edge effect):
|
|
26
|
-
// - a segmented control (Grid, Spectrum, Sliders
|
|
26
|
+
// - a segmented control of the app's modes (e.g. Grid, Spectrum, Sliders,
|
|
27
|
+
// Named), 24px above the view;
|
|
27
28
|
// - Grid: 12 by 10 swatches (a gray row, then hues by lightness), its
|
|
28
29
|
// corners 18px, the selected one outlined white (3px);
|
|
29
30
|
// - Spectrum: hues across, light to dark down (white at the top, pure hues
|
|
30
31
|
// halfway, black at the bottom), its corners 18px, the color ringed;
|
|
31
|
-
// - Sliders: red, green and blue
|
|
32
|
-
//
|
|
32
|
+
// - Sliders: a color model's channels (red, green and blue, 0 to 255 or 0
|
|
33
|
+
// to 100%; hue, saturation and lightness; cyan, magenta, yellow and
|
|
34
|
+
// black; see `Sliders`), each a channel's row (see `ChannelRow`): its title (all caps), a slider
|
|
33
35
|
// mixing from the color (the channel along its range), and its value,
|
|
34
36
|
// typed;
|
|
37
|
+
// - Named: a list of named colors (e.g. CSS's), with an index of their
|
|
38
|
+
// first letters (see `Named`);
|
|
35
39
|
// - Each channel's row kept above the keyboard as its field's typed into
|
|
36
40
|
// (a `Viewport.KeyboardAccessory`; in a `Viewport.Provider`);
|
|
37
41
|
// - Opacity (optional: its part, `Opacity`), a channel's row too: the
|
|
@@ -147,6 +151,48 @@ const PanelContext = createContext({
|
|
|
147
151
|
registerMode: () => undefined,
|
|
148
152
|
setMode: () => undefined,
|
|
149
153
|
});
|
|
154
|
+
/**
|
|
155
|
+
* A picker's built-in words (English): the defaults of every part's
|
|
156
|
+
* `…Label` props (see `ColorPickerLabels`), shown (e.g. a channel's title,
|
|
157
|
+
* the swatches' menu and action sheet) or read by assistive technology.
|
|
158
|
+
*/
|
|
159
|
+
export const colorPickerLabels = {
|
|
160
|
+
addColorLabel: 'Add color',
|
|
161
|
+
blackLabel: 'Black',
|
|
162
|
+
blueLabel: 'Blue',
|
|
163
|
+
channelValueLabel: (channel) => `${channel} value`,
|
|
164
|
+
copyColorCodeLabel: 'Copy color code',
|
|
165
|
+
cyanLabel: 'Cyan',
|
|
166
|
+
deleteColorLabel: 'Delete',
|
|
167
|
+
eyedropperLabel: 'Eyedropper',
|
|
168
|
+
flattenColorLabel: 'Flatten color',
|
|
169
|
+
flattenColorTitleLabel: 'Flatten Color?',
|
|
170
|
+
flattenOnBlackLabel: 'Flatten on Black',
|
|
171
|
+
flattenOnWhiteLabel: 'Flatten on White',
|
|
172
|
+
greenLabel: 'Green',
|
|
173
|
+
gridLabel: 'Grid',
|
|
174
|
+
hexLabel: 'Hex',
|
|
175
|
+
hexWithAlphaLabel: 'Hex with alpha',
|
|
176
|
+
hueLabel: 'Hue',
|
|
177
|
+
indexLabel: 'Index',
|
|
178
|
+
lightnessLabel: 'Lightness',
|
|
179
|
+
magentaLabel: 'Magenta',
|
|
180
|
+
modesLabel: 'Mode',
|
|
181
|
+
opacityLabel: 'Opacity',
|
|
182
|
+
opacityValueLabel: 'Opacity percentage',
|
|
183
|
+
perceptualLabel: 'Perceptual',
|
|
184
|
+
redLabel: 'Red',
|
|
185
|
+
removeTransparencyLabel: 'Remove Transparency',
|
|
186
|
+
saturationLabel: 'Saturation',
|
|
187
|
+
savedColorsLabel: 'Saved colors',
|
|
188
|
+
spectrumLabel: 'Spectrum',
|
|
189
|
+
srgbLabel: 'sRGB',
|
|
190
|
+
systemColorsLabel: 'System colors',
|
|
191
|
+
wideGamutLabel: 'Wide gamut',
|
|
192
|
+
yellowLabel: 'Yellow',
|
|
193
|
+
};
|
|
194
|
+
/** A picker's words (see `Root`), for its parts within; a part's own. */
|
|
195
|
+
const { LabelsContext, omitLabels, useLabels } = createLabels(colorPickerLabels);
|
|
150
196
|
/**
|
|
151
197
|
* A color picker: its color and its mode, for its parts (`Modes`,
|
|
152
198
|
* `Panel`, `Eyedropper`, anywhere in it), in the app's popover or sheet.
|
|
@@ -154,7 +200,10 @@ const PanelContext = createContext({
|
|
|
154
200
|
* toolbar (and, in a sheet, its modes' control) can be in the popup's
|
|
155
201
|
* header (`Popover.Header`, `Sheet.Header`), its panel scrolling under it.
|
|
156
202
|
*/
|
|
157
|
-
const Root = forwardRef((
|
|
203
|
+
const Root = forwardRef((allProps, ref) => {
|
|
204
|
+
const labels = useLabels(allProps);
|
|
205
|
+
const { className, defaultMode, defaultValue = '#000000', mode: modeProp, onModeChange, onValueChange, render, style, value, ...rest } = allProps;
|
|
206
|
+
const props = omitLabels(rest);
|
|
158
207
|
const [own, setOwn] = useState(defaultValue);
|
|
159
208
|
// Its `Opacity`s rendered: without one, the color opaque (its alpha,
|
|
160
209
|
// if given one, dropped).
|
|
@@ -224,7 +273,7 @@ const Root = forwardRef(({ className, defaultMode, defaultValue = '#000000', mod
|
|
|
224
273
|
ref,
|
|
225
274
|
render,
|
|
226
275
|
});
|
|
227
|
-
return (_jsx(PickerContext.Provider, { value: state, children: _jsx(PanelContext.Provider, { value: modes, children: element }) }));
|
|
276
|
+
return (_jsx(LabelsContext.Provider, { value: labels, children: _jsx(PickerContext.Provider, { value: state, children: _jsx(PanelContext.Provider, { value: modes, children: element }) }) }));
|
|
228
277
|
});
|
|
229
278
|
/**
|
|
230
279
|
* Its panel: its modes' control (`Modes`, unless elsewhere, e.g. a sheet's
|
|
@@ -240,7 +289,8 @@ const Panel = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: r
|
|
|
240
289
|
*/
|
|
241
290
|
const Modes = forwardRef(({ children, ...props }, ref) => {
|
|
242
291
|
const { mode, setMode } = useContext(PanelContext);
|
|
243
|
-
|
|
292
|
+
const { modesLabel } = useContext(LabelsContext);
|
|
293
|
+
return (_jsxs(Segmented.Root, { ref: ref, "aria-label": modesLabel,
|
|
244
294
|
// (Its modes, however many, scrolled when they don't fit.)
|
|
245
295
|
overflow: "scroll", ...props, className: cn('uikit-color-picker-modes', props.className), value: mode, onValueChange: (next, details) => setMode(String(next), details), children: [children, _jsx(Segmented.Highlight, {})] }));
|
|
246
296
|
});
|
|
@@ -253,7 +303,8 @@ const Mode = forwardRef(({ value, ...props }, ref) => {
|
|
|
253
303
|
/** Swatches in rows (a gray row, then hues by lightness), its corners 18px. */
|
|
254
304
|
const Grid = forwardRef(({ className, ...props }, ref) => {
|
|
255
305
|
const { color, setColor } = useContext(PickerContext);
|
|
256
|
-
|
|
306
|
+
const { gridLabel } = useContext(LabelsContext);
|
|
307
|
+
return (_jsx("div", { ref: ref, "aria-label": gridLabel, role: "group", ...props, className: cn('uikit-color-picker-grid', className), "data-color-picker-part": "grid", children: grid.flatMap((row) => row.map((hex) => {
|
|
257
308
|
const swatch = parseColor(hex);
|
|
258
309
|
return (_jsx("button", { "aria-label": hex, "aria-pressed": sameColor(swatch, color), style: { backgroundColor: hex }, type: "button", onClick: (event) => setColor({ ...swatch, a: color.a }, { event, reason: 'grid' }) }, hex));
|
|
259
310
|
})) }));
|
|
@@ -261,6 +312,7 @@ const Grid = forwardRef(({ className, ...props }, ref) => {
|
|
|
261
312
|
/** Hues across, white to black down, the color ringed; its corners 18px. */
|
|
262
313
|
const Spectrum = forwardRef(({ className, ...props }, ref) => {
|
|
263
314
|
const { color, setColor } = useContext(PickerContext);
|
|
315
|
+
const { spectrumLabel } = useContext(LabelsContext);
|
|
264
316
|
const { h, l } = toHsl(color);
|
|
265
317
|
const pick = (event) => {
|
|
266
318
|
const { height, left, top, width } = event.currentTarget.getBoundingClientRect();
|
|
@@ -294,7 +346,7 @@ const Spectrum = forwardRef(({ className, ...props }, ref) => {
|
|
|
294
346
|
a: color.a,
|
|
295
347
|
}, { event, reason: 'spectrum' });
|
|
296
348
|
};
|
|
297
|
-
return (_jsx("div", { ref: ref, "aria-label":
|
|
349
|
+
return (_jsx("div", { ref: ref, "aria-label": spectrumLabel, "aria-valuetext": formatColor({ ...color, a: 1 }), role: "slider", tabIndex: 0, ...props, className: cn('uikit-color-picker-spectrum', className), "data-base-ui-swipe-ignore": "", "data-color-picker-part": "spectrum", onKeyDown: handleKeyDown, onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, children: _jsx("span", { style: {
|
|
298
350
|
backgroundColor: formatColor({ ...color, a: 1 }),
|
|
299
351
|
left: `${String((h / 360) * 100)}%`,
|
|
300
352
|
top: `${String((1 - l) * 100)}%`,
|
|
@@ -325,14 +377,6 @@ const View = forwardRef(({ children, className, value, ...props }, ref) => {
|
|
|
325
377
|
const trackStops = (colors) => colors
|
|
326
378
|
.map((stop, index) => `${stop} calc(var(--uikit-color-picker-channel-size) / 2 + (100% - var(--uikit-color-picker-channel-size)) * ${String(index / Math.max(colors.length - 1, 1))})`)
|
|
327
379
|
.join(', ');
|
|
328
|
-
/**
|
|
329
|
-
* A channel's row (the sliders', the opacity's): its title (all caps,
|
|
330
|
-
* secondary), a slider (32px high, mixing from the color: its gradient
|
|
331
|
-
* the color with the channel along its range; its knob as high, in the
|
|
332
|
-
* color, ringed white, 3px) and its value (a 75px by 32px field on the system
|
|
333
|
-
* fill, 8px corners, Body emphasized: typed, applied as it's typed, within
|
|
334
|
-
* its range).
|
|
335
|
-
*/
|
|
336
380
|
/**
|
|
337
381
|
* A typed field's handlers (a channel's value, the code): focused, all of
|
|
338
382
|
* it selected (to type over); left (or Enter), `onLeave` (its value again,
|
|
@@ -368,6 +412,14 @@ const useFieldSelection = (onLeave) => {
|
|
|
368
412
|
},
|
|
369
413
|
};
|
|
370
414
|
};
|
|
415
|
+
/**
|
|
416
|
+
* A channel's row (the sliders', the opacity's): its title (all caps,
|
|
417
|
+
* secondary), a slider (32px high, mixing from the color: its gradient
|
|
418
|
+
* the color with the channel along its range; its knob as high, in the
|
|
419
|
+
* color, ringed white, 3px) and its value (a 75px by 32px field on the system
|
|
420
|
+
* fill, 8px corners, Body emphasized: typed, applied as it's typed, within
|
|
421
|
+
* its range).
|
|
422
|
+
*/
|
|
371
423
|
const ChannelRow = ({ fieldLabel, isCheckered = false, label, max, onValueChange, stops, thumbColor, unit, value, }) => {
|
|
372
424
|
const [draft, setDraft] = useState(undefined);
|
|
373
425
|
const selection = useFieldSelection(() => setDraft(undefined));
|
|
@@ -392,7 +444,7 @@ const ChannelRow = ({ fieldLabel, isCheckered = false, label, max, onValueChange
|
|
|
392
444
|
'--uikit-color-picker-channel-position': value / max,
|
|
393
445
|
'--uikit-color-picker-channel-stops': trackStops(stops),
|
|
394
446
|
'--uikit-color-picker-channel-thumb': thumbColor,
|
|
395
|
-
}, ...holdHandlers, children: _jsx(BaseSlider.Track, { children: _jsx(BaseSlider.Thumb, { className: "uikit-color-picker-channel-thumb", "data-color-picker-part": "channel-thumb" }) }) }) }), _jsxs("label", { className: "uikit-color-picker-channel-field", "data-color-picker-part": "channel-field", children: [_jsx("input", { "aria-label": fieldLabel
|
|
447
|
+
}, ...holdHandlers, children: _jsx(BaseSlider.Track, { children: _jsx(BaseSlider.Thumb, { className: "uikit-color-picker-channel-thumb", "data-color-picker-part": "channel-thumb" }) }) }) }), _jsxs("label", { className: "uikit-color-picker-channel-field", "data-color-picker-part": "channel-field", children: [_jsx("input", { "aria-label": fieldLabel, inputMode: "numeric", value: draft ?? String(value),
|
|
396
448
|
// (Left, or Enter: its value again, e.g. emptied; see
|
|
397
449
|
// `useFieldSelection`.)
|
|
398
450
|
onChange: (event) => type(event.currentTarget.value, event), ...selection }), unit ? _jsx("span", { "aria-hidden": "true", children: unit }) : null] })] })] }));
|
|
@@ -400,9 +452,9 @@ const ChannelRow = ({ fieldLabel, isCheckered = false, label, max, onValueChange
|
|
|
400
452
|
/** Hue (0–360°), saturation and lightness (0–100%). */
|
|
401
453
|
const hsl = {
|
|
402
454
|
channels: [
|
|
403
|
-
{
|
|
404
|
-
{
|
|
405
|
-
{
|
|
455
|
+
{ labelKey: 'hueLabel', max: 360, unit: '°' },
|
|
456
|
+
{ labelKey: 'saturationLabel', max: 100, unit: '%' },
|
|
457
|
+
{ labelKey: 'lightnessLabel', max: 100, unit: '%' },
|
|
406
458
|
],
|
|
407
459
|
from: (color) => {
|
|
408
460
|
const { h, l, s } = toHsl(color);
|
|
@@ -416,10 +468,10 @@ const hsl = {
|
|
|
416
468
|
*/
|
|
417
469
|
const cmyk = {
|
|
418
470
|
channels: [
|
|
419
|
-
{
|
|
420
|
-
{
|
|
421
|
-
{
|
|
422
|
-
{
|
|
471
|
+
{ labelKey: 'cyanLabel', max: 100, unit: '%' },
|
|
472
|
+
{ labelKey: 'magentaLabel', max: 100, unit: '%' },
|
|
473
|
+
{ labelKey: 'yellowLabel', max: 100, unit: '%' },
|
|
474
|
+
{ labelKey: 'blackLabel', max: 100, unit: '%' },
|
|
423
475
|
],
|
|
424
476
|
from: ({ b, g, r }) => {
|
|
425
477
|
const k = 1 - Math.max(r, g, b) / 255;
|
|
@@ -434,9 +486,9 @@ const cmyk = {
|
|
|
434
486
|
/** Red, green and blue (0–255). */
|
|
435
487
|
const rgb = {
|
|
436
488
|
channels: [
|
|
437
|
-
{
|
|
438
|
-
{
|
|
439
|
-
{
|
|
489
|
+
{ labelKey: 'redLabel', max: 255 },
|
|
490
|
+
{ labelKey: 'greenLabel', max: 255 },
|
|
491
|
+
{ labelKey: 'blueLabel', max: 255 },
|
|
440
492
|
],
|
|
441
493
|
from: ({ b, g, r }) => [r, g, b].map((channel) => Math.round(channel)),
|
|
442
494
|
to: ([r = 0, g = 0, b = 0]) => ({ b, g, r }),
|
|
@@ -448,9 +500,9 @@ const rgbKeys = ['r', 'g', 'b'];
|
|
|
448
500
|
*/
|
|
449
501
|
const rgbPercentage = {
|
|
450
502
|
channels: [
|
|
451
|
-
{
|
|
452
|
-
{
|
|
453
|
-
{
|
|
503
|
+
{ labelKey: 'redLabel', max: 100, unit: '%' },
|
|
504
|
+
{ labelKey: 'greenLabel', max: 100, unit: '%' },
|
|
505
|
+
{ labelKey: 'blueLabel', max: 100, unit: '%' },
|
|
454
506
|
],
|
|
455
507
|
from: ({ b, g, r }) => [r, g, b].map((channel) => Math.round((channel / 255) * 100)),
|
|
456
508
|
set: ({ b, g, r }, index, value) => ({
|
|
@@ -489,7 +541,10 @@ const trackColors = (model, color, values, index) => {
|
|
|
489
541
|
* yellow and black), each mixing from the color, its value typed too; then
|
|
490
542
|
* its children (e.g. the `Code`), spaced as the channels.
|
|
491
543
|
*/
|
|
492
|
-
const Sliders = forwardRef((
|
|
544
|
+
const Sliders = forwardRef((allProps, ref) => {
|
|
545
|
+
const labels = useLabels(allProps);
|
|
546
|
+
const { children, className, model: modelName = 'rgb', range = 'byte', ...rest } = allProps;
|
|
547
|
+
const props = omitLabels(rest);
|
|
493
548
|
const { color, setColor } = useContext(PickerContext);
|
|
494
549
|
const model = modelName === 'rgb' && range === 'percentage'
|
|
495
550
|
? rgbPercentage
|
|
@@ -502,7 +557,7 @@ const Sliders = forwardRef(({ children, className, model: modelName = 'rgb', ran
|
|
|
502
557
|
const values = last?.color === opaque && last.model === model
|
|
503
558
|
? last.values
|
|
504
559
|
: model.from(color);
|
|
505
|
-
return (_jsxs("div", { ref: ref, ...props, className: cn('uikit-color-picker-sliders', className), "data-color-picker-part": "sliders", "data-model": modelName, "data-range": modelName === 'rgb' ? range : undefined, children: [model.channels.map(({
|
|
560
|
+
return (_jsxs("div", { ref: ref, ...props, className: cn('uikit-color-picker-sliders', className), "data-color-picker-part": "sliders", "data-model": modelName, "data-range": modelName === 'rgb' ? range : undefined, children: [model.channels.map(({ labelKey, max, unit }, index) => (_jsx(ChannelRow, { fieldLabel: labels.channelValueLabel(labels[labelKey]), label: labels[labelKey], max: max, stops: trackColors(model, color, values, index), thumbColor: opaque, unit: unit, value: values[index] ?? 0, onValueChange: (next, event) => {
|
|
506
561
|
const nextValues = values.with(index, next);
|
|
507
562
|
const nextColor = {
|
|
508
563
|
...withChannel(model, color, values, index, next),
|
|
@@ -514,17 +569,20 @@ const Sliders = forwardRef(({ children, className, model: modelName = 'rgb', ran
|
|
|
514
569
|
values: nextValues,
|
|
515
570
|
});
|
|
516
571
|
setColor(nextColor, { event, reason: 'sliders' });
|
|
517
|
-
} },
|
|
572
|
+
} }, labelKey))), children] }));
|
|
518
573
|
});
|
|
519
574
|
/**
|
|
520
575
|
* The opacity: the color fading in over a checkerboard, in percent; 22px
|
|
521
576
|
* above what follows. Rendered, the color has it (see `Root`): without
|
|
522
577
|
* it, it's opaque.
|
|
523
578
|
*/
|
|
524
|
-
const Opacity = forwardRef((
|
|
579
|
+
const Opacity = forwardRef((allProps, ref) => {
|
|
580
|
+
const { opacityLabel, opacityValueLabel } = useLabels(allProps);
|
|
581
|
+
const { className, ...rest } = allProps;
|
|
582
|
+
const props = omitLabels(rest);
|
|
525
583
|
const { color, registerOpacity, setColor } = useContext(PickerContext);
|
|
526
584
|
useLayoutEffect(registerOpacity, [registerOpacity]);
|
|
527
|
-
return (_jsx("div", { ref: ref, ...props, className: cn('uikit-color-picker-opacity', className), "data-color-picker-part": "opacity", children: _jsx(ChannelRow, { isCheckered: true, fieldLabel:
|
|
585
|
+
return (_jsx("div", { ref: ref, ...props, className: cn('uikit-color-picker-opacity', className), "data-color-picker-part": "opacity", children: _jsx(ChannelRow, { isCheckered: true, fieldLabel: opacityValueLabel, label: opacityLabel, max: 100, thumbColor: formatColor(color), unit: "%", value: Math.round(color.a * 100), stops: [
|
|
528
586
|
formatColor({ ...color, a: 0 }),
|
|
529
587
|
formatColor({ ...color, a: 1 }),
|
|
530
588
|
], onValueChange: (next, event) => setColor({ ...color, a: next / 100 }, { event, reason: 'opacity' }) }) }));
|
|
@@ -536,9 +594,10 @@ const Saved = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: r
|
|
|
536
594
|
const pageSize = 10;
|
|
537
595
|
const SavedSwatch = ({ hex, onDelete }) => {
|
|
538
596
|
const { color, setColor } = useContext(PickerContext);
|
|
597
|
+
const { deleteColorLabel } = useContext(LabelsContext);
|
|
539
598
|
const swatch = parseColor(hex);
|
|
540
599
|
// Its menu (a secondary click: right click, or a long press): delete it.
|
|
541
|
-
return (_jsxs(Menu.Root, { children: [_jsx(Menu.Trigger, { openOn: "secondaryClick", render: _jsx("button", { "aria-label": hex, "aria-pressed": sameColor(swatch, color) && swatch.a === color.a, style: { '--uikit-color-picker-color': hex }, type: "button", onClick: (event) => setColor(swatch, { event, reason: 'saved' }) }) }), _jsx(Menu.Portal, { children: _jsx(Menu.Positioner, { children: _jsx(Menu.Popup, { children: _jsx(Menu.Item, { destructive: true, onClick: (event) => onDelete(event), children: _jsx(Menu.Label, { children:
|
|
600
|
+
return (_jsxs(Menu.Root, { children: [_jsx(Menu.Trigger, { openOn: "secondaryClick", render: _jsx("button", { "aria-label": hex, "aria-pressed": sameColor(swatch, color) && swatch.a === color.a, style: { '--uikit-color-picker-color': hex }, type: "button", onClick: (event) => setColor(swatch, { event, reason: 'saved' }) }) }), _jsx(Menu.Portal, { children: _jsx(Menu.Positioner, { children: _jsx(Menu.Popup, { children: _jsx(Menu.Item, { destructive: true, onClick: (event) => onDelete(event), children: _jsx(Menu.Label, { children: deleteColorLabel }) }) }) }) })] }));
|
|
542
601
|
};
|
|
543
602
|
/** A color laid over an opaque one (`on`): its mix, opaque. */
|
|
544
603
|
const flattened = (color, on) => {
|
|
@@ -552,10 +611,11 @@ const flattened = (color, on) => {
|
|
|
552
611
|
*/
|
|
553
612
|
const FlattenCurrent = () => {
|
|
554
613
|
const { color, setColor } = useContext(PickerContext);
|
|
614
|
+
const { flattenColorLabel, flattenColorTitleLabel, flattenOnBlackLabel, flattenOnWhiteLabel, removeTransparencyLabel, } = useContext(LabelsContext);
|
|
555
615
|
// (Pressed, its button: gone once the color's opaque.)
|
|
556
616
|
const triggerRef = useRef(null);
|
|
557
617
|
const choose = (next) => (event) => setColor(next, { event, reason: 'flatten' });
|
|
558
|
-
return (_jsxs(ActionSheet.Root, { children: [_jsx(ActionSheet.Trigger, { render: _jsx("button", { ref: triggerRef, "aria-label":
|
|
618
|
+
return (_jsxs(ActionSheet.Root, { children: [_jsx(ActionSheet.Trigger, { render: _jsx("button", { ref: triggerRef, "aria-label": flattenColorLabel, className: "uikit-color-picker-current", "data-color-picker-part": "current", type: "button" }) }), _jsxs(ActionSheet.Popup, { finalFocus: () => triggerRef.current?.isConnected === true, children: [_jsx(ActionSheet.Header, { children: _jsx(ActionSheet.Title, { children: flattenColorTitleLabel }) }), _jsxs(ActionSheet.Actions, { children: [_jsx(ActionSheet.Action, { onClick: choose({ ...color, a: 1 }), children: removeTransparencyLabel }), _jsx(ActionSheet.Action, { onClick: choose(flattened(color, 255)), children: flattenOnWhiteLabel }), _jsx(ActionSheet.Action, { onClick: choose(flattened(color, 0)), children: flattenOnBlackLabel })] })] })] }));
|
|
559
619
|
};
|
|
560
620
|
/**
|
|
561
621
|
* The color (82px, 18px corners; translucent, over black and white) beside
|
|
@@ -563,7 +623,11 @@ const FlattenCurrent = () => {
|
|
|
563
623
|
* them, deleting one by its menu). Translucent, pressed: offering it opaque
|
|
564
624
|
* (`flattenOnPress`, see `FlattenCurrent`).
|
|
565
625
|
*/
|
|
566
|
-
const Swatches = forwardRef((
|
|
626
|
+
const Swatches = forwardRef((allProps, ref) => {
|
|
627
|
+
// (Its words, for its saved colors' menus and its action sheet too.)
|
|
628
|
+
const labels = useLabels(allProps);
|
|
629
|
+
const { className, defaultSavedColors: initialSaved = defaultSavedColors, flattenOnPress = true, onSavedColorsChange, savedColors: savedProp, ...rest } = allProps;
|
|
630
|
+
const props = omitLabels(rest);
|
|
567
631
|
const { color } = useContext(PickerContext);
|
|
568
632
|
const [ownSaved, setOwnSaved] = useState(initialSaved);
|
|
569
633
|
const saved = savedProp ?? ownSaved;
|
|
@@ -599,7 +663,7 @@ const Swatches = forwardRef(({ className, defaultSavedColors: initialSaved = def
|
|
|
599
663
|
return undefined;
|
|
600
664
|
const isRightToLeft = getComputedStyle(element).direction === 'rtl';
|
|
601
665
|
element.scrollTo({
|
|
602
|
-
behavior:
|
|
666
|
+
behavior: smoothScrollOf(element),
|
|
603
667
|
left: (isRightToLeft ? -1 : 1) * scrollTarget * element.clientWidth,
|
|
604
668
|
});
|
|
605
669
|
// (Swipes count again once it's there.)
|
|
@@ -615,21 +679,21 @@ const Swatches = forwardRef(({ className, defaultSavedColors: initialSaved = def
|
|
|
615
679
|
setPage(next);
|
|
616
680
|
setScrollTarget(next);
|
|
617
681
|
};
|
|
618
|
-
return (_jsxs("div", { ref: ref, ...props, className: cn('uikit-color-picker-swatches', className), "data-color-picker-part": "swatches", children: [flattenOnPress && color.a < 1 ? (_jsx(FlattenCurrent, {})) : (_jsx("div", { "aria-hidden": "true", className: "uikit-color-picker-current", "data-color-picker-part": "current" })), _jsxs("div", { className: "uikit-color-picker-saved-column", "data-color-picker-part": "saved-column", children: [_jsx("div", { ref: pagesRef, "aria-label":
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
682
|
+
return (_jsx(LabelsContext.Provider, { value: labels, children: _jsxs("div", { ref: ref, ...props, className: cn('uikit-color-picker-swatches', className), "data-color-picker-part": "swatches", children: [flattenOnPress && color.a < 1 ? (_jsx(FlattenCurrent, {})) : (_jsx("div", { "aria-hidden": "true", className: "uikit-color-picker-current", "data-color-picker-part": "current" })), _jsxs("div", { className: "uikit-color-picker-saved-column", "data-color-picker-part": "saved-column", children: [_jsx("div", { ref: pagesRef, "aria-label": labels.savedColorsLabel, className: "uikit-color-picker-saved-pages", "data-color-picker-part": "saved-pages", role: "group", onScroll: handleScroll, children: Array.from({ length: pages }, (_, index) => (_jsx(Saved, {
|
|
683
|
+
// (Only the page shown can be reached.)
|
|
684
|
+
inert: index !== shownPage, children: items
|
|
685
|
+
.slice(index * pageSize, (index + 1) * pageSize)
|
|
686
|
+
.map((hex) => hex === undefined ? (_jsx("button", { "aria-label": labels.addColorLabel, "data-add": "", type: "button", onClick: (event) => {
|
|
687
|
+
const next = formatColor(color);
|
|
688
|
+
if (saved.includes(next))
|
|
689
|
+
return;
|
|
690
|
+
changeSaved([...saved, next], {
|
|
691
|
+
event,
|
|
692
|
+
reason: 'add',
|
|
693
|
+
});
|
|
694
|
+
// On the page it lands on.
|
|
695
|
+
goTo(Math.floor(saved.length / pageSize));
|
|
696
|
+
}, children: "+" }, "add")) : (_jsx(SavedSwatch, { hex: hex, onDelete: (event) => changeSaved(saved.filter((other) => other !== hex), { event, reason: 'delete' }) }, hex))) }, index))) }), pages > 1 ? (_jsx(PageControl, { count: pages, value: shownPage, variant: "plain", onValueChange: goTo })) : null] })] }) }));
|
|
633
697
|
});
|
|
634
698
|
/** The browser's eyedropper (`EyeDropper`), if it has one. */
|
|
635
699
|
const eyeDropper = () => globalThis.EyeDropper;
|
|
@@ -640,6 +704,7 @@ const eyeDropper = () => globalThis.EyeDropper;
|
|
|
640
704
|
*/
|
|
641
705
|
const Eyedropper = ({ render, ...props }) => {
|
|
642
706
|
const { color, setColor } = useContext(PickerContext);
|
|
707
|
+
const { eyedropperLabel } = useContext(LabelsContext);
|
|
643
708
|
const Picker = eyeDropper();
|
|
644
709
|
if (!Picker)
|
|
645
710
|
return null;
|
|
@@ -650,10 +715,10 @@ const Eyedropper = ({ render, ...props }) => {
|
|
|
650
715
|
.catch(() => undefined);
|
|
651
716
|
};
|
|
652
717
|
return render ? (cloneElement(render, {
|
|
653
|
-
'aria-label':
|
|
718
|
+
'aria-label': eyedropperLabel,
|
|
654
719
|
...props,
|
|
655
720
|
onClick: pick,
|
|
656
|
-
})) : (_jsx(Button.Root, { "aria-label":
|
|
721
|
+
})) : (_jsx(Button.Root, { "aria-label": eyedropperLabel, ...props, onClick: pick }));
|
|
657
722
|
};
|
|
658
723
|
/** Whether the browser has a color input (its picker the system's). */
|
|
659
724
|
const hasColorInput = () => {
|
|
@@ -692,6 +757,7 @@ const setAlpha = (input, hasAlpha, value) => {
|
|
|
692
757
|
*/
|
|
693
758
|
const SystemColors = ({ render, ...props }) => {
|
|
694
759
|
const { color, hasOpacity, setColor } = useContext(PickerContext);
|
|
760
|
+
const { systemColorsLabel } = useContext(LabelsContext);
|
|
695
761
|
// (Its input, as rendered: for its button's press.)
|
|
696
762
|
const [input, setInput] = useState(null);
|
|
697
763
|
// (With the opacity, the input's alpha too, where it has one.)
|
|
@@ -706,10 +772,10 @@ const SystemColors = ({ render, ...props }) => {
|
|
|
706
772
|
return null;
|
|
707
773
|
const open = () => input?.click();
|
|
708
774
|
return (_jsxs("span", { className: "uikit-color-picker-system-colors", "data-color-picker-part": "system-colors", children: [render ? (cloneElement(render, {
|
|
709
|
-
'aria-label':
|
|
775
|
+
'aria-label': systemColorsLabel,
|
|
710
776
|
...props,
|
|
711
777
|
onClick: open,
|
|
712
|
-
})) : (_jsx(Button.Root, { "aria-label":
|
|
778
|
+
})) : (_jsx(Button.Root, { "aria-label": systemColorsLabel, ...props, onClick: open })), _jsx("input", { ref: setInput, "aria-hidden": "true", className: "uikit-color-picker-system-colors-input", disabled: props.disabled, tabIndex: -1, type: "color", value: value,
|
|
713
779
|
// (As it's picked, live; without its alpha, the opacity kept.)
|
|
714
780
|
onChange: (event) => {
|
|
715
781
|
// (Any CSS color, with an alpha: see color.ts.)
|
|
@@ -735,7 +801,10 @@ const noSpellcheck = (input) => {
|
|
|
735
801
|
* a code, 3, 4, 6 or 8 of them; with an alpha, 4 or 8), at its end. Kept above the keyboard as it's typed into (as a
|
|
736
802
|
* channel's row).
|
|
737
803
|
*/
|
|
738
|
-
const Code = forwardRef((
|
|
804
|
+
const Code = forwardRef((allProps, ref) => {
|
|
805
|
+
const { hexLabel } = useLabels(allProps);
|
|
806
|
+
const { children, className, ...rest } = allProps;
|
|
807
|
+
const props = omitLabels(rest);
|
|
739
808
|
const { color, setColor } = useContext(PickerContext);
|
|
740
809
|
const [draft, setDraft] = useState(undefined);
|
|
741
810
|
const selection = useFieldSelection(() => setDraft(undefined));
|
|
@@ -754,10 +823,10 @@ const Code = forwardRef(({ children, className, ...props }, ref) => {
|
|
|
754
823
|
reason: 'code',
|
|
755
824
|
});
|
|
756
825
|
};
|
|
757
|
-
return (_jsx(Viewport.KeyboardAccessory, { ref: ref, gap: 20, ...props, className: cn('uikit-color-picker-code', className), "data-color-picker-part": "code", children: _jsxs("div", { className: "uikit-color-picker-channel-row uikit-color-picker-code-row", "data-color-picker-part": "code-row", children: [_jsx("div", { "aria-hidden": "true", className: "uikit-color-picker-channel-title", "data-color-picker-part": "code-title", children:
|
|
826
|
+
return (_jsx(Viewport.KeyboardAccessory, { ref: ref, gap: 20, ...props, className: cn('uikit-color-picker-code', className), "data-color-picker-part": "code", children: _jsxs("div", { className: "uikit-color-picker-channel-row uikit-color-picker-code-row", "data-color-picker-part": "code-row", children: [_jsx("div", { "aria-hidden": "true", className: "uikit-color-picker-channel-title", "data-color-picker-part": "code-title", children: hexLabel }), children, _jsxs("label", { className: "uikit-color-picker-channel-field uikit-color-picker-code-field", "data-color-picker-part": "code-field", children: [_jsx("span", { "aria-hidden": "true", children: "#" }), _jsx("input", {
|
|
758
827
|
// (As a property: spelled differently in React's and Preact's
|
|
759
828
|
// JSX.)
|
|
760
|
-
ref: noSpellcheck, value: draft ?? formatColor(color).slice(1), onChange: (event) => type(event.currentTarget.value, event), ...selection })] })] }) }));
|
|
829
|
+
ref: noSpellcheck, "aria-label": hexLabel, value: draft ?? formatColor(color).slice(1), onChange: (event) => type(event.currentTarget.value, event), ...selection })] })] }) }));
|
|
761
830
|
});
|
|
762
831
|
/** A color well: its color, opening the picker. */
|
|
763
832
|
const Well = forwardRef(({ className, color, size = 'small', style, ...props }, ref) => (_jsx("button", { ref: ref, "aria-label": "Color", "data-color": color === undefined ? undefined : '', "data-size": size, style: withStyle({ '--uikit-color-picker-well-color': color }, style), type: "button", ...props, className: cn('uikit-color-picker-well', className), "data-color-picker-part": "well" })));
|
|
@@ -771,7 +840,10 @@ const copiedFor = 1500;
|
|
|
771
840
|
* clipboard (`onCodeCopy`); for a moment, a checkmark instead of its content
|
|
772
841
|
* (`data-copied`). Its place the app's (in a `Code`, or not).
|
|
773
842
|
*/
|
|
774
|
-
const CodeCopy = (
|
|
843
|
+
const CodeCopy = (allProps) => {
|
|
844
|
+
const labels = useLabels(allProps);
|
|
845
|
+
const { children, onCodeCopy, render, ...rest } = allProps;
|
|
846
|
+
const props = omitLabels(rest);
|
|
775
847
|
const { color } = useContext(PickerContext);
|
|
776
848
|
const [isCopied, setIsCopied] = useState(false);
|
|
777
849
|
useEffect(() => {
|
|
@@ -793,11 +865,11 @@ const CodeCopy = ({ children, onCodeCopy, render, ...props }) => {
|
|
|
793
865
|
const item = ({ code, label, subtitle, well }) => (_jsxs(Menu.Item, { onClick: (event) => copy(code, event), children: [_jsx(Menu.Label, { children: label }), _jsx(Menu.Subtitle, { children: subtitle }), well === undefined ? null : (_jsx(Well, { inert: true, "aria-hidden": "true", className: "uikit-color-picker-code-copy-well", color: well, tabIndex: -1 }))] }, code));
|
|
794
866
|
const content = isCopied ? (_jsx(Button.Icon, { children: _jsx(Checkmark, {}) })) : (children);
|
|
795
867
|
const trigger = render ? (cloneElement(render, {
|
|
796
|
-
'aria-label':
|
|
868
|
+
'aria-label': labels.copyColorCodeLabel,
|
|
797
869
|
...props,
|
|
798
870
|
'data-copied': isCopied ? '' : undefined,
|
|
799
|
-
}, content)) : (_jsx(Button.Root, { "aria-label":
|
|
800
|
-
return (_jsxs(Menu.Root, { children: [_jsx(Menu.Trigger, { render: trigger }), _jsx(Menu.Portal, { children: _jsx(Menu.Positioner, { children: _jsx(Menu.Popup, { children: codeGroups(color, formatColor({ ...color, a: 1 })).map(([title, codes], index) => index === 0 ? (_jsx(Fragment, { children: codes.map((entry) => item(entry)) }, title)) : (_jsxs(Menu.SubmenuRoot, { children: [_jsx(Menu.SubmenuTrigger, { children: _jsx(Menu.Label, { children: title }) }), _jsx(Menu.Portal, { children: _jsx(Menu.Positioner, { children: _jsx(Menu.Popup, { children: codes.map((entry) => item(entry)) }) }) })] }, title))) }) }) })] }));
|
|
871
|
+
}, content)) : (_jsx(Button.Root, { "aria-label": labels.copyColorCodeLabel, ...props, "data-copied": isCopied ? '' : undefined, children: content }));
|
|
872
|
+
return (_jsxs(Menu.Root, { children: [_jsx(Menu.Trigger, { render: trigger }), _jsx(Menu.Portal, { children: _jsx(Menu.Positioner, { children: _jsx(Menu.Popup, { children: codeGroups(color, formatColor({ ...color, a: 1 }), labels).map(([title, codes], index) => index === 0 ? (_jsx(Fragment, { children: codes.map((entry) => item(entry)) }, title)) : (_jsxs(Menu.SubmenuRoot, { children: [_jsx(Menu.SubmenuTrigger, { children: _jsx(Menu.Label, { children: title }) }), _jsx(Menu.Portal, { children: _jsx(Menu.Positioner, { children: _jsx(Menu.Popup, { children: codes.map((entry) => item(entry)) }) }) })] }, title))) }) }) })] }));
|
|
801
873
|
};
|
|
802
874
|
/**
|
|
803
875
|
* Its named colors' rows (see `Named`): one registered (its label's first
|
|
@@ -813,17 +885,6 @@ const scrollerOf = (element) => {
|
|
|
813
885
|
}
|
|
814
886
|
return document.scrollingElement ?? document.documentElement;
|
|
815
887
|
};
|
|
816
|
-
/** A row at the top of its scroll container (below its scroll padding). */
|
|
817
|
-
const jumpTo = (element) => {
|
|
818
|
-
const scroller = scrollerOf(element);
|
|
819
|
-
const padding = Number.parseFloat(getComputedStyle(scroller).scrollPaddingBlockStart) || 0;
|
|
820
|
-
const top = scroller === document.scrollingElement
|
|
821
|
-
? 0
|
|
822
|
-
: scroller.getBoundingClientRect().top;
|
|
823
|
-
scroller.scrollTo({
|
|
824
|
-
top: scroller.scrollTop + element.getBoundingClientRect().top - top - padding,
|
|
825
|
-
});
|
|
826
|
-
};
|
|
827
888
|
/**
|
|
828
889
|
* A row in view (between its scroll container's scroll paddings: e.g. a
|
|
829
890
|
* sheet's header), at once: already, it stays; else, centered there.
|
|
@@ -855,7 +916,10 @@ const revealCentered = (element) => {
|
|
|
855
916
|
* at the top (below the container's scroll padding: e.g. a sheet's header).
|
|
856
917
|
* Shown, the color's row in view at once (see `revealCentered`).
|
|
857
918
|
*/
|
|
858
|
-
const Named = forwardRef((
|
|
919
|
+
const Named = forwardRef((allProps, forwardedRef) => {
|
|
920
|
+
const { indexLabel } = useLabels(allProps);
|
|
921
|
+
const { children, className, ...rest } = allProps;
|
|
922
|
+
const props = omitLabels(rest);
|
|
859
923
|
const ref = useForwardedRef(forwardedRef);
|
|
860
924
|
// Shown (e.g. its mode chosen): the color's row in view, at once.
|
|
861
925
|
useLayoutEffect(() => {
|
|
@@ -873,16 +937,10 @@ const Named = forwardRef(({ children, className, ...props }, forwardedRef) => {
|
|
|
873
937
|
: 1));
|
|
874
938
|
return () => setEntries((current) => current.filter((other) => other !== entry));
|
|
875
939
|
}, []);
|
|
876
|
-
//
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
if (!first.has(label))
|
|
881
|
-
first.set(label, element);
|
|
882
|
-
}
|
|
883
|
-
return [...first];
|
|
884
|
-
}, [entries]);
|
|
885
|
-
return (_jsx(NamedContext.Provider, { value: register, children: _jsxs("div", { ref: ref, ...props, className: cn('uikit-color-picker-named', className), "data-color-picker-part": "named", children: [_jsx(List.Root, { listStyle: "insetGrouped", children: _jsx(List.Section, { children: _jsx(List.Group, { children: children }) }) }), letters.length > 0 ? (_jsx("div", { className: "uikit-color-picker-named-index", "data-color-picker-part": "named-index", children: _jsx(List.Index, { "aria-label": "Index", children: letters.map(([letter, element]) => (_jsx(List.IndexItem, { onClick: () => jumpTo(element), children: letter }, letter))) }) })) : null] }) }));
|
|
940
|
+
// Its rows' letters, in order (each row its letter's index value, the
|
|
941
|
+
// first jumped to, see List.Index).
|
|
942
|
+
const letters = useMemo(() => [...new Set(entries.map(({ label }) => label))], [entries]);
|
|
943
|
+
return (_jsx(NamedContext.Provider, { value: register, children: _jsx("div", { ref: ref, ...props, className: cn('uikit-color-picker-named', className), "data-color-picker-part": "named", children: _jsxs(List.Root, { listStyle: "insetGrouped", children: [_jsx(List.Section, { children: _jsx(List.Group, { children: children }) }), letters.length > 0 ? (_jsx(List.Index, { "aria-label": indexLabel, "data-color-picker-part": "named-index", children: letters.map((letter) => (_jsx(List.IndexItem, { children: letter }, letter))) })) : null] }) }) }));
|
|
886
944
|
});
|
|
887
945
|
/**
|
|
888
946
|
* A named color's row (in a `Named`): its color in a well (inert), its label
|
|
@@ -903,7 +961,7 @@ const NamedColor = forwardRef(({ children, color: cssColor, ...props }, forwarde
|
|
|
903
961
|
const { current: element } = ref;
|
|
904
962
|
return element ? register({ element, label: letter }) : undefined;
|
|
905
963
|
}, [letter, ref, register]);
|
|
906
|
-
return (_jsxs(List.Item, { ref: ref, ...props, "data-color-picker-part": "named-color", "data-picked": isPicked ? '' : undefined, children: [_jsx(List.Leading, { children: _jsx(Well, { inert: true, "aria-hidden": "true", color: cssColor, tabIndex: -1 }) }), _jsx(List.Content, { children: _jsx(List.Title, { "aria-pressed": isPicked, render: _jsx("button", { type: "button" }), onClick: (event) => {
|
|
964
|
+
return (_jsxs(List.Item, { ref: ref, ...props, "data-color-picker-part": "named-color", "data-picked": isPicked ? '' : undefined, indexValue: letter, children: [_jsx(List.Leading, { children: _jsx(Well, { inert: true, "aria-hidden": "true", color: cssColor, tabIndex: -1 }) }), _jsx(List.Content, { children: _jsx(List.Title, { "aria-pressed": isPicked, render: _jsx("button", { type: "button" }), onClick: (event) => {
|
|
907
965
|
if (!named)
|
|
908
966
|
return;
|
|
909
967
|
setColor({ ...named, a: color.a }, { event, reason: 'named' });
|