mac-human-design 0.1.24 → 0.1.25

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/changelog.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  This file tracks changes between published npm versions of `mac-human-design`.
4
4
 
5
+ ## 0.1.25
6
+
7
+ ### Added
8
+
9
+ - Added accessible label props, a stable `hd-mac-segmented-control` class,
10
+ class/style pass-through, and verifier coverage to `MacSegmentedControl`.
11
+
12
+ ### Changed
13
+
14
+ - `MacSegmentedControl` now has a default accessible label and stable
15
+ center-origin inline alignment for toolbar usage.
16
+ - Bumped the package to `0.1.25`.
17
+
5
18
  ## 0.1.24
6
19
 
7
20
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mac-human-design",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "description": "Reusable macOS-oriented UI primitives and SF Symbols bridge for Tauri apps.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -10,6 +10,7 @@ const symbolIconButtonPath = path.join(repoRoot, "src", "components", "SymbolIco
10
10
  const galleryPath = path.join(repoRoot, "src", "components", "MacBaseUIGallery.tsx");
11
11
  const dataTablePath = path.join(repoRoot, "src", "components", "MacDataTable.tsx");
12
12
  const windowToolbarPath = path.join(repoRoot, "src", "components", "MacWindowToolbar.tsx");
13
+ const segmentedControlPath = path.join(repoRoot, "src", "components", "MacSegmentedControl.tsx");
13
14
  const symbolServicePath = path.join(repoRoot, "src", "symbols", "systemSymbolService.ts");
14
15
 
15
16
  function readText(filePath) {
@@ -52,6 +53,7 @@ const symbolIconButtonSource = readText(symbolIconButtonPath);
52
53
  const gallerySource = readText(galleryPath);
53
54
  const dataTableSource = readText(dataTablePath);
54
55
  const windowToolbarSource = readText(windowToolbarPath);
56
+ const segmentedControlSource = readText(segmentedControlPath);
55
57
  const symbolServiceSource = readText(symbolServicePath);
56
58
 
57
59
  function getCssRuleBody(selector) {
@@ -298,6 +300,28 @@ if (missingToolbarRequirements.length > 0) {
298
300
  );
299
301
  }
300
302
 
303
+ const missingSegmentedControlRequirements = [
304
+ ["stable segmented control class", /"hd-mac-segmented-control"/],
305
+ ["default accessible label", /ariaLabel = "Segmented control"/],
306
+ ["aria label prop", /aria-label=\{ariaLabel\}/],
307
+ ["aria labelledby prop", /aria-labelledby=\{ariaLabelledBy\}/],
308
+ ["full width class composition", /fullWidth && "hd-mac-segmented-control-full-width"/],
309
+ ["className pass through", /\bclassName,\s*\n\s*style,/],
310
+ ["style pass through", /style=\{style\}/],
311
+ ].filter(([, pattern]) => !pattern.test(segmentedControlSource));
312
+
313
+ if (missingSegmentedControlRequirements.length > 0) {
314
+ fail(
315
+ "Missing MacSegmentedControl accessibility and layout invariants.",
316
+ missingSegmentedControlRequirements.map(([label]) => label),
317
+ );
318
+ }
319
+
320
+ requireCssDeclarations(".hd-mac-segmented-control", [
321
+ ["middle inline alignment", /vertical-align\s*:\s*middle\s*;/],
322
+ ["center transform origin", /transform-origin\s*:\s*center\s*;/],
323
+ ]);
324
+
301
325
  const missingSymbolServiceRequirements = [
302
326
  ["transparent symbol padding trim", /trimTransparentSymbolPadding/],
303
327
  ["alpha threshold trim", /TRANSPARENT_ALPHA_THRESHOLD/],
@@ -1,4 +1,4 @@
1
- import { ReactNode } from "react";
1
+ import { type CSSProperties, type ReactNode } from "react";
2
2
  import { MacSegmentedToggleGroup, MacToggle } from "./MacBaseUI";
3
3
 
4
4
  export type MacSegmentedControlOption<T extends string> = {
@@ -11,21 +11,40 @@ type MacSegmentedControlProps<T extends string> = {
11
11
  options: readonly MacSegmentedControlOption<T>[];
12
12
  value: T;
13
13
  onChange: (value: T) => void;
14
+ ariaLabel?: string;
15
+ ariaLabelledBy?: string;
14
16
  disabled?: boolean;
15
17
  fullWidth?: boolean;
18
+ className?: string;
19
+ style?: CSSProperties;
16
20
  };
17
21
 
22
+ function joinClasses(...classes: Array<string | undefined | false>) {
23
+ return classes.filter(Boolean).join(" ");
24
+ }
25
+
18
26
  export function MacSegmentedControl<T extends string>({
19
27
  options,
20
28
  value,
21
29
  onChange,
30
+ ariaLabel = "Segmented control",
31
+ ariaLabelledBy,
22
32
  disabled,
23
33
  fullWidth,
34
+ className,
35
+ style,
24
36
  }: MacSegmentedControlProps<T>) {
25
37
  return (
26
38
  <MacSegmentedToggleGroup
39
+ aria-label={ariaLabel}
40
+ aria-labelledby={ariaLabelledBy}
27
41
  aria-disabled={disabled || undefined}
28
- className={fullWidth ? "hd-mac-segmented-control-full-width" : undefined}
42
+ className={joinClasses(
43
+ "hd-mac-segmented-control",
44
+ fullWidth && "hd-mac-segmented-control-full-width",
45
+ className,
46
+ )}
47
+ style={style}
29
48
  value={[value]}
30
49
  disabled={disabled}
31
50
  onValueChange={(nextValue) => {
@@ -923,6 +923,11 @@
923
923
  min-height: 28px;
924
924
  }
925
925
 
926
+ .hd-mac-segmented-control {
927
+ vertical-align: middle;
928
+ transform-origin: center;
929
+ }
930
+
926
931
  .hd-mac-separated-segmented-toggle-group {
927
932
  gap: 0;
928
933
  padding: 0;