@vnejs/uis.react.toggle-with-text 0.1.3 → 0.1.4

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/package.json CHANGED
@@ -1,32 +1,26 @@
1
1
  {
2
2
  "name": "@vnejs/uis.react.toggle-with-text",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
7
- "build": "node ../../../scripts/build-package.mjs",
8
- "publish:major:plugin": "npm run publish:major",
9
- "publish:minor:plugin": "npm run publish:minor",
10
- "publish:patch:plugin": "npm run publish:patch",
11
- "publish:major": "npm run build && npm version major && npm publish --access public",
12
- "publish:minor": "npm run build && npm version minor && npm publish --access public",
13
- "publish:patch": "npm run build && npm version patch && npm publish --access public"
7
+ "build": "npx @vnejs/monorepo package",
8
+ "publish:major:uis:react": "npm run publish:major",
9
+ "publish:minor:uis:react": "npm run publish:minor",
10
+ "publish:patch:uis:react": "npm run publish:patch",
11
+ "publish:major": "npx @vnejs/monorepo publish major --access public",
12
+ "publish:minor": "npx @vnejs/monorepo publish minor --access public",
13
+ "publish:patch": "npx @vnejs/monorepo publish patch --access public"
14
14
  },
15
15
  "peerDependencies": {
16
- "@bem-react/classname": "1.5.12",
17
- "@vnejs/uis.utils": "~0.1.0",
18
- "react": "19.2.4",
19
- "react-dom": "19.2.4",
20
- "@vnejs/uis.react": "~0.1.0"
16
+ "@vnejs/uis.utils": "~0.1.0"
21
17
  },
22
18
  "devDependencies": {
23
- "@vnejs/uis.react": "~0.1.0",
24
- "typescript": "^6.0.3",
25
- "@types/react": "^19.0.10",
26
- "@types/react-dom": "^19.0.4"
19
+ "@vnejs/uis.react": "~0.1.0"
27
20
  },
28
21
  "files": [
29
22
  "dist",
30
- "package.json"
23
+ "src",
24
+ "tsconfig.json"
31
25
  ]
32
26
  }
@@ -0,0 +1,53 @@
1
+ import { useCallback, useMemo, useState } from "react";
2
+
3
+ import { renderWithVneWrap, VneWrap } from "@vnejs/uis.react";
4
+
5
+ import { ToggleWithText } from "@vnejs/uis.react";
6
+
7
+ export const Common = {
8
+ args: {
9
+ ...VneWrap.DEFAULT_ARGS,
10
+
11
+ gap: 120,
12
+ size: 24,
13
+ isSelected: false,
14
+
15
+ titleWidth: 1200,
16
+
17
+ textSize: 72,
18
+ toggleSize: 120,
19
+ },
20
+ };
21
+
22
+ export default {
23
+ title: "Base/ToggleWithText",
24
+ render: renderWithVneWrap(({ textSize, toggleSize, gap, titleWidth, isSelected }) => {
25
+ const [isToggled, setIsToggled] = useState(false);
26
+
27
+ const onToggle = useCallback(() => setIsToggled((value) => !value), [setIsToggled]);
28
+
29
+ return (
30
+ <ToggleWithText
31
+ titleWidth={titleWidth}
32
+ titleToggled="Включено"
33
+ titleUntoggled="Выключено"
34
+ isToggled={isToggled}
35
+ isSelected={isSelected}
36
+ onToggle={onToggle}
37
+ gap={gap}
38
+ textSize={textSize}
39
+ toggleSize={toggleSize}
40
+ />
41
+ );
42
+ }),
43
+ argTypes: {
44
+ // engine
45
+ ...VneWrap.ARGS,
46
+
47
+ textSize: { control: { type: "number", min: 24, max: 120, step: 12 } },
48
+ toggleSize: { control: { type: "number", min: 24, max: 240, step: 12 } },
49
+ gap: { control: { type: "number", min: 12, max: 240, step: 12 } },
50
+
51
+ titleWidth: { control: { type: "number", min: 360, max: 2400, step: 60 } },
52
+ },
53
+ };
@@ -0,0 +1,38 @@
1
+ import { Text, Flex, Toggle } from "@vnejs/uis.react";
2
+
3
+ export const ToggleWithText = ({
4
+ transition = 300,
5
+ titleToggled = "",
6
+ titleUntoggled = "",
7
+ isToggled = false,
8
+ isSelected = false,
9
+ gap = 120,
10
+ textSize = 72,
11
+ toggleSize = 120,
12
+ titleWidth = 1200,
13
+ onToggle,
14
+ }) => (
15
+ <Flex
16
+ align={Flex.ALIGN.CENTER}
17
+ justify={Flex.JUSTIFY.CENTER}
18
+ direction={Flex.DIRECTION.ROW_REVERSE}
19
+ gap={gap}
20
+ >
21
+ <Toggle
22
+ className="TextHoverSibling"
23
+ isToggled={isToggled}
24
+ onToggle={onToggle}
25
+ isSelected={isSelected}
26
+ size={toggleSize}
27
+ transition={transition}
28
+ />
29
+ <Text
30
+ text={isToggled ? titleToggled : titleUntoggled}
31
+ width={titleWidth}
32
+ isSelected={isSelected}
33
+ size={textSize}
34
+ align={Text.ALIGNS.RIGHT}
35
+ transition={transition}
36
+ />
37
+ </Flex>
38
+ );
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./ToggleWithText";
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": "../../../tsconfig.react.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "rootDir": "src"
6
+ },
7
+ "include": [
8
+ "src/**/*.ts",
9
+ "src/**/*.tsx",
10
+ "../../../globals.d.ts",
11
+ "../../../peer-modules.d.ts"
12
+ ],
13
+ "exclude": [
14
+ "dist",
15
+ "node_modules",
16
+ "src/**/*.stories.tsx"
17
+ ]
18
+ }