mac-human-design 0.1.24 → 0.1.26

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,34 @@
2
2
 
3
3
  This file tracks changes between published npm versions of `mac-human-design`.
4
4
 
5
+ ## 0.1.26
6
+
7
+ ### Added
8
+
9
+ - Added safe `className`, `style`, and `tooltipSideOffset` pass-through props
10
+ to `SymbolIconButton`.
11
+ - Added verifier coverage for `SymbolIconButton` pass-through props, fixed
12
+ geometry preservation, tooltip offset handling, and explicit `type="button"`.
13
+
14
+ ### Changed
15
+
16
+ - `SymbolIconButton` now sets `type="button"` so toolbar icon buttons do not
17
+ accidentally submit surrounding forms.
18
+ - Bumped the package to `0.1.26`.
19
+
20
+ ## 0.1.25
21
+
22
+ ### Added
23
+
24
+ - Added accessible label props, a stable `hd-mac-segmented-control` class,
25
+ class/style pass-through, and verifier coverage to `MacSegmentedControl`.
26
+
27
+ ### Changed
28
+
29
+ - `MacSegmentedControl` now has a default accessible label and stable
30
+ center-origin inline alignment for toolbar usage.
31
+ - Bumped the package to `0.1.25`.
32
+
5
33
  ## 0.1.24
6
34
 
7
35
  ### 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.26",
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) {
@@ -191,7 +193,12 @@ if (/\by\s*:/.test(iconMotionBranch)) {
191
193
  const symbolIconRequirements = [
192
194
  ["SymbolIconButton imports MacIconButton", /import\s+\{\s*MacIconButton,\s*MacTooltip\s*\}\s+from\s+["']\.\/MacBaseUI["']/],
193
195
  ["SymbolIconButton render element is MacIconButton", /render=\{\s*<MacIconButton\b/],
194
- ["SymbolIconButton applies hd-mac-symbol-icon-button class", /className=["']hd-mac-symbol-icon-button["']/],
196
+ ["SymbolIconButton applies hd-mac-symbol-icon-button class", /joinClasses\("hd-mac-symbol-icon-button", className\)/],
197
+ ["SymbolIconButton defaults to button type", /type=["']button["']/],
198
+ ["SymbolIconButton supports className pass-through", /\bclassName,\s*\n\s*style,/],
199
+ ["SymbolIconButton supports style pass-through after fixed geometry", /\.\.\.style/],
200
+ ["SymbolIconButton supports tooltip offset", /tooltipSideOffset = 5/],
201
+ ["SymbolIconButton applies tooltip offset", /sideOffset=\{tooltipSideOffset\}/],
195
202
  ["SymbolIconButton exposes aria-busy loading state", /aria-busy=\{isLoading \|\| undefined\}/],
196
203
  ["masked symbol class path", /className=["']hd-mac-symbol-icon hd-mac-symbol-icon-mask["']/],
197
204
  ["fallback symbol class path", /className=["']hd-mac-symbol-icon hd-mac-symbol-icon-fallback["']/],
@@ -298,6 +305,28 @@ if (missingToolbarRequirements.length > 0) {
298
305
  );
299
306
  }
300
307
 
308
+ const missingSegmentedControlRequirements = [
309
+ ["stable segmented control class", /"hd-mac-segmented-control"/],
310
+ ["default accessible label", /ariaLabel = "Segmented control"/],
311
+ ["aria label prop", /aria-label=\{ariaLabel\}/],
312
+ ["aria labelledby prop", /aria-labelledby=\{ariaLabelledBy\}/],
313
+ ["full width class composition", /fullWidth && "hd-mac-segmented-control-full-width"/],
314
+ ["className pass through", /\bclassName,\s*\n\s*style,/],
315
+ ["style pass through", /style=\{style\}/],
316
+ ].filter(([, pattern]) => !pattern.test(segmentedControlSource));
317
+
318
+ if (missingSegmentedControlRequirements.length > 0) {
319
+ fail(
320
+ "Missing MacSegmentedControl accessibility and layout invariants.",
321
+ missingSegmentedControlRequirements.map(([label]) => label),
322
+ );
323
+ }
324
+
325
+ requireCssDeclarations(".hd-mac-segmented-control", [
326
+ ["middle inline alignment", /vertical-align\s*:\s*middle\s*;/],
327
+ ["center transform origin", /transform-origin\s*:\s*center\s*;/],
328
+ ]);
329
+
301
330
  const missingSymbolServiceRequirements = [
302
331
  ["transparent symbol padding trim", /trimTransparentSymbolPadding/],
303
332
  ["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) => {
@@ -1,3 +1,4 @@
1
+ import type { CSSProperties } from "react";
1
2
  import { MacIconButton, MacTooltip } from "./MacBaseUI";
2
3
  import { useSystemSymbol } from "../symbols/useSystemSymbol";
3
4
 
@@ -10,11 +11,18 @@ type SymbolIconButtonProps = {
10
11
  isLoading?: boolean;
11
12
  iconSizePx?: number;
12
13
  symbolEnabled?: boolean;
14
+ className?: string;
15
+ style?: CSSProperties;
16
+ tooltipSideOffset?: number;
13
17
  };
14
18
 
15
19
  const ICON_BUTTON_SIZE = "30px";
16
20
  const ICON_BUTTON_RADIUS = "7px";
17
21
 
22
+ function joinClasses(...classes: Array<string | undefined | false>) {
23
+ return classes.filter(Boolean).join(" ");
24
+ }
25
+
18
26
  export function SymbolIconButton({
19
27
  label,
20
28
  symbolName,
@@ -24,6 +32,9 @@ export function SymbolIconButton({
24
32
  isLoading,
25
33
  iconSizePx = 18,
26
34
  symbolEnabled = true,
35
+ className,
36
+ style,
37
+ tooltipSideOffset = 5,
27
38
  }: SymbolIconButtonProps) {
28
39
  const { dataUrl: symbolDataUrl } = useSystemSymbol({
29
40
  symbolName,
@@ -40,9 +51,10 @@ export function SymbolIconButton({
40
51
  aria-label={label}
41
52
  aria-busy={isLoading || undefined}
42
53
  title={label}
54
+ type="button"
43
55
  disabled={disabled || isLoading}
44
56
  onClick={onClick}
45
- className="hd-mac-symbol-icon-button"
57
+ className={joinClasses("hd-mac-symbol-icon-button", className)}
46
58
  data-loading={isLoading || undefined}
47
59
  style={{
48
60
  width: ICON_BUTTON_SIZE,
@@ -50,6 +62,7 @@ export function SymbolIconButton({
50
62
  height: ICON_BUTTON_SIZE,
51
63
  minHeight: ICON_BUTTON_SIZE,
52
64
  borderRadius: ICON_BUTTON_RADIUS,
65
+ ...style,
53
66
  }}
54
67
  >
55
68
  {symbolDataUrl ? (
@@ -88,7 +101,7 @@ export function SymbolIconButton({
88
101
  }
89
102
  />
90
103
  <MacTooltip.Portal>
91
- <MacTooltip.Positioner sideOffset={5}>
104
+ <MacTooltip.Positioner sideOffset={tooltipSideOffset}>
92
105
  <MacTooltip.Popup>{label}</MacTooltip.Popup>
93
106
  </MacTooltip.Positioner>
94
107
  </MacTooltip.Portal>
@@ -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;