@newtone-dev/ui-react-web 0.36.0 → 0.37.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/segmented-control/segmented-control.css +25 -0
- package/dist/segmented-control/segmented-control.d.ts +5 -1
- package/dist/segmented-control/segmented-control.d.ts.map +1 -1
- package/dist/segmented-control/segmented-control.js +9 -2
- package/dist/segmented-control/segmented-control.js.map +1 -1
- package/package.json +1 -1
|
@@ -186,6 +186,31 @@
|
|
|
186
186
|
color: var(--newtone-segmented-control-segment-chosen-text);
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
+
/* THE TWO RUNGS: the text is 14/20 at both, so the rung is the block padding. `sm` is a 36px segment
|
|
190
|
+
* in a 44px track; the track's padding and corner do not move, so 12 still wraps 8.
|
|
191
|
+
* components/segmented-control.md, *size and square*. */
|
|
192
|
+
.newtone-segmented-control--sm .newtone-segmented-control-segment {
|
|
193
|
+
padding-block: var(--newtone-space-2);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/* SQUARE: as wide as tall, the label centered, for one or two letters. The width is stated, the
|
|
197
|
+
* label's 20px leading plus the rung's block padding twice, because `aspect-ratio` cannot widen a
|
|
198
|
+
* flex item whose height is not definite (measured: it left ES 16px wide). */
|
|
199
|
+
.newtone-segmented-control--square .newtone-segmented-control-segment {
|
|
200
|
+
box-sizing: border-box;
|
|
201
|
+
inline-size: calc(
|
|
202
|
+
var(--newtone-typography-step-sm-leading) + 2 *
|
|
203
|
+
var(--newtone-segmented-control-segment-padding-block)
|
|
204
|
+
);
|
|
205
|
+
padding-inline: 0;
|
|
206
|
+
justify-content: center;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.newtone-segmented-control--sm.newtone-segmented-control--square
|
|
210
|
+
.newtone-segmented-control-segment {
|
|
211
|
+
inline-size: calc(var(--newtone-typography-step-sm-leading) + 2 * var(--newtone-space-2));
|
|
212
|
+
}
|
|
213
|
+
|
|
189
214
|
/* A link segment is an <a>: no underline, and its own focus ring, where a radio segment's ring is
|
|
190
215
|
* its input's. components/segmented-control.md, *Links*. */
|
|
191
216
|
.newtone-segmented-control--links .newtone-segmented-control-segment {
|
|
@@ -96,6 +96,10 @@ export interface SegmentedControlProps extends HTMLAttributes<HTMLElement> {
|
|
|
96
96
|
options: readonly SegmentedControlOption[];
|
|
97
97
|
/** The `value` of the option checked first; the first option when it names none. */
|
|
98
98
|
defaultValue?: string;
|
|
99
|
+
/** 44px segments in a 52px track (`md`, the default) or 36 in 44 (`sm`). */
|
|
100
|
+
size?: 'sm' | 'md';
|
|
101
|
+
/** Each segment as wide as it is tall, for labels of one or two letters (*ES | EN*). */
|
|
102
|
+
square?: boolean;
|
|
99
103
|
}
|
|
100
|
-
export declare function SegmentedControl({ name, label, options, defaultValue, className, ...rest }: SegmentedControlProps): import("react").JSX.Element;
|
|
104
|
+
export declare function SegmentedControl({ name, label, options, defaultValue, size, square, className, ...rest }: SegmentedControlProps): import("react").JSX.Element;
|
|
101
105
|
//# sourceMappingURL=segmented-control.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segmented-control.d.ts","sourceRoot":"","sources":["../../src/segmented-control/segmented-control.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAG3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAEH,MAAM,WAAW,sBAAsB;IACnC,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAA;IACb,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAA;IACb,kGAAkG;IAClG,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,qBAAsB,SAAQ,cAAc,CAAC,WAAW,CAAC;IACtE;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAA;IACb,8BAA8B;IAC9B,OAAO,EAAE,SAAS,sBAAsB,EAAE,CAAA;IAC1C,oFAAoF;IACpF,YAAY,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"segmented-control.d.ts","sourceRoot":"","sources":["../../src/segmented-control/segmented-control.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAG3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAEH,MAAM,WAAW,sBAAsB;IACnC,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAA;IACb,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAA;IACb,kGAAkG;IAClG,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,qBAAsB,SAAQ,cAAc,CAAC,WAAW,CAAC;IACtE;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAA;IACb,8BAA8B;IAC9B,OAAO,EAAE,SAAS,sBAAsB,EAAE,CAAA;IAC1C,oFAAoF;IACpF,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IAClB,wFAAwF;IACxF,MAAM,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,wBAAgB,gBAAgB,CAAC,EAC7B,IAAI,EACJ,KAAK,EACL,OAAO,EACP,YAAY,EACZ,IAAW,EACX,MAAc,EACd,SAAS,EACT,GAAG,IAAI,EACV,EAAE,qBAAqB,+BAuFvB"}
|
|
@@ -3,7 +3,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
// this is a server component -- see the repo blueprint, section 4.3.
|
|
4
4
|
import { Surface } from '../surface/index.js';
|
|
5
5
|
import { Text } from '../text/index.js';
|
|
6
|
-
export function SegmentedControl({ name, label, options, defaultValue, className, ...rest }) {
|
|
6
|
+
export function SegmentedControl({ name, label, options, defaultValue, size = 'md', square = false, className, ...rest }) {
|
|
7
|
+
const modifiers = [
|
|
8
|
+
size === 'sm' ? 'newtone-segmented-control--sm' : null,
|
|
9
|
+
square ? 'newtone-segmented-control--square' : null,
|
|
10
|
+
];
|
|
7
11
|
const named = options.findIndex((option) => option.value === defaultValue);
|
|
8
12
|
const checked = named === -1 ? 0 : named;
|
|
9
13
|
// LINKS, when every option goes somewhere: the choice is a different address, so each segment
|
|
@@ -14,11 +18,14 @@ export function SegmentedControl({ name, label, options, defaultValue, className
|
|
|
14
18
|
return (_jsx("nav", { className: [
|
|
15
19
|
'newtone-segmented-control',
|
|
16
20
|
'newtone-segmented-control--links',
|
|
21
|
+
...modifiers,
|
|
17
22
|
className,
|
|
18
23
|
]
|
|
19
24
|
.filter(Boolean)
|
|
20
25
|
.join(' '), "aria-label": label, ...rest, children: options.map((option, index) => (_jsx("a", { className: "newtone-segmented-control-segment", href: option.href, hrefLang: option.hrefLang, lang: option.hrefLang, "aria-current": index === checked ? 'page' : undefined, children: _jsx(Text, { as: "span", scale: "body-sm", weight: "medium", children: option.label }) }, option.value))) }));
|
|
21
26
|
}
|
|
22
|
-
return (_jsx("div", { className: ['newtone-segmented-control',
|
|
27
|
+
return (_jsx("div", { className: ['newtone-segmented-control', ...modifiers, className]
|
|
28
|
+
.filter(Boolean)
|
|
29
|
+
.join(' '), role: "radiogroup", "aria-label": label, ...rest, children: options.map((option, index) => (_jsxs("label", { className: "newtone-segmented-control-segment", children: [_jsx("input", { className: "newtone-segmented-control-input", type: "radio", name: name, value: option.value, defaultChecked: index === checked }), _jsx(Text, { as: "span", scale: "body-sm", weight: "medium", children: option.label }), option.badge ? (_jsx(Surface, { as: "span", theme: "tinted", className: "newtone-segmented-control-badge", children: _jsx(Text, { as: "span", scale: "caption", weight: "medium", figures: "tabular", children: option.badge }) })) : null] }, option.value))) }));
|
|
23
30
|
}
|
|
24
31
|
//# sourceMappingURL=segmented-control.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segmented-control.js","sourceRoot":"","sources":["../../src/segmented-control/segmented-control.tsx"],"names":[],"mappings":";AAAA,uGAAuG;AACvG,qEAAqE;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"segmented-control.js","sourceRoot":"","sources":["../../src/segmented-control/segmented-control.tsx"],"names":[],"mappings":";AAAA,uGAAuG;AACvG,qEAAqE;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AA2GvC,MAAM,UAAU,gBAAgB,CAAC,EAC7B,IAAI,EACJ,KAAK,EACL,OAAO,EACP,YAAY,EACZ,IAAI,GAAG,IAAI,EACX,MAAM,GAAG,KAAK,EACd,SAAS,EACT,GAAG,IAAI,EACa;IACpB,MAAM,SAAS,GAAG;QACd,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,IAAI;QACtD,MAAM,CAAC,CAAC,CAAC,mCAAmC,CAAC,CAAC,CAAC,IAAI;KACtD,CAAA;IACD,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,YAAY,CAAC,CAAA;IAC1E,MAAM,OAAO,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,C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