@kcuf-ui/backdrop 0.0.1

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) 2019 Alibaba Cloud
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,13 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "default", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _withModel.default;
11
+ }
12
+ });
13
+ var _withModel = _interopRequireDefault(require("./with-model"));
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = Ui;
8
+ var _react = require("react");
9
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
10
+ var _transition = _interopRequireDefault(require("@kcuf-ui/transition"));
11
+ var _backdropHeadless = require("@kcuf-ui/backdrop-headless");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ var ScBackdrop = _styledComponents.default.div.withConfig({
14
+ displayName: "ui__ScBackdrop",
15
+ componentId: "sc-1fyzkif-0"
16
+ })(["position:fixed;inset:0;background-color:hsl(0 0% 0% / 17%);transition:all 300ms ease-in-out;&[data-transition='entering']{opacity:1;}&[data-transition='entered']{opacity:1;}&[data-transition='exiting']{opacity:0;}&[data-transition='exited']{opacity:0;}"]);
17
+ function Ui() {
18
+ var zIndex = (0, _backdropHeadless.useZIndex)();
19
+ var handleClick = (0, _backdropHeadless.useHandleClick)();
20
+ var nodeRef = (0, _react.useRef)(null);
21
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_transition.default, {
22
+ nodeRef: nodeRef,
23
+ in: zIndex > 0,
24
+ mountOnEnter: true,
25
+ unmountOnExit: true,
26
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ScBackdrop, {
27
+ ref: nodeRef,
28
+ style: {
29
+ zIndex: zIndex
30
+ },
31
+ onClick: handleClick
32
+ })
33
+ });
34
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = WithProvider;
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
+ var _reactDom = require("react-dom");
10
+ var _backdropHeadless = _interopRequireDefault(require("@kcuf-ui/backdrop-headless"));
11
+ var _ui = _interopRequireDefault(require("../ui"));
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function WithProvider(props) {
14
+ return /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_backdropHeadless.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, props), {}, {
15
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ui.default, {})
16
+ })), document.body);
17
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './with-model';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["default"],"sources":["../../src/index.ts"],"sourcesContent":["export { default } from './with-model';\n\nexport type {\n BackdropProps\n} from '@kcuf-ui/backdrop-headless';\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,cAAc","ignoreList":[]}
@@ -0,0 +1,28 @@
1
+ import { useRef } from 'react';
2
+ import styled from 'styled-components';
3
+ import Transition from '@kcuf-ui/transition';
4
+ import { useZIndex, useHandleClick } from '@kcuf-ui/backdrop-headless';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ var ScBackdrop = styled.div.withConfig({
7
+ displayName: "ui__ScBackdrop",
8
+ componentId: "sc-1fyzkif-0"
9
+ })(["position:fixed;inset:0;background-color:hsl(0 0% 0% / 17%);transition:all 300ms ease-in-out;&[data-transition='entering']{opacity:1;}&[data-transition='entered']{opacity:1;}&[data-transition='exiting']{opacity:0;}&[data-transition='exited']{opacity:0;}"]);
10
+ export default function Ui() {
11
+ var zIndex = useZIndex();
12
+ var handleClick = useHandleClick();
13
+ var nodeRef = useRef(null);
14
+ return /*#__PURE__*/_jsx(Transition, {
15
+ nodeRef: nodeRef,
16
+ in: zIndex > 0,
17
+ mountOnEnter: true,
18
+ unmountOnExit: true,
19
+ children: /*#__PURE__*/_jsx(ScBackdrop, {
20
+ ref: nodeRef,
21
+ style: {
22
+ zIndex: zIndex
23
+ },
24
+ onClick: handleClick
25
+ })
26
+ });
27
+ }
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["useRef","styled","Transition","useZIndex","useHandleClick","jsx","_jsx","ScBackdrop","div","withConfig","displayName","componentId","Ui","zIndex","handleClick","nodeRef","in","mountOnEnter","unmountOnExit","children","ref","style","onClick"],"sources":["../../../src/ui/index.tsx"],"sourcesContent":["import {\n ReactElement,\n useRef\n} from 'react';\nimport styled from 'styled-components';\n\nimport Transition from '@kcuf-ui/transition';\nimport {\n useZIndex,\n useHandleClick\n} from '@kcuf-ui/backdrop-headless';\n\nconst ScBackdrop = styled.div`\n position: fixed;\n inset: 0;\n background-color: hsl(0 0% 0% / 17%);\n transition: all 300ms ease-in-out;\n \n &[data-transition='entering'] {\n opacity: 1;\n }\n \n &[data-transition='entered'] {\n opacity: 1;\n }\n \n &[data-transition='exiting'] {\n opacity: 0;\n }\n \n &[data-transition='exited'] {\n opacity: 0;\n }\n`;\n\nexport default function Ui(): ReactElement | null {\n const zIndex = useZIndex();\n const handleClick = useHandleClick();\n const nodeRef = useRef<HTMLDivElement>(null);\n \n return <Transition {...{\n nodeRef,\n in: zIndex > 0,\n mountOnEnter: true,\n unmountOnExit: true\n }}>\n <ScBackdrop {...{\n ref: nodeRef,\n style: {\n zIndex\n },\n onClick: handleClick\n }} />\n </Transition>;\n}\n"],"mappings":"AAAA,SAEEA,MAAM,QACD,OAAO;AACd,OAAOC,MAAM,MAAM,mBAAmB;AAEtC,OAAOC,UAAU,MAAM,qBAAqB;AAC5C,SACEC,SAAS,EACTC,cAAc,QACT,4BAA4B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEpC,IAAMC,UAAU,GAAGN,MAAM,CAACO,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,oQAqB5B;AAED,eAAe,SAASC,EAAEA,CAAA,EAAwB;EAChD,IAAMC,MAAM,GAAGV,SAAS,CAAC,CAAC;EAC1B,IAAMW,WAAW,GAAGV,cAAc,CAAC,CAAC;EACpC,IAAMW,OAAO,GAAGf,MAAM,CAAiB,IAAI,CAAC;EAE5C,oBAAOM,IAAA,CAACJ,UAAU;IAChBa,OAAO,EAAPA,OAAO;IACPC,EAAE,EAAEH,MAAM,GAAG,CAAC;IACdI,YAAY,EAAE,IAAI;IAClBC,aAAa,EAAE,IAAI;IAAAC,QAAA,eAEnBb,IAAA,CAACC,UAAU;MACTa,GAAG,EAAEL,OAAO;MACZM,KAAK,EAAE;QACLR,MAAM,EAANA;MACF,CAAC;MACDS,OAAO,EAAER;IAAW,CAClB;EAAC,CACK,CAAC;AACf","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
+ import { createPortal } from 'react-dom';
3
+ import BackdropHeadless from '@kcuf-ui/backdrop-headless';
4
+ import Ui from '../ui';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ export default function WithProvider(props) {
7
+ return /*#__PURE__*/createPortal(/*#__PURE__*/_jsx(BackdropHeadless, _objectSpread(_objectSpread({}, props), {}, {
8
+ children: /*#__PURE__*/_jsx(Ui, {})
9
+ })), document.body);
10
+ }
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["createPortal","BackdropHeadless","Ui","jsx","_jsx","WithProvider","props","_objectSpread","children","document","body"],"sources":["../../../src/with-model/index.tsx"],"sourcesContent":["import {\n ReactPortal\n} from 'react';\nimport {\n createPortal\n} from 'react-dom';\n\nimport BackdropHeadless, {\n BackdropProps\n} from '@kcuf-ui/backdrop-headless';\n\nimport Ui from '../ui';\n\nexport default function WithProvider(props: BackdropProps): ReactPortal {\n return createPortal(<BackdropHeadless {...props}>\n <Ui />\n </BackdropHeadless>, document.body);\n}\n"],"mappings":";AAGA,SACEA,YAAY,QACP,WAAW;AAElB,OAAOC,gBAAgB,MAEhB,4BAA4B;AAEnC,OAAOC,EAAE,MAAM,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEvB,eAAe,SAASC,YAAYA,CAACC,KAAoB,EAAe;EACtE,oBAAON,YAAY,cAACI,IAAA,CAACH,gBAAgB,EAAAM,aAAA,CAAAA,aAAA,KAAKD,KAAK;IAAAE,QAAA,eAC7CJ,IAAA,CAACF,EAAE,IAAE;EAAC,EACU,CAAC,EAAEO,QAAQ,CAACC,IAAI,CAAC;AACrC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export { default } from './with-model';
2
+ export type { BackdropProps } from '@kcuf-ui/backdrop-headless';
@@ -0,0 +1,2 @@
1
+ import { ReactElement } from 'react';
2
+ export default function Ui(): ReactElement | null;
@@ -0,0 +1,3 @@
1
+ import { ReactPortal } from 'react';
2
+ import { BackdropProps } from '@kcuf-ui/backdrop-headless';
3
+ export default function WithProvider(props: BackdropProps): ReactPortal;
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@kcuf-ui/backdrop",
3
+ "version": "0.0.1",
4
+ "description": "A singleton backdrop component.",
5
+ "keywords": [],
6
+ "license": "MIT",
7
+ "sideEffects": false,
8
+ "main": "dist/cjs/index.js",
9
+ "module": "dist/esm/index.js",
10
+ "types": "dist/types/index.d.ts",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/justnewbee/kcuf.git"
14
+ },
15
+ "homepage": "https://github.com/justnewbee/kcuf/tree/main/packages-ui/backdrop",
16
+ "bugs": "https://github.com/justnewbee/kcuf/issues",
17
+ "author": {
18
+ "name": "Jianchun Wang",
19
+ "email": "justnewbee@gmail.com"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "devDependencies": {
25
+ "@babel/cli": "^7.28.6",
26
+ "@babel/core": "^7.29.0",
27
+ "@babel/plugin-transform-react-jsx": "^7.28.6",
28
+ "@babel/plugin-transform-runtime": "^7.29.0",
29
+ "@babel/preset-env": "^7.29.5",
30
+ "@babel/preset-react": "^7.28.5",
31
+ "@babel/preset-typescript": "^7.28.5",
32
+ "@chromatic-com/storybook": "^5.1.2",
33
+ "@storybook/addon-docs": "^10.3.6",
34
+ "@storybook/addon-links": "^10.3.6",
35
+ "@storybook/react-vite": "^10.3.6",
36
+ "@types/react": "^19.2.14",
37
+ "@types/react-dom": "^19.2.3",
38
+ "babel-plugin-styled-components": "^2.1.4",
39
+ "react": "^19.2.6",
40
+ "react-dom": "^19.2.6",
41
+ "rimraf": "^6.1.3",
42
+ "storybook": "^10.3.6",
43
+ "styled-components": "^6.4.1",
44
+ "typescript": "^6.0.3",
45
+ "@kcuf/demo-rc": "^0.6.1",
46
+ "@kcuf/ts-config": "^0.2.0"
47
+ },
48
+ "peerDependencies": {
49
+ "@babel/runtime": ">=7.0.0",
50
+ "react": ">=19.0.0",
51
+ "styled-components": ">=6.0.0"
52
+ },
53
+ "dependencies": {
54
+ "@kcuf-ui/backdrop-headless": "^0.0.1",
55
+ "@kcuf-ui/transition": "^0.0.1"
56
+ },
57
+ "scripts": {
58
+ "start": "storybook dev -p 6006",
59
+ "build:clean": "rimraf dist",
60
+ "build:esm": "ESM=1 babel src -d dist/esm --extensions .ts,.tsx --source-maps",
61
+ "build:cjs": "ESM=0 babel src -d dist/cjs --extensions .ts,.tsx",
62
+ "build:types": "tsc -rootDir src --outDir dist/types --declaration --noEmit false --emitDeclarationOnly --isolatedModules false",
63
+ "build:sb": "storybook build",
64
+ "build": "pnpm build:esm && pnpm build:cjs && pnpm build:types",
65
+ "watch": "pnpm build:esm -w"
66
+ }
67
+ }