@huin-core/react-separator 1.0.2 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +67 -0
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +34 -0
- package/dist/index.mjs.map +7 -0
- package/package.json +3 -2
package/dist/index.d.mts
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { Primitive } from '@huin-core/react-primitive';
|
3
|
+
|
4
|
+
declare const ORIENTATIONS: readonly ["horizontal", "vertical"];
|
5
|
+
type Orientation = (typeof ORIENTATIONS)[number];
|
6
|
+
type PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;
|
7
|
+
interface SeparatorProps extends PrimitiveDivProps {
|
8
|
+
/**
|
9
|
+
* Either `vertical` or `horizontal`. Defaults to `horizontal`.
|
10
|
+
*/
|
11
|
+
orientation?: Orientation;
|
12
|
+
/**
|
13
|
+
* Whether or not the component is purely decorative. When true, accessibility-related attributes
|
14
|
+
* are updated so that that the rendered element is removed from the accessibility tree.
|
15
|
+
*/
|
16
|
+
decorative?: boolean;
|
17
|
+
}
|
18
|
+
declare const Separator: React.ForwardRefExoticComponent<SeparatorProps & React.RefAttributes<HTMLDivElement>>;
|
19
|
+
declare const Root: React.ForwardRefExoticComponent<SeparatorProps & React.RefAttributes<HTMLDivElement>>;
|
20
|
+
|
21
|
+
export { Root, Separator, type SeparatorProps };
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { Primitive } from '@huin-core/react-primitive';
|
3
|
+
|
4
|
+
declare const ORIENTATIONS: readonly ["horizontal", "vertical"];
|
5
|
+
type Orientation = (typeof ORIENTATIONS)[number];
|
6
|
+
type PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;
|
7
|
+
interface SeparatorProps extends PrimitiveDivProps {
|
8
|
+
/**
|
9
|
+
* Either `vertical` or `horizontal`. Defaults to `horizontal`.
|
10
|
+
*/
|
11
|
+
orientation?: Orientation;
|
12
|
+
/**
|
13
|
+
* Whether or not the component is purely decorative. When true, accessibility-related attributes
|
14
|
+
* are updated so that that the rendered element is removed from the accessibility tree.
|
15
|
+
*/
|
16
|
+
decorative?: boolean;
|
17
|
+
}
|
18
|
+
declare const Separator: React.ForwardRefExoticComponent<SeparatorProps & React.RefAttributes<HTMLDivElement>>;
|
19
|
+
declare const Root: React.ForwardRefExoticComponent<SeparatorProps & React.RefAttributes<HTMLDivElement>>;
|
20
|
+
|
21
|
+
export { Root, Separator, type SeparatorProps };
|
package/dist/index.js
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
|
30
|
+
// packages/react/separator/src/index.ts
|
31
|
+
var src_exports = {};
|
32
|
+
__export(src_exports, {
|
33
|
+
Root: () => Root,
|
34
|
+
Separator: () => Separator
|
35
|
+
});
|
36
|
+
module.exports = __toCommonJS(src_exports);
|
37
|
+
|
38
|
+
// packages/react/separator/src/Separator.tsx
|
39
|
+
var React = __toESM(require("react"));
|
40
|
+
var import_react_primitive = require("@huin-core/react-primitive");
|
41
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
42
|
+
var NAME = "Separator";
|
43
|
+
var DEFAULT_ORIENTATION = "horizontal";
|
44
|
+
var ORIENTATIONS = ["horizontal", "vertical"];
|
45
|
+
var Separator = React.forwardRef(
|
46
|
+
(props, forwardedRef) => {
|
47
|
+
const { decorative, orientation: orientationProp = DEFAULT_ORIENTATION, ...domProps } = props;
|
48
|
+
const orientation = isValidOrientation(orientationProp) ? orientationProp : DEFAULT_ORIENTATION;
|
49
|
+
const ariaOrientation = orientation === "vertical" ? orientation : void 0;
|
50
|
+
const semanticProps = decorative ? { role: "none" } : { "aria-orientation": ariaOrientation, role: "separator" };
|
51
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
52
|
+
import_react_primitive.Primitive.div,
|
53
|
+
{
|
54
|
+
"data-orientation": orientation,
|
55
|
+
...semanticProps,
|
56
|
+
...domProps,
|
57
|
+
ref: forwardedRef
|
58
|
+
}
|
59
|
+
);
|
60
|
+
}
|
61
|
+
);
|
62
|
+
Separator.displayName = NAME;
|
63
|
+
function isValidOrientation(orientation) {
|
64
|
+
return ORIENTATIONS.includes(orientation);
|
65
|
+
}
|
66
|
+
var Root = Separator;
|
67
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../src/index.ts", "../src/Separator.tsx"],
|
4
|
+
"sourcesContent": ["export {\n Separator,\n //\n Root,\n} from './Separator';\nexport type { SeparatorProps } from './Separator';\n", "import * as React from \"react\";\nimport { Primitive } from \"@huin-core/react-primitive\";\n\n/* -------------------------------------------------------------------------------------------------\n * Separator\n * -----------------------------------------------------------------------------------------------*/\n\nconst NAME = \"Separator\";\nconst DEFAULT_ORIENTATION = \"horizontal\";\nconst ORIENTATIONS = [\"horizontal\", \"vertical\"] as const;\n\ntype Orientation = (typeof ORIENTATIONS)[number];\ntype SeparatorElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface SeparatorProps extends PrimitiveDivProps {\n /**\n * Either `vertical` or `horizontal`. Defaults to `horizontal`.\n */\n orientation?: Orientation;\n /**\n * Whether or not the component is purely decorative. When true, accessibility-related attributes\n * are updated so that that the rendered element is removed from the accessibility tree.\n */\n decorative?: boolean;\n}\n\nconst Separator = React.forwardRef<SeparatorElement, SeparatorProps>(\n (props, forwardedRef) => {\n const { decorative, orientation: orientationProp = DEFAULT_ORIENTATION, ...domProps } = props;\n const orientation = isValidOrientation(orientationProp)\n ? orientationProp\n : DEFAULT_ORIENTATION;\n // `aria-orientation` defaults to `horizontal` so we only need it if `orientation` is vertical\n const ariaOrientation =\n orientation === \"vertical\" ? orientation : undefined;\n const semanticProps = decorative\n ? { role: \"none\" }\n : { \"aria-orientation\": ariaOrientation, role: \"separator\" };\n\n return (\n <Primitive.div\n data-orientation={orientation}\n {...semanticProps}\n {...domProps}\n ref={forwardedRef}\n />\n );\n }\n);\n\nSeparator.displayName = NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction isValidOrientation(orientation: any): orientation is Orientation {\n return ORIENTATIONS.includes(orientation);\n}\n\nconst Root = Separator;\n\nexport {\n Separator,\n //\n Root,\n};\nexport type { SeparatorProps };\n"],
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,6BAA0B;AAuCpB;AAjCN,IAAM,OAAO;AACb,IAAM,sBAAsB;AAC5B,IAAM,eAAe,CAAC,cAAc,UAAU;AAiB9C,IAAM,YAAkB;AAAA,EACtB,CAAC,OAAO,iBAAiB;AACvB,UAAM,EAAE,YAAY,aAAa,kBAAkB,qBAAqB,GAAG,SAAS,IAAI;AACxF,UAAM,cAAc,mBAAmB,eAAe,IAClD,kBACA;AAEJ,UAAM,kBACJ,gBAAgB,aAAa,cAAc;AAC7C,UAAM,gBAAgB,aAClB,EAAE,MAAM,OAAO,IACf,EAAE,oBAAoB,iBAAiB,MAAM,YAAY;AAE7D,WACE;AAAA,MAAC,iCAAU;AAAA,MAAV;AAAA,QACC,oBAAkB;AAAA,QACjB,GAAG;AAAA,QACH,GAAG;AAAA,QACJ,KAAK;AAAA;AAAA,IACP;AAAA,EAEJ;AACF;AAEA,UAAU,cAAc;AAIxB,SAAS,mBAAmB,aAA8C;AACxE,SAAO,aAAa,SAAS,WAAW;AAC1C;AAEA,IAAM,OAAO;",
|
6
|
+
"names": []
|
7
|
+
}
|
package/dist/index.mjs
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
// packages/react/separator/src/Separator.tsx
|
2
|
+
import * as React from "react";
|
3
|
+
import { Primitive } from "@huin-core/react-primitive";
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
5
|
+
var NAME = "Separator";
|
6
|
+
var DEFAULT_ORIENTATION = "horizontal";
|
7
|
+
var ORIENTATIONS = ["horizontal", "vertical"];
|
8
|
+
var Separator = React.forwardRef(
|
9
|
+
(props, forwardedRef) => {
|
10
|
+
const { decorative, orientation: orientationProp = DEFAULT_ORIENTATION, ...domProps } = props;
|
11
|
+
const orientation = isValidOrientation(orientationProp) ? orientationProp : DEFAULT_ORIENTATION;
|
12
|
+
const ariaOrientation = orientation === "vertical" ? orientation : void 0;
|
13
|
+
const semanticProps = decorative ? { role: "none" } : { "aria-orientation": ariaOrientation, role: "separator" };
|
14
|
+
return /* @__PURE__ */ jsx(
|
15
|
+
Primitive.div,
|
16
|
+
{
|
17
|
+
"data-orientation": orientation,
|
18
|
+
...semanticProps,
|
19
|
+
...domProps,
|
20
|
+
ref: forwardedRef
|
21
|
+
}
|
22
|
+
);
|
23
|
+
}
|
24
|
+
);
|
25
|
+
Separator.displayName = NAME;
|
26
|
+
function isValidOrientation(orientation) {
|
27
|
+
return ORIENTATIONS.includes(orientation);
|
28
|
+
}
|
29
|
+
var Root = Separator;
|
30
|
+
export {
|
31
|
+
Root,
|
32
|
+
Separator
|
33
|
+
};
|
34
|
+
//# sourceMappingURL=index.mjs.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../src/Separator.tsx"],
|
4
|
+
"sourcesContent": ["import * as React from \"react\";\nimport { Primitive } from \"@huin-core/react-primitive\";\n\n/* -------------------------------------------------------------------------------------------------\n * Separator\n * -----------------------------------------------------------------------------------------------*/\n\nconst NAME = \"Separator\";\nconst DEFAULT_ORIENTATION = \"horizontal\";\nconst ORIENTATIONS = [\"horizontal\", \"vertical\"] as const;\n\ntype Orientation = (typeof ORIENTATIONS)[number];\ntype SeparatorElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface SeparatorProps extends PrimitiveDivProps {\n /**\n * Either `vertical` or `horizontal`. Defaults to `horizontal`.\n */\n orientation?: Orientation;\n /**\n * Whether or not the component is purely decorative. When true, accessibility-related attributes\n * are updated so that that the rendered element is removed from the accessibility tree.\n */\n decorative?: boolean;\n}\n\nconst Separator = React.forwardRef<SeparatorElement, SeparatorProps>(\n (props, forwardedRef) => {\n const { decorative, orientation: orientationProp = DEFAULT_ORIENTATION, ...domProps } = props;\n const orientation = isValidOrientation(orientationProp)\n ? orientationProp\n : DEFAULT_ORIENTATION;\n // `aria-orientation` defaults to `horizontal` so we only need it if `orientation` is vertical\n const ariaOrientation =\n orientation === \"vertical\" ? orientation : undefined;\n const semanticProps = decorative\n ? { role: \"none\" }\n : { \"aria-orientation\": ariaOrientation, role: \"separator\" };\n\n return (\n <Primitive.div\n data-orientation={orientation}\n {...semanticProps}\n {...domProps}\n ref={forwardedRef}\n />\n );\n }\n);\n\nSeparator.displayName = NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction isValidOrientation(orientation: any): orientation is Orientation {\n return ORIENTATIONS.includes(orientation);\n}\n\nconst Root = Separator;\n\nexport {\n Separator,\n //\n Root,\n};\nexport type { SeparatorProps };\n"],
|
5
|
+
"mappings": ";AAAA,YAAY,WAAW;AACvB,SAAS,iBAAiB;AAuCpB;AAjCN,IAAM,OAAO;AACb,IAAM,sBAAsB;AAC5B,IAAM,eAAe,CAAC,cAAc,UAAU;AAiB9C,IAAM,YAAkB;AAAA,EACtB,CAAC,OAAO,iBAAiB;AACvB,UAAM,EAAE,YAAY,aAAa,kBAAkB,qBAAqB,GAAG,SAAS,IAAI;AACxF,UAAM,cAAc,mBAAmB,eAAe,IAClD,kBACA;AAEJ,UAAM,kBACJ,gBAAgB,aAAa,cAAc;AAC7C,UAAM,gBAAgB,aAClB,EAAE,MAAM,OAAO,IACf,EAAE,oBAAoB,iBAAiB,MAAM,YAAY;AAE7D,WACE;AAAA,MAAC,UAAU;AAAA,MAAV;AAAA,QACC,oBAAkB;AAAA,QACjB,GAAG;AAAA,QACH,GAAG;AAAA,QACJ,KAAK;AAAA;AAAA,IACP;AAAA,EAEJ;AACF;AAEA,UAAU,cAAc;AAIxB,SAAS,mBAAmB,aAA8C;AACxE,SAAO,aAAa,SAAS,WAAW;AAC1C;AAEA,IAAM,OAAO;",
|
6
|
+
"names": []
|
7
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@huin-core/react-separator",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.4",
|
4
4
|
"license": "MIT",
|
5
5
|
"exports": {
|
6
6
|
".": {
|
@@ -20,7 +20,8 @@
|
|
20
20
|
"types": "./dist/index.d.ts",
|
21
21
|
"files": [
|
22
22
|
"dist",
|
23
|
-
"README.md"
|
23
|
+
"README.md",
|
24
|
+
"package.json"
|
24
25
|
],
|
25
26
|
"sideEffects": false,
|
26
27
|
"scripts": {
|