@mindlogic-ai/logician-ui 5.0.0-alpha.29 → 5.0.0-alpha.30
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/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.js +9 -9
- package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.mjs +10 -10
- package/dist/components/SegmentedControl/SegmentedControl.mjs.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.styles.d.ts +14 -8
- package/dist/components/SegmentedControl/SegmentedControl.styles.d.ts.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.styles.js +16 -10
- package/dist/components/SegmentedControl/SegmentedControl.styles.js.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.styles.mjs +16 -10
- package/dist/components/SegmentedControl/SegmentedControl.styles.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/SegmentedControl/SegmentedControl.styles.ts +16 -9
- package/src/components/SegmentedControl/SegmentedControl.tsx +11 -11
- package/src/theme/controlSizes.test.ts +8 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.d.ts","sourceRoot":"","sources":["../../../src/components/SegmentedControl/SegmentedControl.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUhD,OAAO,EACL,sBAAsB,EAEvB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"SegmentedControl.d.ts","sourceRoot":"","sources":["../../../src/components/SegmentedControl/SegmentedControl.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUhD,OAAO,EACL,sBAAsB,EAEvB,MAAM,0BAA0B,CAAC;AAElC,eAAO,MAAM,gBAAgB;;;;kDAoJ3B,CAAC"}
|
|
@@ -8,17 +8,17 @@ var controlSizes = require('../../theme/controlSizes.js');
|
|
|
8
8
|
var mergeCss = require('../../utils/mergeCss.js');
|
|
9
9
|
var SegmentedControl_styles = require('./SegmentedControl.styles.js');
|
|
10
10
|
|
|
11
|
-
// Root padding in px, not the `1` spacing token: that token is 0.25em, so at a
|
|
12
|
-
// 14px font it is 3.5px, and Ark positions the indicator from the item's
|
|
13
|
-
// integer offsetTop/offsetLeft (3.5 rounds to 4). The thumb then sat 0.5px low
|
|
14
|
-
// and its bottom gap was a pixel narrower than its top.
|
|
15
|
-
const ROOT_PADDING = `${SegmentedControl_styles.SEGMENT_ROOT_PADDING_PX}px`;
|
|
16
11
|
const SegmentedControl = React.forwardRef(function SegmentedControl(props, ref) {
|
|
17
12
|
const { options, value, onSelect, defaultValue, size = 'md', borderRadius = 'md', css, ...rest } = props;
|
|
18
13
|
// Same textStyle as every other control at this size (see controlSizes):
|
|
19
14
|
// the item height is em inside a ScaledContext, so equal type is what keeps
|
|
20
15
|
// the outer height equal to Button's there too.
|
|
21
16
|
const spec = controlSizes.getControlSize(size);
|
|
17
|
+
// Root padding in px, not the `1` spacing token: that token is 0.25em, so at
|
|
18
|
+
// a 14px font it is 3.5px, and Ark positions the indicator from the item's
|
|
19
|
+
// integer offsetTop/offsetLeft (3.5 rounds to 4). The thumb then sat 0.5px
|
|
20
|
+
// low and its bottom gap was a pixel narrower than its top.
|
|
21
|
+
const rootPadding = `${SegmentedControl_styles.segmentRootPaddingPx(size)}px`;
|
|
22
22
|
// Normalize options to the format expected by SegmentGroup.Items
|
|
23
23
|
const items = options.map((option) => ({
|
|
24
24
|
value: option.value,
|
|
@@ -26,11 +26,11 @@ const SegmentedControl = React.forwardRef(function SegmentedControl(props, ref)
|
|
|
26
26
|
disabled: option.disabled,
|
|
27
27
|
}));
|
|
28
28
|
// Concentric with the root: inner radius = outer radius − root padding
|
|
29
|
-
// (
|
|
29
|
+
// (rootPadding), floored at 0, so the gap between the two curves stays even.
|
|
30
30
|
const indicatorRadius = typeof borderRadius === 'string'
|
|
31
|
-
? `max(0px, calc(var(--chakra-radii-${borderRadius}) - ${
|
|
31
|
+
? `max(0px, calc(var(--chakra-radii-${borderRadius}) - ${rootPadding}))`
|
|
32
32
|
: typeof borderRadius === 'number'
|
|
33
|
-
? `max(0px, calc(${borderRadius}px - ${
|
|
33
|
+
? `max(0px, calc(${borderRadius}px - ${rootPadding}))`
|
|
34
34
|
: borderRadius;
|
|
35
35
|
return (jsxRuntime.jsxs(react.SegmentGroup.Root, { ref: ref, value: value, defaultValue: defaultValue ?? options[0]?.value, onValueChange: (details) => {
|
|
36
36
|
if (onSelect) {
|
|
@@ -63,7 +63,7 @@ const SegmentedControl = React.forwardRef(function SegmentedControl(props, ref)
|
|
|
63
63
|
// row) clipped its straight edges and left only the rounded corners.
|
|
64
64
|
// Inset, it is drawn inside the root padding, where the indicator never
|
|
65
65
|
// reaches.
|
|
66
|
-
bg: "bg.subtle", p:
|
|
66
|
+
bg: "bg.subtle", p: rootPadding, borderRadius: borderRadius, w: "fit-content", ...rest, css: mergeCss.mergeCss({
|
|
67
67
|
'--segment-indicator-bg': `var(--chakra-colors-bg-raised)`,
|
|
68
68
|
'--segment-indicator-shadow': `var(--chakra-shadows-xs)`,
|
|
69
69
|
boxShadow: 'inset 0 0 0 1px var(--chakra-colors-border-default)',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.js","sources":["../../../src/components/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"SegmentedControl.js","sources":["../../../src/components/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":[null],"names":["forwardRef","getControlSize","segmentRootPaddingPx","_jsxs","SegmentGroup","mergeCss","_jsx","indicatorTravel","segmentItemHeight"],"mappings":";;;;;;;;;;AAgBO,MAAM,gBAAgB,GAAGA,gBAAU,CAGxC,SAAS,gBAAgB,CAAC,KAAK,EAAE,GAAG,EAAA;IACpC,MAAM,EACJ,OAAO,EACP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AAA,MAAM,EAAE,GAAG;AACX,gCAAA,UAAU,EAAE,QAAQ;AACpB,gCAAA,QAAQ,EAAE,QAAQ;AAClB,gCAAA,UAAU,EAAE,MAAM;AAClB,gCAAA,aAAa,EAAE,MAAM;AACtB,6BAAA;AACD,4BAAA,0BAA0B,EAAE;AAC1B,gCAAA,KAAK,EAAE,iCAAiC;AACxC,gCAAA,UAAU,EAAE,KAAK;AAClB,6BAAA;AACF,yBAAA,EAAA,QAAA,EAEA,IAAI,CAAC,KAAK,GACW,EACxBE,cAAA,CAACF,kBAAY,CAAC,eAAe,KAAG,CAAA,EAAA,EArC3B,IAAI,CAAC,KAAK,CAsCG,CACrB,CAAC,CAAA,EAAA,CACgB;AAExB,CAAC;AAED,gBAAgB,CAAC,WAAW,GAAG,kBAAkB;;;;"}
|
|
@@ -4,19 +4,19 @@ import { forwardRef } from 'react';
|
|
|
4
4
|
import { SegmentGroup } from '@chakra-ui/react';
|
|
5
5
|
import { getControlSize } from '../../theme/controlSizes.mjs';
|
|
6
6
|
import { mergeCss } from '../../utils/mergeCss.mjs';
|
|
7
|
-
import {
|
|
7
|
+
import { segmentRootPaddingPx, indicatorTravel, segmentItemHeight } from './SegmentedControl.styles.mjs';
|
|
8
8
|
|
|
9
|
-
// Root padding in px, not the `1` spacing token: that token is 0.25em, so at a
|
|
10
|
-
// 14px font it is 3.5px, and Ark positions the indicator from the item's
|
|
11
|
-
// integer offsetTop/offsetLeft (3.5 rounds to 4). The thumb then sat 0.5px low
|
|
12
|
-
// and its bottom gap was a pixel narrower than its top.
|
|
13
|
-
const ROOT_PADDING = `${SEGMENT_ROOT_PADDING_PX}px`;
|
|
14
9
|
const SegmentedControl = forwardRef(function SegmentedControl(props, ref) {
|
|
15
10
|
const { options, value, onSelect, defaultValue, size = 'md', borderRadius = 'md', css, ...rest } = props;
|
|
16
11
|
// Same textStyle as every other control at this size (see controlSizes):
|
|
17
12
|
// the item height is em inside a ScaledContext, so equal type is what keeps
|
|
18
13
|
// the outer height equal to Button's there too.
|
|
19
14
|
const spec = getControlSize(size);
|
|
15
|
+
// Root padding in px, not the `1` spacing token: that token is 0.25em, so at
|
|
16
|
+
// a 14px font it is 3.5px, and Ark positions the indicator from the item's
|
|
17
|
+
// integer offsetTop/offsetLeft (3.5 rounds to 4). The thumb then sat 0.5px
|
|
18
|
+
// low and its bottom gap was a pixel narrower than its top.
|
|
19
|
+
const rootPadding = `${segmentRootPaddingPx(size)}px`;
|
|
20
20
|
// Normalize options to the format expected by SegmentGroup.Items
|
|
21
21
|
const items = options.map((option) => ({
|
|
22
22
|
value: option.value,
|
|
@@ -24,11 +24,11 @@ const SegmentedControl = forwardRef(function SegmentedControl(props, ref) {
|
|
|
24
24
|
disabled: option.disabled,
|
|
25
25
|
}));
|
|
26
26
|
// Concentric with the root: inner radius = outer radius − root padding
|
|
27
|
-
// (
|
|
27
|
+
// (rootPadding), floored at 0, so the gap between the two curves stays even.
|
|
28
28
|
const indicatorRadius = typeof borderRadius === 'string'
|
|
29
|
-
? `max(0px, calc(var(--chakra-radii-${borderRadius}) - ${
|
|
29
|
+
? `max(0px, calc(var(--chakra-radii-${borderRadius}) - ${rootPadding}))`
|
|
30
30
|
: typeof borderRadius === 'number'
|
|
31
|
-
? `max(0px, calc(${borderRadius}px - ${
|
|
31
|
+
? `max(0px, calc(${borderRadius}px - ${rootPadding}))`
|
|
32
32
|
: borderRadius;
|
|
33
33
|
return (jsxs(SegmentGroup.Root, { ref: ref, value: value, defaultValue: defaultValue ?? options[0]?.value, onValueChange: (details) => {
|
|
34
34
|
if (onSelect) {
|
|
@@ -61,7 +61,7 @@ const SegmentedControl = forwardRef(function SegmentedControl(props, ref) {
|
|
|
61
61
|
// row) clipped its straight edges and left only the rounded corners.
|
|
62
62
|
// Inset, it is drawn inside the root padding, where the indicator never
|
|
63
63
|
// reaches.
|
|
64
|
-
bg: "bg.subtle", p:
|
|
64
|
+
bg: "bg.subtle", p: rootPadding, borderRadius: borderRadius, w: "fit-content", ...rest, css: mergeCss({
|
|
65
65
|
'--segment-indicator-bg': `var(--chakra-colors-bg-raised)`,
|
|
66
66
|
'--segment-indicator-shadow': `var(--chakra-shadows-xs)`,
|
|
67
67
|
boxShadow: 'inset 0 0 0 1px var(--chakra-colors-border-default)',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.mjs","sources":["../../../src/components/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"SegmentedControl.mjs","sources":["../../../src/components/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;AAgBO,MAAM,gBAAgB,GAAG,UAAU,CAGxC,SAAS,gBAAgB,CAAC,KAAK,EAAE,GAAG,EAAA;IACpC,MAAM,EACJ,OAAO,EACP,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,IAAI,GAAG,IAAI,EACX,YAAY,GAAG,IAAI,EACnB,GAAG,EACH,GAAG,IAAI,EACR,GAAG,KAAK;;;;AAKT,IAAA,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC;;;;;IAMjC,MAAM,WAAW,GAAG,CAAA,EAAG,oBAAoB,CAAC,IAAI,CAAC,IAAI;;IAGrD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAA8B,MAAM;QAC7D,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ;AAC1B,KAAA,CAAC,CAAC;;;AAIH,IAAA,MAAM,eAAe,GACnB,OAAO,YAAY,KAAK;AACtB,UAAE,CAAA,iCAAA,EAAoC,YAAY,CAAA,IAAA,EAAO,WAAW,CAAA,EAAA;AACpE,UAAE,OAAO,YAAY,KAAK;AACxB,cAAE,CAAA,cAAA,EAAiB,YAAY,CAAA,KAAA,EAAQ,WAAW,CA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zB,EAAE,EAAE,IAAI,CAAC,cAAc,EACvB,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,MAAM,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,EAAA,QAAA,EAAA,CAE7BC,GAAA,CAAC,YAAY,CAAC,QAAQ,EAAA,EAAA,WAAA,EACT,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,GAAG,IAAI,CAAC,KAAK,GAAG,SAAS,EAClE,KAAK,EAAC,UAAU,EAChB,UAAU,EAAC,KAAK,EAChB,UAAU,EAAC,QAAQ,EACnB,OAAO,EAAC,aAAa,EACrB,aAAa,EAAC,QAAQ,EACtB,UAAU,EAAC,QAAQ,EACnB,GAAG,EAAE;AACH,4BAAA,UAAU,EAAE;AACV,gCAAA,OAAO,EAAE,iBAAiB;AAC1B,gCAAA,UAAU,EAAE,KAAK;AACjB,gCAAA,MAAM,EAAE,GAAG;AACX,gCAAA,UAAU,EAAE,QAAQ;AACpB,gCAAA,QAAQ,EAAE,QAAQ;AAClB,gCAAA,UAAU,EAAE,MAAM;AAClB,gCAAA,aAAa,EAAE,MAAM;AACtB,6BAAA;AACD,4BAAA,0BAA0B,EAAE;AAC1B,gCAAA,KAAK,EAAE,iCAAiC;AACxC,gCAAA,UAAU,EAAE,KAAK;AAClB,6BAAA;AACF,yBAAA,EAAA,QAAA,EAEA,IAAI,CAAC,KAAK,GACW,EACxBA,GAAA,CAAC,YAAY,CAAC,eAAe,KAAG,CAAA,EAAA,EArC3B,IAAI,CAAC,KAAK,CAsCG,CACrB,CAAC,CAAA,EAAA,CACgB;AAExB,CAAC;AAED,gBAAgB,CAAC,WAAW,GAAG,kBAAkB;;;;"}
|
|
@@ -14,21 +14,27 @@ import type { SystemStyleObject } from '@chakra-ui/react';
|
|
|
14
14
|
*/
|
|
15
15
|
export declare const indicatorTravel: SystemStyleObject;
|
|
16
16
|
/**
|
|
17
|
-
* The root's padding in px (see `
|
|
18
|
-
* why px). Shared with the item-height calc so the two cannot
|
|
17
|
+
* The root's padding in px (see `rootPadding` in SegmentedControl.tsx for
|
|
18
|
+
* why px), per size. Shared with the item-height calc so the two cannot
|
|
19
|
+
* disagree.
|
|
20
|
+
*
|
|
21
|
+
* 4px from `sm` up; 2px at `xs` / `2xs`. A fixed 4px left an `xs` item 20px
|
|
22
|
+
* tall (28 − 8) inside a 16px `ScaledContext`, shorter than its own 14px type's
|
|
23
|
+
* 21px line, and the label read squeezed against the indicator (FactChat
|
|
24
|
+
* coding-agent toolbar, 박상현 2026-11-10). At 2px the item is 24px.
|
|
19
25
|
*/
|
|
20
|
-
export declare const
|
|
26
|
+
export declare const segmentRootPaddingPx: (size: unknown) => number;
|
|
21
27
|
/**
|
|
22
|
-
* Item height so that the OUTER height (item + 2 ×
|
|
28
|
+
* Item height so that the OUTER height (item + 2 × root padding) equals the
|
|
23
29
|
* Button height for the same size — `controlSizes[size].height`, i.e. 28 /
|
|
24
30
|
* 31.5 / 35 / 38.5px for xs / sm / md / lg at the 14px root, and 36 / 40 / 44
|
|
25
31
|
* for sm / md / lg inside a 16px `ScaledContext`.
|
|
26
32
|
*
|
|
27
33
|
* A `calc()` on the height token rather than a smaller token: the root padding
|
|
28
|
-
* is a fixed
|
|
29
|
-
* so no single token equals "Button height −
|
|
30
|
-
* one-token-smaller table (`6`/`7`/`8`/`9`) was written for
|
|
31
|
-
* came out 1px taller than Button at the real 14px root.
|
|
34
|
+
* is a fixed px value while the sizes tokens are rem (em inside a
|
|
35
|
+
* ScaledContext), so no single token equals "Button height − padding" at every
|
|
36
|
+
* font size. The old one-token-smaller table (`6`/`7`/`8`/`9`) was written for
|
|
37
|
+
* a 16px rem and came out 1px taller than Button at the real 14px root.
|
|
32
38
|
*/
|
|
33
39
|
export declare const segmentItemHeight: (size: unknown) => string;
|
|
34
40
|
//# sourceMappingURL=SegmentedControl.styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.styles.d.ts","sourceRoot":"","sources":["../../../src/components/SegmentedControl/SegmentedControl.styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAQ1D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,EAAE,iBAM7B,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"SegmentedControl.styles.d.ts","sourceRoot":"","sources":["../../../src/components/SegmentedControl/SegmentedControl.styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAQ1D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,EAAE,iBAM7B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,GAAI,MAAM,OAAO,KAAG,MACZ,CAAC;AAE1C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,OAAO,KAAG,MAKN,CAAC"}
|
|
@@ -24,27 +24,33 @@ const indicatorTravel = {
|
|
|
24
24
|
},
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
|
-
* The root's padding in px (see `
|
|
28
|
-
* why px). Shared with the item-height calc so the two cannot
|
|
27
|
+
* The root's padding in px (see `rootPadding` in SegmentedControl.tsx for
|
|
28
|
+
* why px), per size. Shared with the item-height calc so the two cannot
|
|
29
|
+
* disagree.
|
|
30
|
+
*
|
|
31
|
+
* 4px from `sm` up; 2px at `xs` / `2xs`. A fixed 4px left an `xs` item 20px
|
|
32
|
+
* tall (28 − 8) inside a 16px `ScaledContext`, shorter than its own 14px type's
|
|
33
|
+
* 21px line, and the label read squeezed against the indicator (FactChat
|
|
34
|
+
* coding-agent toolbar, 박상현 2026-11-10). At 2px the item is 24px.
|
|
29
35
|
*/
|
|
30
|
-
const
|
|
36
|
+
const segmentRootPaddingPx = (size) => size === 'xs' || size === '2xs' ? 2 : 4;
|
|
31
37
|
/**
|
|
32
|
-
* Item height so that the OUTER height (item + 2 ×
|
|
38
|
+
* Item height so that the OUTER height (item + 2 × root padding) equals the
|
|
33
39
|
* Button height for the same size — `controlSizes[size].height`, i.e. 28 /
|
|
34
40
|
* 31.5 / 35 / 38.5px for xs / sm / md / lg at the 14px root, and 36 / 40 / 44
|
|
35
41
|
* for sm / md / lg inside a 16px `ScaledContext`.
|
|
36
42
|
*
|
|
37
43
|
* A `calc()` on the height token rather than a smaller token: the root padding
|
|
38
|
-
* is a fixed
|
|
39
|
-
* so no single token equals "Button height −
|
|
40
|
-
* one-token-smaller table (`6`/`7`/`8`/`9`) was written for
|
|
41
|
-
* came out 1px taller than Button at the real 14px root.
|
|
44
|
+
* is a fixed px value while the sizes tokens are rem (em inside a
|
|
45
|
+
* ScaledContext), so no single token equals "Button height − padding" at every
|
|
46
|
+
* font size. The old one-token-smaller table (`6`/`7`/`8`/`9`) was written for
|
|
47
|
+
* a 16px rem and came out 1px taller than Button at the real 14px root.
|
|
42
48
|
*/
|
|
43
49
|
const segmentItemHeight = (size) => `calc(${controlSizes.controlHeightVar((typeof size === 'string' && size in controlSizes.controlSizes
|
|
44
50
|
? size
|
|
45
|
-
: 'md'))} - ${
|
|
51
|
+
: 'md'))} - ${segmentRootPaddingPx(size) * 2}px)`;
|
|
46
52
|
|
|
47
|
-
exports.SEGMENT_ROOT_PADDING_PX = SEGMENT_ROOT_PADDING_PX;
|
|
48
53
|
exports.indicatorTravel = indicatorTravel;
|
|
49
54
|
exports.segmentItemHeight = segmentItemHeight;
|
|
55
|
+
exports.segmentRootPaddingPx = segmentRootPaddingPx;
|
|
50
56
|
//# sourceMappingURL=SegmentedControl.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.styles.js","sources":["../../../src/components/SegmentedControl/SegmentedControl.styles.ts"],"sourcesContent":[null],"names":["controlHeightVar","controlSizes"],"mappings":";;;;;AAQA;;;;;;;;;;;;AAYG;AACI,MAAM,eAAe,GAAsB;AAChD,IAAA,uBAAuB,EAAE,qCAAqC;AAC9D,IAAA,8BAA8B,EAAE,kCAAkC;AAClE,IAAA,aAAa,EAAE;AACb,QAAA,uBAAuB,EAAE,wCAAwC;AAClE,KAAA;;AAGH
|
|
1
|
+
{"version":3,"file":"SegmentedControl.styles.js","sources":["../../../src/components/SegmentedControl/SegmentedControl.styles.ts"],"sourcesContent":[null],"names":["controlHeightVar","controlSizes"],"mappings":";;;;;AAQA;;;;;;;;;;;;AAYG;AACI,MAAM,eAAe,GAAsB;AAChD,IAAA,uBAAuB,EAAE,qCAAqC;AAC9D,IAAA,8BAA8B,EAAE,kCAAkC;AAClE,IAAA,aAAa,EAAE;AACb,QAAA,uBAAuB,EAAE,wCAAwC;AAClE,KAAA;;AAGH;;;;;;;;;AASG;AACI,MAAM,oBAAoB,GAAG,CAAC,IAAa,KAChD,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,GAAG,CAAC,GAAG;AAExC;;;;;;;;;;;AAWG;MACU,iBAAiB,GAAG,CAAC,IAAa,KAC7C,CAAA,KAAA,EAAQA,6BAAgB,EACrB,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,IAAIC;AACnC,MAAE;AACF,MAAE,IAAI,EACT,CAAA,GAAA,EAAM,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA,GAAA;;;;;;"}
|
|
@@ -22,25 +22,31 @@ const indicatorTravel = {
|
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
|
-
* The root's padding in px (see `
|
|
26
|
-
* why px). Shared with the item-height calc so the two cannot
|
|
25
|
+
* The root's padding in px (see `rootPadding` in SegmentedControl.tsx for
|
|
26
|
+
* why px), per size. Shared with the item-height calc so the two cannot
|
|
27
|
+
* disagree.
|
|
28
|
+
*
|
|
29
|
+
* 4px from `sm` up; 2px at `xs` / `2xs`. A fixed 4px left an `xs` item 20px
|
|
30
|
+
* tall (28 − 8) inside a 16px `ScaledContext`, shorter than its own 14px type's
|
|
31
|
+
* 21px line, and the label read squeezed against the indicator (FactChat
|
|
32
|
+
* coding-agent toolbar, 박상현 2026-11-10). At 2px the item is 24px.
|
|
27
33
|
*/
|
|
28
|
-
const
|
|
34
|
+
const segmentRootPaddingPx = (size) => size === 'xs' || size === '2xs' ? 2 : 4;
|
|
29
35
|
/**
|
|
30
|
-
* Item height so that the OUTER height (item + 2 ×
|
|
36
|
+
* Item height so that the OUTER height (item + 2 × root padding) equals the
|
|
31
37
|
* Button height for the same size — `controlSizes[size].height`, i.e. 28 /
|
|
32
38
|
* 31.5 / 35 / 38.5px for xs / sm / md / lg at the 14px root, and 36 / 40 / 44
|
|
33
39
|
* for sm / md / lg inside a 16px `ScaledContext`.
|
|
34
40
|
*
|
|
35
41
|
* A `calc()` on the height token rather than a smaller token: the root padding
|
|
36
|
-
* is a fixed
|
|
37
|
-
* so no single token equals "Button height −
|
|
38
|
-
* one-token-smaller table (`6`/`7`/`8`/`9`) was written for
|
|
39
|
-
* came out 1px taller than Button at the real 14px root.
|
|
42
|
+
* is a fixed px value while the sizes tokens are rem (em inside a
|
|
43
|
+
* ScaledContext), so no single token equals "Button height − padding" at every
|
|
44
|
+
* font size. The old one-token-smaller table (`6`/`7`/`8`/`9`) was written for
|
|
45
|
+
* a 16px rem and came out 1px taller than Button at the real 14px root.
|
|
40
46
|
*/
|
|
41
47
|
const segmentItemHeight = (size) => `calc(${controlHeightVar((typeof size === 'string' && size in controlSizes
|
|
42
48
|
? size
|
|
43
|
-
: 'md'))} - ${
|
|
49
|
+
: 'md'))} - ${segmentRootPaddingPx(size) * 2}px)`;
|
|
44
50
|
|
|
45
|
-
export {
|
|
51
|
+
export { indicatorTravel, segmentItemHeight, segmentRootPaddingPx };
|
|
46
52
|
//# sourceMappingURL=SegmentedControl.styles.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.styles.mjs","sources":["../../../src/components/SegmentedControl/SegmentedControl.styles.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAQA;;;;;;;;;;;;AAYG;AACI,MAAM,eAAe,GAAsB;AAChD,IAAA,uBAAuB,EAAE,qCAAqC;AAC9D,IAAA,8BAA8B,EAAE,kCAAkC;AAClE,IAAA,aAAa,EAAE;AACb,QAAA,uBAAuB,EAAE,wCAAwC;AAClE,KAAA;;AAGH
|
|
1
|
+
{"version":3,"file":"SegmentedControl.styles.mjs","sources":["../../../src/components/SegmentedControl/SegmentedControl.styles.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAQA;;;;;;;;;;;;AAYG;AACI,MAAM,eAAe,GAAsB;AAChD,IAAA,uBAAuB,EAAE,qCAAqC;AAC9D,IAAA,8BAA8B,EAAE,kCAAkC;AAClE,IAAA,aAAa,EAAE;AACb,QAAA,uBAAuB,EAAE,wCAAwC;AAClE,KAAA;;AAGH;;;;;;;;;AASG;AACI,MAAM,oBAAoB,GAAG,CAAC,IAAa,KAChD,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,GAAG,CAAC,GAAG;AAExC;;;;;;;;;;;AAWG;MACU,iBAAiB,GAAG,CAAC,IAAa,KAC7C,CAAA,KAAA,EAAQ,gBAAgB,EACrB,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,IAAI;AACnC,MAAE;AACF,MAAE,IAAI,EACT,CAAA,GAAA,EAAM,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA,GAAA;;;;"}
|
package/package.json
CHANGED
|
@@ -28,26 +28,33 @@ export const indicatorTravel: SystemStyleObject = {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* The root's padding in px (see `
|
|
32
|
-
* why px). Shared with the item-height calc so the two cannot
|
|
31
|
+
* The root's padding in px (see `rootPadding` in SegmentedControl.tsx for
|
|
32
|
+
* why px), per size. Shared with the item-height calc so the two cannot
|
|
33
|
+
* disagree.
|
|
34
|
+
*
|
|
35
|
+
* 4px from `sm` up; 2px at `xs` / `2xs`. A fixed 4px left an `xs` item 20px
|
|
36
|
+
* tall (28 − 8) inside a 16px `ScaledContext`, shorter than its own 14px type's
|
|
37
|
+
* 21px line, and the label read squeezed against the indicator (FactChat
|
|
38
|
+
* coding-agent toolbar, 박상현 2026-11-10). At 2px the item is 24px.
|
|
33
39
|
*/
|
|
34
|
-
export const
|
|
40
|
+
export const segmentRootPaddingPx = (size: unknown): number =>
|
|
41
|
+
size === 'xs' || size === '2xs' ? 2 : 4;
|
|
35
42
|
|
|
36
43
|
/**
|
|
37
|
-
* Item height so that the OUTER height (item + 2 ×
|
|
44
|
+
* Item height so that the OUTER height (item + 2 × root padding) equals the
|
|
38
45
|
* Button height for the same size — `controlSizes[size].height`, i.e. 28 /
|
|
39
46
|
* 31.5 / 35 / 38.5px for xs / sm / md / lg at the 14px root, and 36 / 40 / 44
|
|
40
47
|
* for sm / md / lg inside a 16px `ScaledContext`.
|
|
41
48
|
*
|
|
42
49
|
* A `calc()` on the height token rather than a smaller token: the root padding
|
|
43
|
-
* is a fixed
|
|
44
|
-
* so no single token equals "Button height −
|
|
45
|
-
* one-token-smaller table (`6`/`7`/`8`/`9`) was written for
|
|
46
|
-
* came out 1px taller than Button at the real 14px root.
|
|
50
|
+
* is a fixed px value while the sizes tokens are rem (em inside a
|
|
51
|
+
* ScaledContext), so no single token equals "Button height − padding" at every
|
|
52
|
+
* font size. The old one-token-smaller table (`6`/`7`/`8`/`9`) was written for
|
|
53
|
+
* a 16px rem and came out 1px taller than Button at the real 14px root.
|
|
47
54
|
*/
|
|
48
55
|
export const segmentItemHeight = (size: unknown): string =>
|
|
49
56
|
`calc(${controlHeightVar(
|
|
50
57
|
(typeof size === 'string' && size in controlSizes
|
|
51
58
|
? size
|
|
52
59
|
: 'md') as ControlSize
|
|
53
|
-
)} - ${
|
|
60
|
+
)} - ${segmentRootPaddingPx(size) * 2}px)`;
|
|
@@ -6,20 +6,14 @@ import { mergeCss } from '@/utils/mergeCss';
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
indicatorTravel,
|
|
9
|
-
SEGMENT_ROOT_PADDING_PX,
|
|
10
9
|
segmentItemHeight,
|
|
10
|
+
segmentRootPaddingPx,
|
|
11
11
|
} from './SegmentedControl.styles';
|
|
12
12
|
import {
|
|
13
13
|
SegmentedControlOption,
|
|
14
14
|
SegmentedControlProps,
|
|
15
15
|
} from './SegmentedControl.types';
|
|
16
16
|
|
|
17
|
-
// Root padding in px, not the `1` spacing token: that token is 0.25em, so at a
|
|
18
|
-
// 14px font it is 3.5px, and Ark positions the indicator from the item's
|
|
19
|
-
// integer offsetTop/offsetLeft (3.5 rounds to 4). The thumb then sat 0.5px low
|
|
20
|
-
// and its bottom gap was a pixel narrower than its top.
|
|
21
|
-
const ROOT_PADDING = `${SEGMENT_ROOT_PADDING_PX}px`;
|
|
22
|
-
|
|
23
17
|
export const SegmentedControl = forwardRef<
|
|
24
18
|
HTMLDivElement,
|
|
25
19
|
SegmentedControlProps
|
|
@@ -40,6 +34,12 @@ export const SegmentedControl = forwardRef<
|
|
|
40
34
|
// the outer height equal to Button's there too.
|
|
41
35
|
const spec = getControlSize(size);
|
|
42
36
|
|
|
37
|
+
// Root padding in px, not the `1` spacing token: that token is 0.25em, so at
|
|
38
|
+
// a 14px font it is 3.5px, and Ark positions the indicator from the item's
|
|
39
|
+
// integer offsetTop/offsetLeft (3.5 rounds to 4). The thumb then sat 0.5px
|
|
40
|
+
// low and its bottom gap was a pixel narrower than its top.
|
|
41
|
+
const rootPadding = `${segmentRootPaddingPx(size)}px`;
|
|
42
|
+
|
|
43
43
|
// Normalize options to the format expected by SegmentGroup.Items
|
|
44
44
|
const items = options.map((option: SegmentedControlOption) => ({
|
|
45
45
|
value: option.value,
|
|
@@ -48,12 +48,12 @@ export const SegmentedControl = forwardRef<
|
|
|
48
48
|
}));
|
|
49
49
|
|
|
50
50
|
// Concentric with the root: inner radius = outer radius − root padding
|
|
51
|
-
// (
|
|
51
|
+
// (rootPadding), floored at 0, so the gap between the two curves stays even.
|
|
52
52
|
const indicatorRadius =
|
|
53
53
|
typeof borderRadius === 'string'
|
|
54
|
-
? `max(0px, calc(var(--chakra-radii-${borderRadius}) - ${
|
|
54
|
+
? `max(0px, calc(var(--chakra-radii-${borderRadius}) - ${rootPadding}))`
|
|
55
55
|
: typeof borderRadius === 'number'
|
|
56
|
-
? `max(0px, calc(${borderRadius}px - ${
|
|
56
|
+
? `max(0px, calc(${borderRadius}px - ${rootPadding}))`
|
|
57
57
|
: borderRadius;
|
|
58
58
|
|
|
59
59
|
return (
|
|
@@ -94,7 +94,7 @@ export const SegmentedControl = forwardRef<
|
|
|
94
94
|
// Inset, it is drawn inside the root padding, where the indicator never
|
|
95
95
|
// reaches.
|
|
96
96
|
bg="bg.subtle"
|
|
97
|
-
p={
|
|
97
|
+
p={rootPadding}
|
|
98
98
|
borderRadius={borderRadius}
|
|
99
99
|
w="fit-content"
|
|
100
100
|
{...rest}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { defaultSystem } from '@chakra-ui/react';
|
|
2
2
|
import { describe, expect, it } from 'vitest';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
segmentItemHeight,
|
|
6
|
+
segmentRootPaddingPx,
|
|
7
|
+
} from '../components/SegmentedControl/SegmentedControl.styles';
|
|
5
8
|
import { getTagSizeStyles } from '../components/Tag/Tag.styles';
|
|
6
9
|
import {
|
|
7
10
|
CONTROL_RADIUS,
|
|
@@ -97,10 +100,12 @@ describe('controlSizes — every other control resolves to the same scale', () =
|
|
|
97
100
|
});
|
|
98
101
|
|
|
99
102
|
it.each(CORE_CONTROL_SIZES)(
|
|
100
|
-
'SegmentedControl %s: item + 2×
|
|
103
|
+
'SegmentedControl %s: item + 2 × root padding = the height token',
|
|
101
104
|
(size) => {
|
|
105
|
+
const padding = size === 'xs' ? 2 : 4;
|
|
106
|
+
expect(segmentRootPaddingPx(size)).toBe(padding);
|
|
102
107
|
expect(segmentItemHeight(size)).toBe(
|
|
103
|
-
`calc(var(--chakra-sizes-${controlSizes[size].height}) -
|
|
108
|
+
`calc(var(--chakra-sizes-${controlSizes[size].height}) - ${padding * 2}px)`
|
|
104
109
|
);
|
|
105
110
|
}
|
|
106
111
|
);
|