@hanzogui/use-direction 2.0.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 +21 -0
- package/dist/cjs/index.cjs +18 -0
- package/dist/cjs/index.native.js +21 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/useDirection.cjs +56 -0
- package/dist/cjs/useDirection.native.js +59 -0
- package/dist/cjs/useDirection.native.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +2 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/useDirection.mjs +20 -0
- package/dist/esm/useDirection.mjs.map +1 -0
- package/dist/esm/useDirection.native.js +20 -0
- package/dist/esm/useDirection.native.js.map +1 -0
- package/package.json +43 -0
- package/src/index.ts +1 -0
- package/src/useDirection.tsx +23 -0
- package/types/index.d.ts +3 -0
- package/types/index.d.ts.map +11 -0
- package/types/useDirection.d.ts +12 -0
- package/types/useDirection.d.ts.map +11 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Nate Wienert
|
|
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.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
7
|
+
get: () => from[key],
|
|
8
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
|
+
});
|
|
10
|
+
return to;
|
|
11
|
+
},
|
|
12
|
+
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
13
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
14
|
+
value: !0
|
|
15
|
+
}), mod);
|
|
16
|
+
var index_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(index_exports);
|
|
18
|
+
__reExport(index_exports, require("./useDirection.cjs"), module.exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
9
|
+
get: () => from[key],
|
|
10
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
|
+
});
|
|
12
|
+
return to;
|
|
13
|
+
},
|
|
14
|
+
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
16
|
+
value: !0
|
|
17
|
+
}), mod);
|
|
18
|
+
var index_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(index_exports);
|
|
20
|
+
__reExport(index_exports, require("./useDirection.native.js"), module.exports);
|
|
21
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
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", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: !0
|
|
28
|
+
}) : target, mod)),
|
|
29
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
+
value: !0
|
|
31
|
+
}), mod);
|
|
32
|
+
var useDirection_exports = {};
|
|
33
|
+
__export(useDirection_exports, {
|
|
34
|
+
DirectionProvider: () => DirectionProvider,
|
|
35
|
+
Provider: () => Provider,
|
|
36
|
+
useDirection: () => useDirection
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(useDirection_exports);
|
|
39
|
+
var React = __toESM(require("react"), 1),
|
|
40
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
41
|
+
const DirectionContext = React.createContext(void 0),
|
|
42
|
+
DirectionProvider = props => {
|
|
43
|
+
const {
|
|
44
|
+
dir,
|
|
45
|
+
children
|
|
46
|
+
} = props;
|
|
47
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(DirectionContext.Provider, {
|
|
48
|
+
value: dir,
|
|
49
|
+
children
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
function useDirection(localDir) {
|
|
53
|
+
const globalDir = React.useContext(DirectionContext);
|
|
54
|
+
return localDir || globalDir || "ltr";
|
|
55
|
+
}
|
|
56
|
+
const Provider = DirectionProvider;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
8
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: !0
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
__copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: !0
|
|
30
|
+
}) : target, mod)),
|
|
31
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: !0
|
|
33
|
+
}), mod);
|
|
34
|
+
var useDirection_exports = {};
|
|
35
|
+
__export(useDirection_exports, {
|
|
36
|
+
DirectionProvider: () => DirectionProvider,
|
|
37
|
+
Provider: () => Provider,
|
|
38
|
+
useDirection: () => useDirection
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(useDirection_exports);
|
|
41
|
+
var import_jsx_runtime = require("react/jsx-runtime"),
|
|
42
|
+
React = __toESM(require("react"), 1),
|
|
43
|
+
DirectionContext = /* @__PURE__ */React.createContext(void 0),
|
|
44
|
+
DirectionProvider = function (props) {
|
|
45
|
+
var {
|
|
46
|
+
dir,
|
|
47
|
+
children
|
|
48
|
+
} = props;
|
|
49
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(DirectionContext.Provider, {
|
|
50
|
+
value: dir,
|
|
51
|
+
children
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
function useDirection(localDir) {
|
|
55
|
+
var globalDir = React.useContext(DirectionContext);
|
|
56
|
+
return localDir || globalDir || "ltr";
|
|
57
|
+
}
|
|
58
|
+
var Provider = DirectionProvider;
|
|
59
|
+
//# sourceMappingURL=useDirection.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","useDirection_exports","__export","DirectionProvider","Provider","useDirection","module","exports","import_jsx_runtime","require","React","__toESM","DirectionContext","createContext","props","dir","children","jsx","localDir","globalDir","useContext"],"sources":["../../src/useDirection.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,oBAAA;AAAAC,QAAA,CAAAD,oBAAA;EAAAE,iBAAA,EAAAA,CAAA,KAAAA,iBAAA;EAAAC,QAAA,EAAAA,CAAA,KAAAA,QAAA;EAAAC,YAAA,EAAAA,CAAA,KAAAA;AAAA;AAEAC,MAAA,CAAAC,OAAuB,GAAAX,YAAA,CAAAK,oBAYd;AATT,IAAAO,kBAAM,GAAmBC,OAAM,oBAA8C;EAOhEC,KAAA,GAAAC,OAAA,CAAAF,OAAuD,QAAU;EAAAG,gBAAA,kBAAAF,KAAA,CAAAG,aAAA;EAAAV,iBAAA,YAAAA,CAAAW,KAAA;IAC5E;MAAMC,GAAE;MAAAC;IAAK,IAASF,KAAI;IAC1B,OAAO,mBAAAN,kBAAA,CAAAS,GAAA,EAACL,gBAAA,CAAiBR,QAAA,EAAjB;MACVJ,KAAA,EAAAe,GAAA;MAEOC;IACL;EACA;AACF,SAAAX,aAAAa,QAAA;EAEO,IAAMC,SAAA,GAA6CT,KAAA,CAAAU,UAAA,CAAAR,gBAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
const DirectionContext = React.createContext(void 0),
|
|
4
|
+
DirectionProvider = props => {
|
|
5
|
+
const {
|
|
6
|
+
dir,
|
|
7
|
+
children
|
|
8
|
+
} = props;
|
|
9
|
+
return /* @__PURE__ */jsx(DirectionContext.Provider, {
|
|
10
|
+
value: dir,
|
|
11
|
+
children
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
function useDirection(localDir) {
|
|
15
|
+
const globalDir = React.useContext(DirectionContext);
|
|
16
|
+
return localDir || globalDir || "ltr";
|
|
17
|
+
}
|
|
18
|
+
const Provider = DirectionProvider;
|
|
19
|
+
export { DirectionProvider, Provider, useDirection };
|
|
20
|
+
//# sourceMappingURL=useDirection.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","jsx","DirectionContext","createContext","DirectionProvider","props","dir","children","Provider","value","useDirection","localDir","globalDir","useContext"],"sources":["../../src/useDirection.tsx"],"sourcesContent":[null],"mappings":"AAEA,YAAYA,KAAA,MAAW;AAYd,SAAAC,GAAA;AATT,MAAMC,gBAAA,GAAmBF,KAAA,CAAMG,aAAA,CAAqC,MAAS;EAOhEC,iBAAA,GAAuDC,KAAA,IAAU;IAC5E,MAAM;MAAEC,GAAA;MAAKC;IAAS,IAAIF,KAAA;IAC1B,OAAO,eAAAJ,GAAA,CAACC,gBAAA,CAAiBM,QAAA,EAAjB;MAA0BC,KAAA,EAAOH,GAAA;MAAMC;IAAA,CAAS;EAC1D;AAEO,SAASG,aAAaC,QAAA,EAAiC;EAC5D,MAAMC,SAAA,GAAYZ,KAAA,CAAMa,UAAA,CAAWX,gBAAgB;EACnD,OAAOS,QAAA,IAAYC,SAAA,IAAa;AAClC;AAEO,MAAMJ,QAAA,GAA6CJ,iBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
var DirectionContext = /* @__PURE__ */React.createContext(void 0),
|
|
4
|
+
DirectionProvider = function (props) {
|
|
5
|
+
var {
|
|
6
|
+
dir,
|
|
7
|
+
children
|
|
8
|
+
} = props;
|
|
9
|
+
return /* @__PURE__ */_jsx(DirectionContext.Provider, {
|
|
10
|
+
value: dir,
|
|
11
|
+
children
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
function useDirection(localDir) {
|
|
15
|
+
var globalDir = React.useContext(DirectionContext);
|
|
16
|
+
return localDir || globalDir || "ltr";
|
|
17
|
+
}
|
|
18
|
+
var Provider = DirectionProvider;
|
|
19
|
+
export { DirectionProvider, Provider, useDirection };
|
|
20
|
+
//# sourceMappingURL=useDirection.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["jsx","_jsx","React","DirectionContext","createContext","DirectionProvider","props","dir","children","Provider","value","useDirection","localDir","globalDir","useContext"],"sources":["../../src/useDirection.tsx"],"sourcesContent":[null],"mappings":"AAEA,SAAAA,GAAY,IAAAC,IAAA,QAAW;AAYd,YAAAC,KAAA;AATT,IAAAC,gBAAM,kBAAyBD,KAAA,CAAqCE,aAOvD;EAAAC,iBAAiE,YAAAA,CAAAC,KAAA;IAC5E;MAAMC,GAAE;MAAAC;IAAK,IAASF,KAAI;IAC1B,OAAO,eAAAL,IAAC,CAAAE,gBAAiB,CAAAM,QAAA,EAAjB;MACVC,KAAA,EAAAH,GAAA;MAEOC;IACL;EACA;AACF,SAAAG,aAAAC,QAAA;EAEO,IAAMC,SAAA,GAA6CX,KAAA,CAAAY,UAAA,CAAAX,gBAAA","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hanzogui/use-direction",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
|
+
"files": [
|
|
6
|
+
"src",
|
|
7
|
+
"types",
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"main": "dist/cjs",
|
|
13
|
+
"module": "dist/esm",
|
|
14
|
+
"types": "./types/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
"./package.json": "./package.json",
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./types/index.d.ts",
|
|
19
|
+
"react-native": "./dist/esm/index.native.js",
|
|
20
|
+
"browser": "./dist/esm/index.mjs",
|
|
21
|
+
"module": "./dist/esm/index.mjs",
|
|
22
|
+
"import": "./dist/esm/index.mjs",
|
|
23
|
+
"require": "./dist/cjs/index.cjs",
|
|
24
|
+
"default": "./dist/esm/index.mjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "hanzo-gui-build",
|
|
32
|
+
"watch": "hanzo-gui-build --watch",
|
|
33
|
+
"clean": "hanzo-gui-build clean",
|
|
34
|
+
"clean:build": "hanzo-gui-build clean:build"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@hanzogui/build": "workspace:*",
|
|
38
|
+
"react": ">=19"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"react": ">=19"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useDirection'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// forked from https://github.com/radix-ui/primitives/blob/main/packages/react/direction/src/Direction.tsx
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
|
|
5
|
+
type Direction = 'ltr' | 'rtl'
|
|
6
|
+
const DirectionContext = React.createContext<Direction | undefined>(undefined)
|
|
7
|
+
|
|
8
|
+
interface DirectionProviderProps {
|
|
9
|
+
children?: React.ReactNode
|
|
10
|
+
dir: Direction
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const DirectionProvider: React.FC<DirectionProviderProps> = (props) => {
|
|
14
|
+
const { dir, children } = props
|
|
15
|
+
return <DirectionContext.Provider value={dir}>{children}</DirectionContext.Provider>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function useDirection(localDir?: Direction): Direction {
|
|
19
|
+
const globalDir = React.useContext(DirectionContext)
|
|
20
|
+
return localDir || globalDir || 'ltr'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const Provider: React.FC<DirectionProviderProps> = DirectionProvider
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
type Direction = "ltr" | "rtl";
|
|
3
|
+
interface DirectionProviderProps {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
dir: Direction;
|
|
6
|
+
}
|
|
7
|
+
export declare const DirectionProvider: React.FC<DirectionProviderProps>;
|
|
8
|
+
export declare function useDirection(localDir?: Direction): Direction;
|
|
9
|
+
export declare const Provider: React.FC<DirectionProviderProps>;
|
|
10
|
+
export {};
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=useDirection.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mappings": "AAEA,YAAY,WAAW;KAElB,YAAY,QAAQ;UAGf,uBAAuB;CAC/B,WAAW,MAAM;CACjB,KAAK;;AAGP,OAAO,cAAM,mBAAmB,MAAM,GAAG;AAKzC,OAAO,iBAAS,aAAa,WAAW,YAAY;AAKpD,OAAO,cAAM,UAAU,MAAM,GAAG",
|
|
3
|
+
"names": [],
|
|
4
|
+
"sources": [
|
|
5
|
+
"src/useDirection.tsx"
|
|
6
|
+
],
|
|
7
|
+
"version": 3,
|
|
8
|
+
"sourcesContent": [
|
|
9
|
+
"// forked from https://github.com/radix-ui/primitives/blob/main/packages/react/direction/src/Direction.tsx\n\nimport * as React from 'react'\n\ntype Direction = 'ltr' | 'rtl'\nconst DirectionContext = React.createContext<Direction | undefined>(undefined)\n\ninterface DirectionProviderProps {\n children?: React.ReactNode\n dir: Direction\n}\n\nexport const DirectionProvider: React.FC<DirectionProviderProps> = (props) => {\n const { dir, children } = props\n return <DirectionContext.Provider value={dir}>{children}</DirectionContext.Provider>\n}\n\nexport function useDirection(localDir?: Direction): Direction {\n const globalDir = React.useContext(DirectionContext)\n return localDir || globalDir || 'ltr'\n}\n\nexport const Provider: React.FC<DirectionProviderProps> = DirectionProvider\n"
|
|
10
|
+
]
|
|
11
|
+
}
|