@pindoba/core-affix 0.0.0-alpha-20260617191010

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/LICENSE ADDED
@@ -0,0 +1,12 @@
1
+ Copyright 2025 Eduardo Lopes
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
8
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
9
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
10
+ FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
11
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
12
+ DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ import { AffixApi, AffixBaseProps, AffixFit, AffixForwardProps, AffixPassThrough, AffixSide, AffixSlotPassThrough, ConnectAffixOptions, ElementAttributes } from "./src/types.js";
2
+ import { affixDefaults, connectAffix } from "./src/connect-affix.js";
3
+ export { type AffixApi, type AffixBaseProps, type AffixFit, type AffixForwardProps, type AffixPassThrough, type AffixSide, type AffixSlotPassThrough, type ConnectAffixOptions, type ElementAttributes, affixDefaults, connectAffix };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { affixDefaults, connectAffix } from "./src/connect-affix.js";
2
+ export { affixDefaults, connectAffix };
@@ -0,0 +1,26 @@
1
+ import { AffixApi, ConnectAffixOptions } from "./types.js";
2
+
3
+ //#region src/connect-affix.d.ts
4
+ declare const affixDefaults: {
5
+ readonly side: "start";
6
+ readonly fit: "row";
7
+ readonly decorative: false;
8
+ };
9
+ /**
10
+ * Connect Contract v1.1 — build the `Affix` prop bags.
11
+ *
12
+ * The bag carries the Control Var Contract's structural hooks:
13
+ * `data-affix="start|end"` (the parent row's `:has()` rules flip their edge
14
+ * padding off it; `end` also gets `margin-inline-start: auto` from the
15
+ * contract's base CSS) and `data-affix-fit="content"` (subtree opt-out from
16
+ * addon row-sizing). `decorative` bakes `aria-hidden` next to the recipe's
17
+ * pointer-events opt-out.
18
+ *
19
+ * Merged by hand instead of `defineConnect` so the contract hooks land
20
+ * AFTER `passThrough.root.props` — invariants win (same convention as
21
+ * `connectInput` / `connectNavigation`).
22
+ */
23
+ declare function connectAffix(options?: ConnectAffixOptions): AffixApi;
24
+ //#endregion
25
+ export { affixDefaults, connectAffix };
26
+ //# sourceMappingURL=connect-affix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect-affix.d.ts","names":[],"sources":["../../src/connect-affix.ts"],"mappings":";;;cAIa,aAAA;EAAA;;;;;;;;;;AAoBb;;;;;;;;iBAAgB,YAAA,CAAa,OAAA,GAAS,mBAAA,GAA2B,QAAQ"}
@@ -0,0 +1,40 @@
1
+ import { css, cx } from "@pindoba/styled-system/css";
2
+ import { affixStyles } from "@pindoba/styles-affix";
3
+ //#region src/connect-affix.ts
4
+ const affixDefaults = {
5
+ side: "start",
6
+ fit: "row",
7
+ decorative: false
8
+ };
9
+ /**
10
+ * Connect Contract v1.1 — build the `Affix` prop bags.
11
+ *
12
+ * The bag carries the Control Var Contract's structural hooks:
13
+ * `data-affix="start|end"` (the parent row's `:has()` rules flip their edge
14
+ * padding off it; `end` also gets `margin-inline-start: auto` from the
15
+ * contract's base CSS) and `data-affix-fit="content"` (subtree opt-out from
16
+ * addon row-sizing). `decorative` bakes `aria-hidden` next to the recipe's
17
+ * pointer-events opt-out.
18
+ *
19
+ * Merged by hand instead of `defineConnect` so the contract hooks land
20
+ * AFTER `passThrough.root.props` — invariants win (same convention as
21
+ * `connectInput` / `connectNavigation`).
22
+ */
23
+ function connectAffix(options = {}) {
24
+ const { side = affixDefaults.side, fit = affixDefaults.fit, decorative = affixDefaults.decorative, passThrough, class: className, ...rest } = options;
25
+ const consumerClass = typeof className === "string" ? className : void 0;
26
+ const classes = affixStyles.raw({ decorative });
27
+ return { rootProps: {
28
+ ...rest,
29
+ ...passThrough?.root?.props,
30
+ "data-component": "affix",
31
+ "data-affix": side === "end" ? "end" : "start",
32
+ ...fit === "content" ? { "data-affix-fit": "content" } : {},
33
+ ...decorative ? { "aria-hidden": "true" } : {},
34
+ class: cx(css(classes.root, passThrough?.root?.style), consumerClass)
35
+ } };
36
+ }
37
+ //#endregion
38
+ export { affixDefaults, connectAffix };
39
+
40
+ //# sourceMappingURL=connect-affix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect-affix.js","names":[],"sources":["../../src/connect-affix.ts"],"sourcesContent":["import { css, cx } from \"@pindoba/styled-system/css\";\nimport { affixStyles } from \"@pindoba/styles-affix\";\nimport type { ConnectAffixOptions, AffixApi, AffixBaseProps } from \"./types.js\";\n\nexport const affixDefaults = {\n side: \"start\",\n fit: \"row\",\n decorative: false,\n} as const satisfies Partial<AffixBaseProps>;\n\n/**\n * Connect Contract v1.1 — build the `Affix` prop bags.\n *\n * The bag carries the Control Var Contract's structural hooks:\n * `data-affix=\"start|end\"` (the parent row's `:has()` rules flip their edge\n * padding off it; `end` also gets `margin-inline-start: auto` from the\n * contract's base CSS) and `data-affix-fit=\"content\"` (subtree opt-out from\n * addon row-sizing). `decorative` bakes `aria-hidden` next to the recipe's\n * pointer-events opt-out.\n *\n * Merged by hand instead of `defineConnect` so the contract hooks land\n * AFTER `passThrough.root.props` — invariants win (same convention as\n * `connectInput` / `connectNavigation`).\n */\nexport function connectAffix(options: ConnectAffixOptions = {}): AffixApi {\n const {\n side = affixDefaults.side,\n fit = affixDefaults.fit,\n decorative = affixDefaults.decorative,\n passThrough,\n class: className,\n ...rest\n } = options;\n\n // `class` is `unknown` so every framework's class type assigns cleanly;\n // narrow to a string (drops `null` / non-strings) before merging.\n const consumerClass = typeof className === \"string\" ? className : undefined;\n\n const classes = affixStyles.raw({ decorative });\n\n return {\n rootProps: {\n ...rest,\n ...passThrough?.root?.props,\n // Invariants last — consumer passThrough cannot clobber the contract\n // hooks or the composed class.\n \"data-component\": \"affix\",\n \"data-affix\": side === \"end\" ? \"end\" : \"start\",\n ...(fit === \"content\" ? { \"data-affix-fit\": \"content\" } : {}),\n ...(decorative ? { \"aria-hidden\": \"true\" } : {}),\n class: cx(css(classes.root, passThrough?.root?.style), consumerClass),\n },\n };\n}\n"],"mappings":";;;AAIA,MAAa,gBAAgB;CAC3B,MAAM;CACN,KAAK;CACL,YAAY;AACd;;;;;;;;;;;;;;;AAgBA,SAAgB,aAAa,UAA+B,CAAC,GAAa;CACxE,MAAM,EACJ,OAAO,cAAc,MACrB,MAAM,cAAc,KACpB,aAAa,cAAc,YAC3B,aACA,OAAO,WACP,GAAG,SACD;CAIJ,MAAM,gBAAgB,OAAO,cAAc,WAAW,YAAY,KAAA;CAElE,MAAM,UAAU,YAAY,IAAI,EAAE,WAAW,CAAC;CAE9C,OAAO,EACL,WAAW;EACT,GAAG;EACH,GAAG,aAAa,MAAM;EAGtB,kBAAkB;EAClB,cAAc,SAAS,QAAQ,QAAQ;EACvC,GAAI,QAAQ,YAAY,EAAE,kBAAkB,UAAU,IAAI,CAAC;EAC3D,GAAI,aAAa,EAAE,eAAe,OAAO,IAAI,CAAC;EAC9C,OAAO,GAAG,IAAI,QAAQ,MAAM,aAAa,MAAM,KAAK,GAAG,aAAa;CACtE,EACF;AACF"}
@@ -0,0 +1,85 @@
1
+ import { AffixSlots } from "@pindoba/styles-affix";
2
+ import { SystemStyleObject } from "@pindoba/styled-system/types";
3
+ import { ConnectReturn } from "@pindoba/normalize-props";
4
+
5
+ //#region src/types.d.ts
6
+ /** Loose attribute bag for slots that forward arbitrary HTML attributes. */
7
+ type ElementAttributes = Partial<Record<string, unknown>>;
8
+ /** Which edge of the control row the affix sits on. */
9
+ type AffixSide = "start" | "end";
10
+ /** Row-fit behavior for the affix subtree. */
11
+ type AffixFit = "row" | "content";
12
+ interface AffixSlotPassThrough<T = ElementAttributes> {
13
+ /** Panda style object merged into the slot's class. */
14
+ style?: SystemStyleObject;
15
+ /** Extra HTML attributes spread onto the slot's element. */
16
+ props?: T;
17
+ }
18
+ /** Per-slot `style` + `props` overrides. */
19
+ type AffixPassThrough<RootElementAttributes = ElementAttributes> = {
20
+ root?: AffixSlotPassThrough<RootElementAttributes>;
21
+ };
22
+ /**
23
+ * Base props shared across all frameworks. Each framework extends this with its
24
+ * own element-attribute type and slot inputs (children / snippets / slots).
25
+ */
26
+ type AffixBaseProps<RootElementAttributes = ElementAttributes> = {
27
+ /**
28
+ * Which edge of the control row the affix sits on. `start` renders before
29
+ * the control's content, `end` after (and pushes itself to the far edge).
30
+ * Drives the row's edge-padding flip via `data-affix="start|end"` —
31
+ * logical sides, so RTL mirrors automatically.
32
+ * @default "start"
33
+ * @group Behavior
34
+ */
35
+ side?: AffixSide;
36
+ /**
37
+ * `row` (default) lets row-aware addons (Badge, Stamp, Kbd) size
38
+ * themselves to the control row. `content` opts the affix subtree out of
39
+ * that sizing — children keep their own intrinsic size (e.g. taller or
40
+ * multi-line content that should overflow the row).
41
+ * @default "row"
42
+ * @group Behavior
43
+ */
44
+ fit?: AffixFit;
45
+ /**
46
+ * Marks the affix as pure decoration: hidden from assistive technology
47
+ * (`aria-hidden`) and transparent to pointer/selection, so clicks fall
48
+ * through to the control underneath. Don't combine with interactive
49
+ * children.
50
+ * @default false
51
+ * @group Behavior
52
+ */
53
+ decorative?: boolean;
54
+ /**
55
+ * Per-slot style and HTML-attribute overrides.
56
+ * @group Advanced
57
+ */
58
+ passThrough?: AffixPassThrough<RootElementAttributes>;
59
+ };
60
+ /**
61
+ * The Affix props a host control forwards through its declarative
62
+ * `leading`/`trailing` slot's `passThrough.<slot>.props`. Typed so `decorative`
63
+ * and `fit` autocomplete (and typecheck) at the call site, while the
64
+ * `ElementAttributes` arm still lets arbitrary HTML attributes ride through to
65
+ * the affix box. `side` is intentionally excluded — the host owns the side.
66
+ */
67
+ type AffixForwardProps = Pick<AffixBaseProps, "decorative" | "fit"> & ElementAttributes;
68
+ /**
69
+ * Options accepted by `connectAffix`. Frameworks spread their full prop
70
+ * object in; the index signature lets arbitrary HTML attributes ride through to
71
+ * the root bag, and `class` is the consumer's class string (DOM `class` /
72
+ * React `className`), typed `unknown` so every framework's class type assigns.
73
+ */
74
+ interface ConnectAffixOptions extends Partial<AffixBaseProps<ElementAttributes>> {
75
+ class?: unknown;
76
+ [key: string]: unknown;
77
+ }
78
+ /**
79
+ * Connect Contract v1.1 return — one spreadable `*Props` bag per slot
80
+ * (`rootProps`). Frameworks spread the bags and nothing else.
81
+ */
82
+ type AffixApi = ConnectReturn<AffixSlots>;
83
+ //#endregion
84
+ export { AffixApi, AffixBaseProps, AffixFit, AffixForwardProps, AffixPassThrough, AffixSide, AffixSlotPassThrough, ConnectAffixOptions, ElementAttributes };
85
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/types.ts"],"mappings":";;;;;;KAKY,iBAAA,GAAoB,OAAO,CAAC,MAAA;AAAxC;AAAA,KAGY,SAAA;;KAGA,QAAA;AAAA,UAEK,oBAAA,KAAyB,iBAAA;EAL9B;EAOV,KAAA,GAAQ,iBAAA;;EAER,KAAA,GAAQ,CAAA;AAAA;AANV;AAAA,KAUY,gBAAA,yBAAyC,iBAAA;EACnD,IAAA,GAAO,oBAAA,CAAqB,qBAAA;AAAA;AAXV;AAEpB;;;AAFoB,KAkBR,cAAA,yBAAuC,iBAAA;EAdzC;;;;;;;;EAuBR,IAAA,GAAO,SAAA;EArBC;;AAAC;AAIX;;;;;EA0BE,GAAA,GAAM,QAAA;EAzBqB;;;;;;;;EAkC3B,UAAA;EA3BU;;;;EAgCV,WAAA,GAAc,gBAAA,CAAiB,qBAAA;AAAA;;;;;;;;KAUrB,iBAAA,GAAoB,IAAA,CAAK,cAAA,0BACnC,iBAAA;;;;;;;UAQe,mBAAA,SAA4B,OAAA,CAC3C,cAAA,CAAe,iBAAA;EAEf,KAAA;EAAA,CACC,GAAA;AAAA;;;;;KAOS,QAAA,GAAW,aAAa,CAAC,UAAA"}
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@pindoba/core-affix",
3
+ "version": "0.0.0-alpha-20260617191010",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "sideEffects": false,
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./*": {
15
+ "types": "./dist/src/*.d.ts",
16
+ "import": "./dist/src/*.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "dependencies": {
23
+ "@pindoba/normalize-props": "0.0.0-alpha-20260617191010",
24
+ "@pindoba/styles-affix": "0.0.0-alpha-20260617191010",
25
+ "@pindoba/styled-system": "0.0.0-alpha-20260617191010"
26
+ },
27
+ "devDependencies": {
28
+ "tsdown": "^0.22.2",
29
+ "typescript": "^6.0.3"
30
+ },
31
+ "scripts": {
32
+ "build": "tsdown",
33
+ "dev": "tsdown --watch",
34
+ "clean": "rm -rf dist && rm -rf node_modules && rm -rf .turbo",
35
+ "format": "prettier --check . --ignore-path \"$PRETTIER_IGNORE_PATH\"",
36
+ "format:fix": "prettier --write . --ignore-path \"$PRETTIER_IGNORE_PATH\""
37
+ }
38
+ }