@widgetic/design-system 0.5.34 → 0.5.35
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.
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
maxSwatches?: number;
|
|
39
39
|
/** Shows the hex field and the button; off for a picker that only changes `value`. */
|
|
40
40
|
showConfirm?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Shows the Add button next to the hex field. Off for a picker whose caller saves when it closes: Enter in the hex field
|
|
43
|
+
* still calls `onConfirm`, so a typed colour can be taken at once.
|
|
44
|
+
*/
|
|
45
|
+
showConfirmButton?: boolean;
|
|
41
46
|
/** Called with `#RRGGBB` when Add is pressed, or Enter in the hex field. */
|
|
42
47
|
onConfirm?: (hex: string) => void;
|
|
43
48
|
/** Called with `#RRGGBB` every time the colour changes, while the person drags or types. */
|
|
@@ -87,6 +92,7 @@
|
|
|
87
92
|
swatches = [],
|
|
88
93
|
maxSwatches = 5,
|
|
89
94
|
showConfirm = true,
|
|
95
|
+
showConfirmButton = true,
|
|
90
96
|
onConfirm,
|
|
91
97
|
onChange,
|
|
92
98
|
onInput,
|
|
@@ -322,7 +328,9 @@
|
|
|
322
328
|
onblur={handleHexBlur}
|
|
323
329
|
onkeydown={handleHexKeydown}
|
|
324
330
|
/>
|
|
325
|
-
|
|
331
|
+
{#if showConfirmButton}
|
|
332
|
+
<Button type="button" size="sm" disabled={typedHex === null} onclick={confirm}>{messages.add}</Button>
|
|
333
|
+
{/if}
|
|
326
334
|
</div>
|
|
327
335
|
{/if}
|
|
328
336
|
</div>
|
|
@@ -23,6 +23,11 @@ export type ColorPickerProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'>
|
|
|
23
23
|
maxSwatches?: number;
|
|
24
24
|
/** Shows the hex field and the button; off for a picker that only changes `value`. */
|
|
25
25
|
showConfirm?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Shows the Add button next to the hex field. Off for a picker whose caller saves when it closes: Enter in the hex field
|
|
28
|
+
* still calls `onConfirm`, so a typed colour can be taken at once.
|
|
29
|
+
*/
|
|
30
|
+
showConfirmButton?: boolean;
|
|
26
31
|
/** Called with `#RRGGBB` when Add is pressed, or Enter in the hex field. */
|
|
27
32
|
onConfirm?: (hex: string) => void;
|
|
28
33
|
/** Called with `#RRGGBB` every time the colour changes, while the person drags or types. */
|
|
@@ -110,12 +110,11 @@
|
|
|
110
110
|
);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
// Parent keeps pe-8 (32px)
|
|
114
|
-
//
|
|
115
|
-
// pe-8 line and the bar is centred in the leftover space between the cards and the dialog edge.
|
|
113
|
+
// Parent keeps pe-8 (32px): the cards of a page end on that line. When the page scrolls we pull the scroll area into that
|
|
114
|
+
// padding, so the bar is drawn in the margin right of the cards, close to the dialog edge, and never over a card.
|
|
116
115
|
const PANE_RIGHT_PADDING_PX = 32;
|
|
117
|
-
/**
|
|
118
|
-
const
|
|
116
|
+
/** How far the bar sits from the dialog's edge (the border is outside it). */
|
|
117
|
+
const SCROLLBAR_EDGE_GAP_PX = 2;
|
|
119
118
|
let paneScrollStyle = $state('');
|
|
120
119
|
|
|
121
120
|
function overlayScrollbar(node: HTMLElement) {
|
|
@@ -125,16 +124,15 @@
|
|
|
125
124
|
paneScrollStyle = '';
|
|
126
125
|
return;
|
|
127
126
|
}
|
|
128
|
-
//
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
);
|
|
134
|
-
const pull = PANE_RIGHT_PADDING_PX - outerGap;
|
|
127
|
+
// A classic bar takes room inside the box (offsetWidth - clientWidth); an overlay bar (macOS with "show scroll bars
|
|
128
|
+
// when scrolling") takes none and is drawn over the padding. Either way the padding that follows the bar is what is
|
|
129
|
+
// left of the pull, so the content keeps ending on the pe-8 line and the bar never covers it.
|
|
130
|
+
const barLayoutWidth = Math.max(node.offsetWidth - node.clientWidth, 0);
|
|
131
|
+
const pull = PANE_RIGHT_PADDING_PX - SCROLLBAR_EDGE_GAP_PX;
|
|
132
|
+
const contentGap = Math.max(pull - barLayoutWidth, 0);
|
|
135
133
|
// End side, not the right: the bar sits at the inline end of the page, so a dialog read right to left mirrors it
|
|
136
134
|
// (tests/rtl/sourcePlacement.test.ts fails on a physical side). Left to right, this is margin-right/padding-right.
|
|
137
|
-
paneScrollStyle = `margin-inline-end: -${pull}px; padding-inline-end: ${
|
|
135
|
+
paneScrollStyle = `margin-inline-end: -${pull}px; padding-inline-end: ${contentGap}px`;
|
|
138
136
|
}
|
|
139
137
|
const resizeObserver = new ResizeObserver(check);
|
|
140
138
|
resizeObserver.observe(node);
|