@itcase/storybook-config 1.2.54 → 1.2.56

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/README.md CHANGED
@@ -67,4 +67,3 @@ npm run storybook-react-native-web
67
67
  # или:
68
68
  make storybook-react-native-web
69
69
  ```
70
-
@@ -0,0 +1,16 @@
1
+ function getFigmaSourceLink(getMeta) {
2
+ const meta = getMeta()
3
+ const links = meta.design.reduce((result, item) => {
4
+ result[`figma${item.name}`] = () => {
5
+ return {
6
+ label: `Figma${item.name} — + ${meta.title}`,
7
+ href: item.url,
8
+ icon: 'FigmaIcon',
9
+ }
10
+ }
11
+ return result
12
+ }, {})
13
+ return links
14
+ }
15
+
16
+ export { getFigmaSourceLink }
@@ -0,0 +1,57 @@
1
+ import camelCase from 'lodash/camelCase'
2
+
3
+ import { axiosInstanceITCase } from '@itcase/common'
4
+
5
+ async function getStoryInfoBlocks(infoBlockSlugsList = []) {
6
+ const slugsList = []
7
+ const regExpsList = []
8
+
9
+ infoBlockSlugsList.forEach((slug) => {
10
+ if (slug instanceof RegExp) {
11
+ regExpsList.push(slug)
12
+ } else {
13
+ slugsList.push(slug)
14
+ }
15
+ })
16
+
17
+ const slugsQuery = slugsList.join(',')
18
+ const response = await axiosInstanceITCase.get(
19
+ `/rest/infoblocks/?active=true&slugs=${slugsQuery}`,
20
+ )
21
+ const infoBlocksList = response.data.results || []
22
+ const infoBlocks = infoBlocksList.reduce((resultData, infoBlockItem) => {
23
+ const targetSlugRegExp = regExpsList.find((slugRegExp) => {
24
+ return slugRegExp.test(infoBlockItem.slug)
25
+ })
26
+
27
+ if (targetSlugRegExp) {
28
+ const key = camelCase(infoBlockItem.slug)
29
+ if (resultData[key]) {
30
+ resultData[key].push(infoBlockItem)
31
+ } else {
32
+ resultData[key] = [infoBlockItem]
33
+ }
34
+ return resultData
35
+ }
36
+
37
+ const targetSlug = slugsList.find((slug) => {
38
+ return slug === infoBlockItem.slug
39
+ })
40
+
41
+ if (targetSlug) {
42
+ const key = camelCase(targetSlug)
43
+ resultData[key] = infoBlockItem
44
+ return resultData
45
+ }
46
+
47
+ // If no specific infoBlocks are assigned to this page,
48
+ // then we use the "slug" as a key for the infoBlocks dictionary.
49
+ const infoBlockKey = camelCase(infoBlockItem.slug)
50
+ resultData[infoBlockKey] = infoBlockItem
51
+ return resultData
52
+ }, {})
53
+
54
+ return infoBlocks
55
+ }
56
+
57
+ export { getStoryInfoBlocks }
@@ -0,0 +1,17 @@
1
+ import { serverErrorHandler } from '../config/msw/mswHandlers'
2
+
3
+ function handleMSWParameters(parameters, args) {
4
+ let mswHandlersParams = {}
5
+
6
+ if (parameters.serverError) {
7
+ mswHandlersParams = {
8
+ msw: {
9
+ handlers: [serverErrorHandler(args.errors)],
10
+ },
11
+ }
12
+ }
13
+
14
+ return mswHandlersParams
15
+ }
16
+
17
+ export { handleMSWParameters }
@@ -0,0 +1,11 @@
1
+ function hasFormParameters(parameters) {
2
+ return Boolean(
3
+ parameters.require ||
4
+ parameters.validation ||
5
+ parameters.error ||
6
+ parameters.serverError ||
7
+ parameters.serverErrorData,
8
+ )
9
+ }
10
+
11
+ export { hasFormParameters }
@@ -0,0 +1,13 @@
1
+ import { getFigmaSourceLink } from './getFigmaSourceLink'
2
+ import { getStoryInfoBlocks } from './getStoryInfoBlocks'
3
+ import { handleMSWParameters } from './handleMSWParameters'
4
+ import { hasFormParameters } from './hasFormParameters'
5
+ import { storybookFormMockFactory } from './storybookFormMockFactory'
6
+
7
+ export {
8
+ getFigmaSourceLink,
9
+ getStoryInfoBlocks,
10
+ handleMSWParameters,
11
+ hasFormParameters,
12
+ storybookFormMockFactory,
13
+ }
@@ -0,0 +1,105 @@
1
+ import {
2
+ serverErrorDataHandler,
3
+ serverErrorHandler,
4
+ } from '../config/msw/mswHandlers'
5
+
6
+ function storybookFormMockFactory(payload) {
7
+ const {
8
+ filled,
9
+ initialValues,
10
+ require,
11
+ serverError,
12
+ serverErrorData,
13
+ validation,
14
+ } = payload
15
+
16
+ const stories = {}
17
+
18
+ stories.Default = {
19
+ parameters: {
20
+ default: true,
21
+ },
22
+ }
23
+
24
+ stories.Filled = {
25
+ args: {
26
+ initialValues: filled,
27
+ },
28
+ parameters: {
29
+ filled: true,
30
+ },
31
+ }
32
+
33
+ if (initialValues) {
34
+ stories.InitialValues = {
35
+ args: {
36
+ initialValues,
37
+ },
38
+ parameters: {
39
+ initialValues: true,
40
+ },
41
+ }
42
+ }
43
+
44
+ stories.Loading = {
45
+ args: {
46
+ initialIsLoading: true,
47
+ },
48
+ }
49
+
50
+ if (require) {
51
+ stories.Require = {
52
+ args: {
53
+ initialValues: require,
54
+ },
55
+ parameters: {
56
+ require: true,
57
+ },
58
+ }
59
+ }
60
+
61
+ if (serverError) {
62
+ stories.ServerError = {
63
+ args: {
64
+ initialValues: filled,
65
+ },
66
+ parameters: {
67
+ msw: {
68
+ handlers: [serverErrorHandler(serverError)],
69
+ },
70
+ serverError: true,
71
+ },
72
+ }
73
+ }
74
+
75
+ if (serverErrorData) {
76
+ stories.ServerErrorData = {
77
+ args: {
78
+ initialValues: filled,
79
+ },
80
+ parameters: {
81
+ msw: {
82
+ handlers: [serverErrorDataHandler(serverErrorData)],
83
+ },
84
+ serverErrorData: true,
85
+ },
86
+ }
87
+ }
88
+
89
+ if (validation) {
90
+ stories.Validation = {
91
+ args: {
92
+ initialValues: validation,
93
+ },
94
+ parameters: {
95
+ validation: true,
96
+ },
97
+ }
98
+ }
99
+
100
+ return {
101
+ ...stories,
102
+ }
103
+ }
104
+
105
+ export { storybookFormMockFactory }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/storybook-config",
3
- "version": "1.2.54",
3
+ "version": "1.2.56",
4
4
  "author": "ITCase",
5
5
  "description": "Storybook configuration package",
6
6
  "engines": {
@@ -116,10 +116,10 @@
116
116
  "babel-plugin-transform-inline-environment-variables": "^0.4.4",
117
117
  "chalk": "^5.6.2",
118
118
  "http-proxy-middleware": "^4.0.0",
119
- "msw": "^2.14.3",
119
+ "msw": "^2.14.5",
120
120
  "msw-storybook-addon": "^2.0.7",
121
121
  "react-native-gesture-handler": "^2.31.2",
122
- "react-native-reanimated": "^4.3.0",
122
+ "react-native-reanimated": "^4.3.1",
123
123
  "react-native-safe-area-context": "^5.7.0",
124
124
  "react-native-svg": "^15.15.4",
125
125
  "react-native-web": "^0.21.2",
@@ -142,7 +142,7 @@
142
142
  "@itcase/common": "^1.2.41",
143
143
  "@itcase/lint": "^1.1.110",
144
144
  "@itcase/ui-core": "^1.9.97",
145
- "@itcase/ui-web": "^1.9.99",
145
+ "@itcase/ui-web": "^1.9.100",
146
146
  "@react-native-community/cli": "20.1.3",
147
147
  "@react-native-community/cli-platform-android": "20.1.3",
148
148
  "@react-native-community/cli-platform-ios": "20.1.3",
@@ -165,7 +165,7 @@
165
165
  "glob": "^13.0.6",
166
166
  "husky": "^9.1.7",
167
167
  "lint-staged": "^17.0.2",
168
- "next": "^16.2.5",
168
+ "next": "^16.2.6",
169
169
  "prettier": "^3.8.3",
170
170
  "react": "^18",
171
171
  "react-dom": "^18",