@ornikar/kitt-universal 13.3.1 → 13.4.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/babel-plugin-csf-to-jest.js +41 -20
- package/dist/definitions/Picker/Picker.d.ts.map +1 -1
- package/dist/index-browser-all.es.android.js +4 -6
- package/dist/index-browser-all.es.android.js.map +1 -1
- package/dist/index-browser-all.es.ios.js +4 -6
- package/dist/index-browser-all.es.ios.js.map +1 -1
- package/dist/index-browser-all.es.js +4 -6
- package/dist/index-browser-all.es.js.map +1 -1
- package/dist/index-node-14.17.cjs.js +4 -6
- package/dist/index-node-14.17.cjs.js.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +4 -3
|
@@ -6,7 +6,10 @@ module.exports = function babelPluginStorybookCSFToJest({ types }, opts) {
|
|
|
6
6
|
const storybookImportName = 'BabelPluginStorybookCSFToJest_StorybookReact';
|
|
7
7
|
const storiesOfName = 'BabelPluginStorybookCSFToJest_stories';
|
|
8
8
|
|
|
9
|
-
const isStory = (file) =>
|
|
9
|
+
const isStory = (file) =>
|
|
10
|
+
file.opts &&
|
|
11
|
+
file.opts.filename &&
|
|
12
|
+
(file.opts.filename.endsWith('.stories.tsx') || file.opts.filename.endsWith('/stories.tsx'));
|
|
10
13
|
|
|
11
14
|
return {
|
|
12
15
|
name: 'plugin-storybook-csf-to-jest',
|
|
@@ -134,6 +137,7 @@ module.exports = function babelPluginStorybookCSFToJest({ types }, opts) {
|
|
|
134
137
|
|
|
135
138
|
const binding = path.scope.getBinding(declaration.id.name);
|
|
136
139
|
let storyName = declaration.id.name;
|
|
140
|
+
let parameters;
|
|
137
141
|
|
|
138
142
|
binding.referencePaths.forEach((refPath) => {
|
|
139
143
|
if (refPath === path) return; // skip named export
|
|
@@ -154,28 +158,44 @@ module.exports = function babelPluginStorybookCSFToJest({ types }, opts) {
|
|
|
154
158
|
}
|
|
155
159
|
|
|
156
160
|
const prop = refPath.parent.property;
|
|
157
|
-
if (types.isIdentifier(prop)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
id: types.identifier('args'),
|
|
161
|
-
init: assignmentExpression.right,
|
|
162
|
-
});
|
|
163
|
-
}
|
|
161
|
+
if (types.isIdentifier(prop)) {
|
|
162
|
+
if (prop.name === 'args') {
|
|
163
|
+
foundArgs = true;
|
|
164
164
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
prop.name === 'story' &&
|
|
168
|
-
types.isObjectExpression(assignmentExpression.right)
|
|
169
|
-
) {
|
|
170
|
-
const objectExpression = assignmentExpression.right;
|
|
171
|
-
objectExpression.properties.forEach((property) => {
|
|
172
|
-
if (types.isIdentifier(property.key) && property.key.name === 'name') {
|
|
173
|
-
storyName = property.value.value;
|
|
165
|
+
if (declaration.init.body.type !== 'BlockStatement') {
|
|
166
|
+
declaration.init.body = types.blockStatement([types.returnStatement(declaration.init.body)]);
|
|
174
167
|
}
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
168
|
|
|
178
|
-
|
|
169
|
+
declaration.init.body.body.unshift(
|
|
170
|
+
types.variableDeclaration('const', [
|
|
171
|
+
types.variableDeclarator(types.identifier('args'), assignmentExpression.right),
|
|
172
|
+
]),
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (prop.name === 'storyName') {
|
|
177
|
+
if (!types.isStringLiteral(assignmentExpression.right)) {
|
|
178
|
+
throw path.buildCodeFrameError(
|
|
179
|
+
`Invalid storyName, expecting StringLiteral, got "${assignmentExpression.right.type}"`,
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
storyName = assignmentExpression.right.value;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (prop.name === 'story' && types.isObjectExpression(assignmentExpression.right)) {
|
|
186
|
+
throw path.buildCodeFrameError('story.name is deprecated, use storyName instead');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (prop.name === 'parameters') {
|
|
190
|
+
parameters = assignmentExpression.right;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (prop.name === 'decorators') {
|
|
194
|
+
throw path.buildCodeFrameError(
|
|
195
|
+
'Story-specific decorators are not supported, use global decorators instead (in export default).',
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
179
199
|
|
|
180
200
|
memberExpressionPath.parentPath.remove();
|
|
181
201
|
});
|
|
@@ -188,6 +208,7 @@ module.exports = function babelPluginStorybookCSFToJest({ types }, opts) {
|
|
|
188
208
|
types.callExpression(types.memberExpression(types.identifier(storiesOfName), types.identifier('add')), [
|
|
189
209
|
types.stringLiteral(storyName),
|
|
190
210
|
declaration.init,
|
|
211
|
+
...(parameters ? [parameters] : []),
|
|
191
212
|
]),
|
|
192
213
|
);
|
|
193
214
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../src/Picker/Picker.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAUrD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,YAAY,EAAE,CAAC,CAAC;IAChB,mBAAmB,CAAC,EAAE,SAAS,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IACpC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,EACxB,QAAQ,EACR,SAAS,EACT,KAAK,EACL,YAAY,EACZ,mBAAmB,EACnB,MAAM,EACN,eAAe,EACf,OAAO,GACR,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"Picker.d.ts","sourceRoot":"","sources":["../../../src/Picker/Picker.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAUrD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,YAAY,EAAE,CAAC,CAAC;IAChB,mBAAmB,CAAC,EAAE,SAAS,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IACpC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,EACxB,QAAQ,EACR,SAAS,EACT,KAAK,EACL,YAAY,EACZ,mBAAmB,EACnB,MAAM,EACN,eAAe,EACf,OAAO,GACR,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,YAAY,CA4E/B;yBArFe,MAAM"}
|
|
@@ -8237,6 +8237,9 @@ function Picker(_ref) {
|
|
|
8237
8237
|
onValueSelected = _ref.onValueSelected,
|
|
8238
8238
|
onClose = _ref.onClose;
|
|
8239
8239
|
var sx = useSx();
|
|
8240
|
+
var iosTextStyle = sx({
|
|
8241
|
+
color: 'kitt.picker.ios.selected.color'
|
|
8242
|
+
});
|
|
8240
8243
|
|
|
8241
8244
|
// Max height is based on base Modal sizes (which are not themified): padding (4*20*2) + footer (58) + header (58) + default iOS picker height (216)
|
|
8242
8245
|
var _useMediaQuery = useMediaQuery({
|
|
@@ -8253,11 +8256,6 @@ function Picker(_ref) {
|
|
|
8253
8256
|
// We can't set a percentage as it will be computed based on the page height
|
|
8254
8257
|
height: isMatchingMaxHeight ? 'kitt.picker.ios.landscape.height' : 'kitt.picker.ios.default.height'
|
|
8255
8258
|
});
|
|
8256
|
-
var getIosTextStyle = function (isSelected) {
|
|
8257
|
-
return sx({
|
|
8258
|
-
color: isSelected ? 'kitt.picker.ios.selected.color' : undefined
|
|
8259
|
-
});
|
|
8260
|
-
};
|
|
8261
8259
|
var _useState = useState(initialValue),
|
|
8262
8260
|
_useState2 = _slicedToArray(_useState, 2),
|
|
8263
8261
|
value = _useState2[0],
|
|
@@ -8288,7 +8286,7 @@ function Picker(_ref) {
|
|
|
8288
8286
|
|
|
8289
8287
|
// iOS Picker doesn't support a custom Item component, we need to override its props manually for the selected one
|
|
8290
8288
|
return /*#__PURE__*/cloneElement(item, {
|
|
8291
|
-
color:
|
|
8289
|
+
color: item.props.value === value ? iosTextStyle.color : undefined
|
|
8292
8290
|
});
|
|
8293
8291
|
})
|
|
8294
8292
|
}) : /*#__PURE__*/jsx(ScrollView$2, {
|