@knitui/components 0.9.0 → 0.11.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/lib/commonjs/ActionIcon/ActionIcon.js +4 -2
- package/lib/commonjs/ActionIcon/ActionIcon.js.map +1 -1
- package/lib/commonjs/Affix/Affix.js +3 -1
- package/lib/commonjs/Affix/Affix.js.map +1 -1
- package/lib/commonjs/Button/Button.js +38 -3
- package/lib/commonjs/Button/Button.js.map +1 -1
- package/lib/commonjs/CloseButton/CloseButton.js +7 -0
- package/lib/commonjs/CloseButton/CloseButton.js.map +1 -1
- package/lib/commonjs/Modal/modal-base.js +4 -2
- package/lib/commonjs/Modal/modal-base.js.map +1 -1
- package/lib/commonjs/Pill/Pill.js +1 -1
- package/lib/commonjs/Popover/Popover.shared.js +3 -1
- package/lib/commonjs/Popover/Popover.shared.js.map +1 -1
- package/lib/commonjs/Portal/OverlayHost.js +147 -0
- package/lib/commonjs/Portal/OverlayHost.js.map +1 -0
- package/lib/commonjs/Portal/index.js +25 -0
- package/lib/commonjs/Portal/index.js.map +1 -1
- package/lib/commonjs/ScrollArea/ScrollArea.js +5 -0
- package/lib/commonjs/ScrollArea/ScrollArea.js.map +1 -1
- package/lib/commonjs/ScrollArea/ScrollArea.native.js +32 -0
- package/lib/commonjs/ScrollArea/ScrollArea.native.js.map +1 -1
- package/lib/commonjs/ScrollArea/ScrollArea.shared.js.map +1 -1
- package/lib/commonjs/SegmentedControl/SegmentedControl.js +7 -1
- package/lib/commonjs/SegmentedControl/SegmentedControl.js.map +1 -1
- package/lib/commonjs/Tabs/Tabs.js +8 -1
- package/lib/commonjs/Tabs/Tabs.js.map +1 -1
- package/lib/commonjs/Tooltip/Tooltip.js +3 -1
- package/lib/commonjs/Tooltip/Tooltip.js.map +1 -1
- package/lib/commonjs/VirtualList/VirtualList.js +7 -1
- package/lib/commonjs/VirtualList/VirtualList.js.map +1 -1
- package/lib/commonjs/VirtualList/VirtualList.shared.js.map +1 -1
- package/lib/commonjs/floating/platform.js +4 -1
- package/lib/commonjs/floating/platform.js.map +1 -1
- package/lib/commonjs/floating/platform.native.js +15 -5
- package/lib/commonjs/floating/platform.native.js.map +1 -1
- package/lib/commonjs/floating/use-position.js +9 -3
- package/lib/commonjs/floating/use-position.js.map +1 -1
- package/lib/commonjs/index.js +24 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal/control-icon-size.js +5 -1
- package/lib/commonjs/internal/control-icon-size.js.map +1 -1
- package/lib/commonjs/internal/control-metrics.js +13 -9
- package/lib/commonjs/internal/control-metrics.js.map +1 -1
- package/lib/commonjs/internal/style-props.js +36 -6
- package/lib/commonjs/internal/style-props.js.map +1 -1
- package/lib/module/ActionIcon/ActionIcon.js +5 -3
- package/lib/module/ActionIcon/ActionIcon.js.map +1 -1
- package/lib/module/Affix/Affix.js +4 -2
- package/lib/module/Affix/Affix.js.map +1 -1
- package/lib/module/Button/Button.js +40 -5
- package/lib/module/Button/Button.js.map +1 -1
- package/lib/module/CloseButton/CloseButton.js +8 -1
- package/lib/module/CloseButton/CloseButton.js.map +1 -1
- package/lib/module/Modal/modal-base.js +5 -3
- package/lib/module/Modal/modal-base.js.map +1 -1
- package/lib/module/Pill/Pill.js +1 -1
- package/lib/module/Popover/Popover.shared.js +4 -2
- package/lib/module/Popover/Popover.shared.js.map +1 -1
- package/lib/module/Portal/OverlayHost.js +138 -0
- package/lib/module/Portal/OverlayHost.js.map +1 -0
- package/lib/module/Portal/index.js +5 -0
- package/lib/module/Portal/index.js.map +1 -1
- package/lib/module/ScrollArea/ScrollArea.js +5 -0
- package/lib/module/ScrollArea/ScrollArea.js.map +1 -1
- package/lib/module/ScrollArea/ScrollArea.native.js +33 -1
- package/lib/module/ScrollArea/ScrollArea.native.js.map +1 -1
- package/lib/module/ScrollArea/ScrollArea.shared.js.map +1 -1
- package/lib/module/SegmentedControl/SegmentedControl.js +9 -3
- package/lib/module/SegmentedControl/SegmentedControl.js.map +1 -1
- package/lib/module/Tabs/Tabs.js +9 -2
- package/lib/module/Tabs/Tabs.js.map +1 -1
- package/lib/module/Tooltip/Tooltip.js +4 -2
- package/lib/module/Tooltip/Tooltip.js.map +1 -1
- package/lib/module/VirtualList/VirtualList.js +7 -1
- package/lib/module/VirtualList/VirtualList.js.map +1 -1
- package/lib/module/VirtualList/VirtualList.shared.js.map +1 -1
- package/lib/module/floating/platform.js +4 -1
- package/lib/module/floating/platform.js.map +1 -1
- package/lib/module/floating/platform.native.js +15 -5
- package/lib/module/floating/platform.native.js.map +1 -1
- package/lib/module/floating/use-position.js +9 -3
- package/lib/module/floating/use-position.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal/control-icon-size.js +5 -1
- package/lib/module/internal/control-icon-size.js.map +1 -1
- package/lib/module/internal/control-metrics.js +13 -9
- package/lib/module/internal/control-metrics.js.map +1 -1
- package/lib/module/internal/style-props.js +33 -4
- package/lib/module/internal/style-props.js.map +1 -1
- package/lib/typescript/ActionIcon/ActionIcon.d.ts +5 -0
- package/lib/typescript/ActionIcon/ActionIcon.d.ts.map +1 -1
- package/lib/typescript/Affix/Affix.d.ts.map +1 -1
- package/lib/typescript/Button/Button.d.ts +6 -0
- package/lib/typescript/Button/Button.d.ts.map +1 -1
- package/lib/typescript/CloseButton/CloseButton.d.ts.map +1 -1
- package/lib/typescript/Input/shared.d.ts +3 -3
- package/lib/typescript/Modal/modal-base.d.ts.map +1 -1
- package/lib/typescript/Popover/Popover.shared.d.ts.map +1 -1
- package/lib/typescript/Portal/OverlayHost.d.ts +46 -0
- package/lib/typescript/Portal/OverlayHost.d.ts.map +1 -0
- package/lib/typescript/Portal/index.d.ts +6 -1
- package/lib/typescript/Portal/index.d.ts.map +1 -1
- package/lib/typescript/Portal/types.d.ts +10 -0
- package/lib/typescript/Portal/types.d.ts.map +1 -1
- package/lib/typescript/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/lib/typescript/ScrollArea/ScrollArea.native.d.ts.map +1 -1
- package/lib/typescript/ScrollArea/ScrollArea.shared.d.ts +20 -0
- package/lib/typescript/ScrollArea/ScrollArea.shared.d.ts.map +1 -1
- package/lib/typescript/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/lib/typescript/Tabs/Tabs.d.ts.map +1 -1
- package/lib/typescript/Tooltip/Tooltip.d.ts.map +1 -1
- package/lib/typescript/VirtualList/VirtualList.d.ts.map +1 -1
- package/lib/typescript/VirtualList/VirtualList.shared.d.ts +9 -0
- package/lib/typescript/VirtualList/VirtualList.shared.d.ts.map +1 -1
- package/lib/typescript/floating/platform.d.ts +1 -1
- package/lib/typescript/floating/platform.d.ts.map +1 -1
- package/lib/typescript/floating/platform.native.d.ts +7 -1
- package/lib/typescript/floating/platform.native.d.ts.map +1 -1
- package/lib/typescript/floating/use-position.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/internal/control-icon-size.d.ts.map +1 -1
- package/lib/typescript/internal/control-metrics.d.ts +13 -9
- package/lib/typescript/internal/control-metrics.d.ts.map +1 -1
- package/lib/typescript/internal/style-props.d.ts +23 -4
- package/lib/typescript/internal/style-props.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/ActionIcon/ActionIcon.tsx +10 -3
- package/src/Affix/Affix.tsx +4 -2
- package/src/Button/Button.tsx +69 -19
- package/src/CloseButton/CloseButton.tsx +7 -1
- package/src/Modal/modal-base.tsx +5 -3
- package/src/Pill/Pill.tsx +1 -1
- package/src/Popover/Popover.shared.tsx +4 -2
- package/src/Portal/OverlayHost.tsx +141 -0
- package/src/Portal/index.ts +11 -1
- package/src/Portal/types.ts +11 -0
- package/src/ScrollArea/ScrollArea.native.tsx +33 -2
- package/src/ScrollArea/ScrollArea.shared.ts +23 -0
- package/src/ScrollArea/ScrollArea.tsx +5 -0
- package/src/SegmentedControl/SegmentedControl.tsx +8 -2
- package/src/Tabs/Tabs.tsx +9 -1
- package/src/Tooltip/Tooltip.tsx +4 -2
- package/src/VirtualList/VirtualList.shared.ts +12 -0
- package/src/VirtualList/VirtualList.tsx +6 -0
- package/src/floating/platform.native.ts +13 -4
- package/src/floating/platform.ts +3 -0
- package/src/floating/use-position.tsx +13 -3
- package/src/index.ts +5 -0
- package/src/internal/control-icon-size.ts +5 -1
- package/src/internal/control-metrics.ts +13 -9
- package/src/internal/style-props.ts +32 -4
package/src/index.ts
CHANGED
|
@@ -393,13 +393,18 @@ export {
|
|
|
393
393
|
type PopoverWidth,
|
|
394
394
|
} from "./Popover";
|
|
395
395
|
export {
|
|
396
|
+
OverlayHost,
|
|
397
|
+
type OverlayHostProps,
|
|
396
398
|
Portal,
|
|
397
399
|
PortalHost,
|
|
398
400
|
type PortalHostProps,
|
|
399
401
|
type PortalProps,
|
|
400
402
|
PortalProvider,
|
|
401
403
|
type PortalProviderProps,
|
|
404
|
+
ROOT_OVERLAY_HOST,
|
|
405
|
+
useOverlayHost,
|
|
402
406
|
usePortal,
|
|
407
|
+
useTopmostOverlayHost,
|
|
403
408
|
} from "./Portal";
|
|
404
409
|
export {
|
|
405
410
|
Progress,
|
|
@@ -43,5 +43,9 @@ const isSizeKey = (value: unknown): value is SizeKey =>
|
|
|
43
43
|
*/
|
|
44
44
|
export const controlIconSize = (size: SizeKey | number | string | undefined): number => {
|
|
45
45
|
if (typeof size === "number") return size;
|
|
46
|
-
|
|
46
|
+
// A size TOKEN (`"$sm"`) names the same step as its bare key. Callers holding
|
|
47
|
+
// token-typed sizes (Pill's remove button passes `iconSize="$sm"`) used to fall
|
|
48
|
+
// through to the `md` 20px here, so every Pill's ✕ drew at 20px whatever its size.
|
|
49
|
+
const key = typeof size === "string" && size.startsWith("$") ? size.slice(1) : size;
|
|
50
|
+
return isSizeKey(key) ? CONTROL_ICON_SIZE[key] : CONTROL_ICON_SIZE.md;
|
|
47
51
|
};
|
|
@@ -15,17 +15,21 @@ import { getTokenValue } from "@knitui/core";
|
|
|
15
15
|
* design rationale (balanced text-to-height ratio, capped radius curve).
|
|
16
16
|
*
|
|
17
17
|
* key height font ratio padX padX(pill) gap radius
|
|
18
|
-
* xxs
|
|
19
|
-
* xs
|
|
20
|
-
* sm 32 14 .44
|
|
21
|
-
* md 40
|
|
22
|
-
* lg 48 20 .42
|
|
23
|
-
* xl
|
|
24
|
-
* xxl
|
|
18
|
+
* xxs 18 12 .67 2 4 2 2
|
|
19
|
+
* xs 24 12 .50 4 8 2 2
|
|
20
|
+
* sm 32 14 .44 8 12 4 4
|
|
21
|
+
* md 40 16 .40 12 16 4 4
|
|
22
|
+
* lg 48 20 .42 16 24 8 8
|
|
23
|
+
* xl 64 24 .38 24 24 8 8
|
|
24
|
+
* xxl 96 28 .29 32 32 12 16
|
|
25
|
+
*
|
|
26
|
+
* (Resolved from `core/config/scales.ts`; this table had drifted from it.)
|
|
25
27
|
*
|
|
26
28
|
* `fontSize` is intentionally CLAMPED at the bottom two steps (xxs/xs borrow the
|
|
27
29
|
* 12px `$xxs` font instead of their same-key font) so tiny controls aren't
|
|
28
|
-
* dominated by text
|
|
30
|
+
* dominated by text. `md` takes `$sm` (16), not its same-key 18: 18px put the
|
|
31
|
+
* default 40px control's label at heading size — larger than the body text
|
|
32
|
+
* around it — and left no 16 step between `sm` (14) and `lg` (20). `borderRadius` is
|
|
29
33
|
* CAPPED at `$lg` (16) so large controls stay rectangles, not accidental pills.
|
|
30
34
|
* `paddingHorizontalPill` is the standard padding bumped one space step — the one
|
|
31
35
|
* sanctioned divergence, used by the pill family (Badge/Chip/Pill).
|
|
@@ -57,7 +61,7 @@ export const controlMetrics = {
|
|
|
57
61
|
},
|
|
58
62
|
md: {
|
|
59
63
|
height: "$md",
|
|
60
|
-
fontSize: "$
|
|
64
|
+
fontSize: "$sm",
|
|
61
65
|
paddingHorizontal: "$md",
|
|
62
66
|
paddingHorizontalPill: "$lg",
|
|
63
67
|
gap: "$xs",
|
|
@@ -165,6 +165,16 @@ export const squareSizeVariant = {
|
|
|
165
165
|
xxl: { minWidth: M.xxl.height, width: M.xxl.height, height: M.xxl.height },
|
|
166
166
|
} as const;
|
|
167
167
|
|
|
168
|
+
/**
|
|
169
|
+
* The corner a square control (`ActionIcon`, `ThemeIcon`) takes from `sm` to `xl`
|
|
170
|
+
* — `$md` (8), the SAME corner `Button` uses at every size. They used to read
|
|
171
|
+
* `controlMetrics.borderRadius` (4 at sm/md), so an icon button beside a labelled
|
|
172
|
+
* one at the same height was visibly squarer than it. The tiny steps keep the
|
|
173
|
+
* table's 2px (an 8px corner on an 18–24px square reads as a circle); `xxl` keeps
|
|
174
|
+
* its 16.
|
|
175
|
+
*/
|
|
176
|
+
const SQUARE_CONTROL_RADIUS = "$md";
|
|
177
|
+
|
|
168
178
|
export const squareSizeRoundedVariant = {
|
|
169
179
|
xxs: {
|
|
170
180
|
minWidth: M.xxs.height,
|
|
@@ -182,25 +192,25 @@ export const squareSizeRoundedVariant = {
|
|
|
182
192
|
minWidth: M.sm.height,
|
|
183
193
|
width: M.sm.height,
|
|
184
194
|
height: M.sm.height,
|
|
185
|
-
borderRadius:
|
|
195
|
+
borderRadius: SQUARE_CONTROL_RADIUS,
|
|
186
196
|
},
|
|
187
197
|
md: {
|
|
188
198
|
minWidth: M.md.height,
|
|
189
199
|
width: M.md.height,
|
|
190
200
|
height: M.md.height,
|
|
191
|
-
borderRadius:
|
|
201
|
+
borderRadius: SQUARE_CONTROL_RADIUS,
|
|
192
202
|
},
|
|
193
203
|
lg: {
|
|
194
204
|
minWidth: M.lg.height,
|
|
195
205
|
width: M.lg.height,
|
|
196
206
|
height: M.lg.height,
|
|
197
|
-
borderRadius:
|
|
207
|
+
borderRadius: SQUARE_CONTROL_RADIUS,
|
|
198
208
|
},
|
|
199
209
|
xl: {
|
|
200
210
|
minWidth: M.xl.height,
|
|
201
211
|
width: M.xl.height,
|
|
202
212
|
height: M.xl.height,
|
|
203
|
-
borderRadius:
|
|
213
|
+
borderRadius: SQUARE_CONTROL_RADIUS,
|
|
204
214
|
},
|
|
205
215
|
xxl: {
|
|
206
216
|
minWidth: M.xxl.height,
|
|
@@ -491,6 +501,24 @@ export const WEB_BUTTON_PROPS: { render?: "button"; type?: string } = Object.fre
|
|
|
491
501
|
|
|
492
502
|
export const webButton = (): { render?: "button"; type?: string } => WEB_BUTTON_PROPS;
|
|
493
503
|
|
|
504
|
+
/**
|
|
505
|
+
* {@link WEB_BUTTON_PROPS}, or — when the control NAVIGATES — a real `<a href>`
|
|
506
|
+
* with `role="link"`. A control that goes somewhere must be a link on web, or
|
|
507
|
+
* middle-click / ⌘-click / "copy link" / the hover URL preview all silently fail;
|
|
508
|
+
* wrapping a `<button>` in an `<a>` instead nests interactive content (an axe
|
|
509
|
+
* `nested-interactive` failure). So the button-like frames take `href` and swap
|
|
510
|
+
* their host element here. Native has no link host: `href` is dropped there and
|
|
511
|
+
* the caller's `onPress` does the navigating.
|
|
512
|
+
*
|
|
513
|
+
* The anchor keeps the browser's default click behaviour; an app that routes
|
|
514
|
+
* in-app cancels it itself (e.g. `preventDefault` in a capture-phase click
|
|
515
|
+
* handler for plain clicks, letting modified clicks through).
|
|
516
|
+
*/
|
|
517
|
+
export const webButtonOrLink = (
|
|
518
|
+
href: string | undefined,
|
|
519
|
+
): { render?: "button" | "a"; type?: string; href?: string; role?: "link" } =>
|
|
520
|
+
isWeb && href ? { render: "a", href, role: "link" } : WEB_BUTTON_PROPS;
|
|
521
|
+
|
|
494
522
|
/**
|
|
495
523
|
* Web-only reset for the native `<button>` user-agent `text-align: center`.
|
|
496
524
|
* Returned as a raw `style` fragment to spread onto the element's `style` prop —
|