@asnewyla/button-group 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 XD
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # @asnewyla/button-group
2
+
3
+ Groups `@asnewyla/button` components visually (`role="group"`) and propagates
4
+ `variant`, `size`, and `disabled` to every child via context. Any child can
5
+ override an individual prop.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @asnewyla/button-group
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```tsx
16
+ import { Button } from '@asnewyla/button';
17
+ import { ButtonGroup } from '@asnewyla/button-group';
18
+
19
+ <ButtonGroup variant="secondary" aria-label="Text alignment">
20
+ <Button>Left</Button>
21
+ <Button>Center</Button>
22
+ <Button variant="destructive">Right</Button> {/* overrides the group */}
23
+ </ButtonGroup>
24
+ ```
25
+
26
+ ## License
27
+
28
+ MIT
@@ -0,0 +1,12 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { ButtonVariant, ButtonSize } from '@asnewyla/button';
4
+
5
+ declare const ButtonGroup: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "role"> & {
6
+ variant?: ButtonVariant;
7
+ size?: ButtonSize;
8
+ disabled?: boolean;
9
+ children: ReactNode;
10
+ } & react.RefAttributes<HTMLDivElement>>;
11
+
12
+ export { ButtonGroup };
@@ -0,0 +1,12 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { ButtonVariant, ButtonSize } from '@asnewyla/button';
4
+
5
+ declare const ButtonGroup: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "role"> & {
6
+ variant?: ButtonVariant;
7
+ size?: ButtonSize;
8
+ disabled?: boolean;
9
+ children: ReactNode;
10
+ } & react.RefAttributes<HTMLDivElement>>;
11
+
12
+ export { ButtonGroup };
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var button = require('@asnewyla/button');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+
7
+ // src/components/ButtonGroup.tsx
8
+ function ButtonGroupInner({ children, variant, size, disabled, ...restProps }, ref) {
9
+ return (
10
+ // biome-ignore lint/a11y/useSemanticElements: role="group" on a div is a correct WAI-ARIA pattern for a button toolbar; <fieldset> is for form-control groupings and carries unwanted default browser chrome.
11
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref, role: "group", ...restProps, children: /* @__PURE__ */ jsxRuntime.jsx(button.ButtonGroupProvider, { value: { variant, size, disabled }, children }) })
12
+ );
13
+ }
14
+ var ButtonGroup = react.forwardRef(ButtonGroupInner);
15
+
16
+ exports.ButtonGroup = ButtonGroup;
17
+ //# sourceMappingURL=index.js.map
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ButtonGroup.tsx"],"names":["jsx","ButtonGroupProvider","forwardRef"],"mappings":";;;;;;;AAmBA,SAAS,gBAAA,CACP,EAAE,QAAA,EAAU,OAAA,EAAS,MAAM,QAAA,EAAU,GAAG,SAAA,EAAU,EAClD,GAAA,EACA;AACA,EAAA;AAAA;AAAA,mCAEG,KAAA,EAAA,EAAI,GAAA,EAAU,IAAA,EAAK,OAAA,EAAS,GAAG,SAAA,EAC9B,QAAA,kBAAAA,cAAA,CAACC,0BAAA,EAAA,EAAoB,KAAA,EAAO,EAAE,OAAA,EAAS,IAAA,EAAM,QAAA,EAAS,EACnD,UACH,CAAA,EACF;AAAA;AAEJ;AAEO,IAAM,WAAA,GAAcC,iBAAW,gBAAgB","file":"index.js","sourcesContent":["import {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ForwardedRef,\n type ReactNode,\n} from 'react';\nimport {\n ButtonGroupProvider,\n type ButtonVariant,\n type ButtonSize,\n} from '@asnewyla/button';\n\nexport type ButtonGroupProps = Omit<ComponentPropsWithoutRef<'div'>, 'role'> & {\n variant?: ButtonVariant;\n size?: ButtonSize;\n disabled?: boolean;\n children: ReactNode;\n};\n\nfunction ButtonGroupInner(\n { children, variant, size, disabled, ...restProps }: ButtonGroupProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n return (\n // biome-ignore lint/a11y/useSemanticElements: role=\"group\" on a div is a correct WAI-ARIA pattern for a button toolbar; <fieldset> is for form-control groupings and carries unwanted default browser chrome.\n <div ref={ref} role=\"group\" {...restProps}>\n <ButtonGroupProvider value={{ variant, size, disabled }}>\n {children}\n </ButtonGroupProvider>\n </div>\n );\n}\n\nexport const ButtonGroup = forwardRef(ButtonGroupInner);\n"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,16 @@
1
+ import { forwardRef } from 'react';
2
+ import { ButtonGroupProvider } from '@asnewyla/button';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+ // src/components/ButtonGroup.tsx
6
+ function ButtonGroupInner({ children, variant, size, disabled, ...restProps }, ref) {
7
+ return (
8
+ // biome-ignore lint/a11y/useSemanticElements: role="group" on a div is a correct WAI-ARIA pattern for a button toolbar; <fieldset> is for form-control groupings and carries unwanted default browser chrome.
9
+ /* @__PURE__ */ jsx("div", { ref, role: "group", ...restProps, children: /* @__PURE__ */ jsx(ButtonGroupProvider, { value: { variant, size, disabled }, children }) })
10
+ );
11
+ }
12
+ var ButtonGroup = forwardRef(ButtonGroupInner);
13
+
14
+ export { ButtonGroup };
15
+ //# sourceMappingURL=index.mjs.map
16
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ButtonGroup.tsx"],"names":[],"mappings":";;;;;AAmBA,SAAS,gBAAA,CACP,EAAE,QAAA,EAAU,OAAA,EAAS,MAAM,QAAA,EAAU,GAAG,SAAA,EAAU,EAClD,GAAA,EACA;AACA,EAAA;AAAA;AAAA,wBAEG,KAAA,EAAA,EAAI,GAAA,EAAU,IAAA,EAAK,OAAA,EAAS,GAAG,SAAA,EAC9B,QAAA,kBAAA,GAAA,CAAC,mBAAA,EAAA,EAAoB,KAAA,EAAO,EAAE,OAAA,EAAS,IAAA,EAAM,QAAA,EAAS,EACnD,UACH,CAAA,EACF;AAAA;AAEJ;AAEO,IAAM,WAAA,GAAc,WAAW,gBAAgB","file":"index.mjs","sourcesContent":["import {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ForwardedRef,\n type ReactNode,\n} from 'react';\nimport {\n ButtonGroupProvider,\n type ButtonVariant,\n type ButtonSize,\n} from '@asnewyla/button';\n\nexport type ButtonGroupProps = Omit<ComponentPropsWithoutRef<'div'>, 'role'> & {\n variant?: ButtonVariant;\n size?: ButtonSize;\n disabled?: boolean;\n children: ReactNode;\n};\n\nfunction ButtonGroupInner(\n { children, variant, size, disabled, ...restProps }: ButtonGroupProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n return (\n // biome-ignore lint/a11y/useSemanticElements: role=\"group\" on a div is a correct WAI-ARIA pattern for a button toolbar; <fieldset> is for form-control groupings and carries unwanted default browser chrome.\n <div ref={ref} role=\"group\" {...restProps}>\n <ButtonGroupProvider value={{ variant, size, disabled }}>\n {children}\n </ButtonGroupProvider>\n </div>\n );\n}\n\nexport const ButtonGroup = forwardRef(ButtonGroupInner);\n"]}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@asnewyla/button-group",
3
+ "version": "0.1.0",
4
+ "description": "Groups buttons visually and propagates shared props via context",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/xavierDelaFuente/xd-components.git",
9
+ "directory": "packages/button-group"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "main": "dist/index.js",
15
+ "module": "dist/index.mjs",
16
+ "types": "dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "import": "./dist/index.mjs",
20
+ "require": "./dist/index.js",
21
+ "types": "./dist/index.d.ts"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "sideEffects": false,
28
+ "keywords": [
29
+ "react",
30
+ "button-group",
31
+ "button",
32
+ "accessible"
33
+ ],
34
+ "peerDependencies": {
35
+ "react": "^18.0.0 || ^19.0.0",
36
+ "react-dom": "^18.0.0 || ^19.0.0"
37
+ },
38
+ "dependencies": {
39
+ "@asnewyla/button": "0.1.0"
40
+ },
41
+ "devDependencies": {
42
+ "react": "^18.3.0",
43
+ "react-dom": "^18.3.0",
44
+ "tsup": "^8.1.0",
45
+ "vitest": "^2.0.0",
46
+ "@vitest/coverage-v8": "^2.0.0",
47
+ "@testing-library/react": "^16.0.0",
48
+ "@testing-library/user-event": "^14.5.0",
49
+ "@testing-library/jest-dom": "^6.4.0",
50
+ "jsdom": "^24.0.0",
51
+ "typescript": "^5.5.0"
52
+ },
53
+ "scripts": {
54
+ "build": "tsup",
55
+ "test": "vitest run",
56
+ "test:watch": "vitest",
57
+ "test:coverage": "vitest run --coverage",
58
+ "type-check": "tsc --noEmit"
59
+ }
60
+ }