@plasmicpkgs/plasmic-strapi 0.1.156 → 0.1.159
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/dist/index.js +35 -21
- package/dist/index.mjs +35 -21
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -98,6 +98,16 @@ var queryParameters = [
|
|
|
98
98
|
}
|
|
99
99
|
];
|
|
100
100
|
var uniq = (xs) => Array.from(new Set(xs));
|
|
101
|
+
var getAttributes = (item) => {
|
|
102
|
+
if (!item) {
|
|
103
|
+
return void 0;
|
|
104
|
+
}
|
|
105
|
+
if (item.attributes) {
|
|
106
|
+
return item.attributes;
|
|
107
|
+
}
|
|
108
|
+
const { documentId: _documentId, locale: _locale, ...rest } = item;
|
|
109
|
+
return rest;
|
|
110
|
+
};
|
|
101
111
|
|
|
102
112
|
// src/StrapiCredentialsProvider.tsx
|
|
103
113
|
var StrapiCredentialsContext = import_react.default.createContext(void 0);
|
|
@@ -275,18 +285,18 @@ function StrapiCollection({
|
|
|
275
285
|
return /* @__PURE__ */ import_react2.default.createElement("div", null, "Please specify a valid collection.");
|
|
276
286
|
}
|
|
277
287
|
const collectionData = (0, import_dlv.default)(data.data, ["data"]);
|
|
278
|
-
const
|
|
279
|
-
const attributes = (
|
|
288
|
+
const filterFields = collectionData.flatMap((item) => {
|
|
289
|
+
const attributes = getAttributes(item);
|
|
280
290
|
const displayableFields = Object.keys(attributes).filter((field) => {
|
|
281
|
-
var _a
|
|
291
|
+
var _a;
|
|
282
292
|
const value = attributes[field];
|
|
283
|
-
const maybeMime = (
|
|
293
|
+
const maybeMime = (_a = getAttributes(value == null ? void 0 : value.data)) == null ? void 0 : _a.mime;
|
|
284
294
|
return typeof value !== "object" || typeof maybeMime === "string" && maybeMime.startsWith("image");
|
|
285
295
|
});
|
|
286
296
|
return displayableFields;
|
|
287
297
|
});
|
|
288
298
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
289
|
-
strapiFields: uniq(
|
|
299
|
+
strapiFields: uniq(filterFields != null ? filterFields : [])
|
|
290
300
|
});
|
|
291
301
|
if (filterParameter && !filterValue && !filterField) {
|
|
292
302
|
return /* @__PURE__ */ import_react2.default.createElement("div", null, "Please specify a Filter Field and a Filter Value");
|
|
@@ -310,16 +320,19 @@ function StrapiCollection({
|
|
|
310
320
|
if (collection.length === 0) {
|
|
311
321
|
return /* @__PURE__ */ import_react2.default.createElement("div", null, "No collection found ");
|
|
312
322
|
}
|
|
313
|
-
const repElements = noAutoRepeat ? children : collection.map((item, index) =>
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
+
const repElements = noAutoRepeat ? children : collection.map((item, index) => {
|
|
324
|
+
var _a;
|
|
325
|
+
return /* @__PURE__ */ import_react2.default.createElement(
|
|
326
|
+
import_host.DataProvider,
|
|
327
|
+
{
|
|
328
|
+
key: (_a = item.documentId) != null ? _a : item.id,
|
|
329
|
+
name: "strapiItem",
|
|
330
|
+
data: item,
|
|
331
|
+
hidden: true
|
|
332
|
+
},
|
|
333
|
+
/* @__PURE__ */ import_react2.default.createElement(import_host.DataProvider, { name: makeDataProviderName(name), data: item }, (0, import_host.repeatedElement)(index, children))
|
|
334
|
+
);
|
|
335
|
+
});
|
|
323
336
|
return /* @__PURE__ */ import_react2.default.createElement(import_host.DataProvider, { name: "strapiItems", data: collection }, noLayout ? /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, " ", repElements, " ") : /* @__PURE__ */ import_react2.default.createElement("div", { className }, " ", repElements, " "));
|
|
324
337
|
}
|
|
325
338
|
|
|
@@ -349,15 +362,16 @@ function StrapiField({
|
|
|
349
362
|
path,
|
|
350
363
|
setControlContextData
|
|
351
364
|
}) {
|
|
352
|
-
var _a
|
|
365
|
+
var _a;
|
|
353
366
|
const item = (0, import_host2.useSelector)("strapiItem");
|
|
354
367
|
if (!item) {
|
|
355
368
|
return /* @__PURE__ */ import_react3.default.createElement("div", null, "StrapiField must be used within a StrapiCollection");
|
|
356
369
|
}
|
|
357
|
-
const attributes = (
|
|
370
|
+
const attributes = getAttributes(item);
|
|
358
371
|
const displayableFields = Object.keys(attributes).filter((field) => {
|
|
372
|
+
var _a2;
|
|
359
373
|
const value = attributes[field];
|
|
360
|
-
const maybeMime2 = (0
|
|
374
|
+
const maybeMime2 = (_a2 = getAttributes(value == null ? void 0 : value.data)) == null ? void 0 : _a2.mime;
|
|
361
375
|
return typeof value !== "object" || typeof maybeMime2 === "string" && maybeMime2.startsWith("image");
|
|
362
376
|
});
|
|
363
377
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
@@ -367,8 +381,8 @@ function StrapiField({
|
|
|
367
381
|
if (!path) {
|
|
368
382
|
return /* @__PURE__ */ import_react3.default.createElement("div", null, "StrapiField must specify a field name.");
|
|
369
383
|
}
|
|
370
|
-
const data = (0, import_dlv2.default)(
|
|
371
|
-
const maybeMime = (
|
|
384
|
+
const data = (0, import_dlv2.default)(attributes, [path]);
|
|
385
|
+
const maybeMime = (_a = getAttributes(data == null ? void 0 : data.data)) == null ? void 0 : _a.mime;
|
|
372
386
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
373
387
|
fields: displayableFields,
|
|
374
388
|
isImage: typeof maybeMime === "string" && maybeMime.startsWith("image")
|
|
@@ -377,7 +391,7 @@ function StrapiField({
|
|
|
377
391
|
return /* @__PURE__ */ import_react3.default.createElement("div", null, "Please specify a valid field name.");
|
|
378
392
|
} else if (typeof maybeMime === "string" && maybeMime.startsWith("image")) {
|
|
379
393
|
const creds = useStrapiCredentials();
|
|
380
|
-
const attrs = data.data
|
|
394
|
+
const attrs = getAttributes(data.data);
|
|
381
395
|
const img_url = attrs.url.startsWith("http") ? attrs.url : creds.host + attrs.url;
|
|
382
396
|
const img_width = attrs.width;
|
|
383
397
|
const img_height = attrs.height;
|
package/dist/index.mjs
CHANGED
|
@@ -58,6 +58,16 @@ var queryParameters = [
|
|
|
58
58
|
}
|
|
59
59
|
];
|
|
60
60
|
var uniq = (xs) => Array.from(new Set(xs));
|
|
61
|
+
var getAttributes = (item) => {
|
|
62
|
+
if (!item) {
|
|
63
|
+
return void 0;
|
|
64
|
+
}
|
|
65
|
+
if (item.attributes) {
|
|
66
|
+
return item.attributes;
|
|
67
|
+
}
|
|
68
|
+
const { documentId: _documentId, locale: _locale, ...rest } = item;
|
|
69
|
+
return rest;
|
|
70
|
+
};
|
|
61
71
|
|
|
62
72
|
// src/StrapiCredentialsProvider.tsx
|
|
63
73
|
var StrapiCredentialsContext = React.createContext(void 0);
|
|
@@ -235,18 +245,18 @@ function StrapiCollection({
|
|
|
235
245
|
return /* @__PURE__ */ React2.createElement("div", null, "Please specify a valid collection.");
|
|
236
246
|
}
|
|
237
247
|
const collectionData = get(data.data, ["data"]);
|
|
238
|
-
const
|
|
239
|
-
const attributes =
|
|
248
|
+
const filterFields = collectionData.flatMap((item) => {
|
|
249
|
+
const attributes = getAttributes(item);
|
|
240
250
|
const displayableFields = Object.keys(attributes).filter((field) => {
|
|
241
|
-
var _a
|
|
251
|
+
var _a;
|
|
242
252
|
const value = attributes[field];
|
|
243
|
-
const maybeMime = (
|
|
253
|
+
const maybeMime = (_a = getAttributes(value == null ? void 0 : value.data)) == null ? void 0 : _a.mime;
|
|
244
254
|
return typeof value !== "object" || typeof maybeMime === "string" && maybeMime.startsWith("image");
|
|
245
255
|
});
|
|
246
256
|
return displayableFields;
|
|
247
257
|
});
|
|
248
258
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
249
|
-
strapiFields: uniq(
|
|
259
|
+
strapiFields: uniq(filterFields != null ? filterFields : [])
|
|
250
260
|
});
|
|
251
261
|
if (filterParameter && !filterValue && !filterField) {
|
|
252
262
|
return /* @__PURE__ */ React2.createElement("div", null, "Please specify a Filter Field and a Filter Value");
|
|
@@ -270,16 +280,19 @@ function StrapiCollection({
|
|
|
270
280
|
if (collection.length === 0) {
|
|
271
281
|
return /* @__PURE__ */ React2.createElement("div", null, "No collection found ");
|
|
272
282
|
}
|
|
273
|
-
const repElements = noAutoRepeat ? children : collection.map((item, index) =>
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
+
const repElements = noAutoRepeat ? children : collection.map((item, index) => {
|
|
284
|
+
var _a;
|
|
285
|
+
return /* @__PURE__ */ React2.createElement(
|
|
286
|
+
DataProvider,
|
|
287
|
+
{
|
|
288
|
+
key: (_a = item.documentId) != null ? _a : item.id,
|
|
289
|
+
name: "strapiItem",
|
|
290
|
+
data: item,
|
|
291
|
+
hidden: true
|
|
292
|
+
},
|
|
293
|
+
/* @__PURE__ */ React2.createElement(DataProvider, { name: makeDataProviderName(name), data: item }, repeatedElement(index, children))
|
|
294
|
+
);
|
|
295
|
+
});
|
|
283
296
|
return /* @__PURE__ */ React2.createElement(DataProvider, { name: "strapiItems", data: collection }, noLayout ? /* @__PURE__ */ React2.createElement(React2.Fragment, null, " ", repElements, " ") : /* @__PURE__ */ React2.createElement("div", { className }, " ", repElements, " "));
|
|
284
297
|
}
|
|
285
298
|
|
|
@@ -309,15 +322,16 @@ function StrapiField({
|
|
|
309
322
|
path,
|
|
310
323
|
setControlContextData
|
|
311
324
|
}) {
|
|
312
|
-
var _a
|
|
325
|
+
var _a;
|
|
313
326
|
const item = useSelector("strapiItem");
|
|
314
327
|
if (!item) {
|
|
315
328
|
return /* @__PURE__ */ React3.createElement("div", null, "StrapiField must be used within a StrapiCollection");
|
|
316
329
|
}
|
|
317
|
-
const attributes =
|
|
330
|
+
const attributes = getAttributes(item);
|
|
318
331
|
const displayableFields = Object.keys(attributes).filter((field) => {
|
|
332
|
+
var _a2;
|
|
319
333
|
const value = attributes[field];
|
|
320
|
-
const maybeMime2 =
|
|
334
|
+
const maybeMime2 = (_a2 = getAttributes(value == null ? void 0 : value.data)) == null ? void 0 : _a2.mime;
|
|
321
335
|
return typeof value !== "object" || typeof maybeMime2 === "string" && maybeMime2.startsWith("image");
|
|
322
336
|
});
|
|
323
337
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
@@ -327,8 +341,8 @@ function StrapiField({
|
|
|
327
341
|
if (!path) {
|
|
328
342
|
return /* @__PURE__ */ React3.createElement("div", null, "StrapiField must specify a field name.");
|
|
329
343
|
}
|
|
330
|
-
const data = get2(
|
|
331
|
-
const maybeMime = (
|
|
344
|
+
const data = get2(attributes, [path]);
|
|
345
|
+
const maybeMime = (_a = getAttributes(data == null ? void 0 : data.data)) == null ? void 0 : _a.mime;
|
|
332
346
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
333
347
|
fields: displayableFields,
|
|
334
348
|
isImage: typeof maybeMime === "string" && maybeMime.startsWith("image")
|
|
@@ -337,7 +351,7 @@ function StrapiField({
|
|
|
337
351
|
return /* @__PURE__ */ React3.createElement("div", null, "Please specify a valid field name.");
|
|
338
352
|
} else if (typeof maybeMime === "string" && maybeMime.startsWith("image")) {
|
|
339
353
|
const creds = useStrapiCredentials();
|
|
340
|
-
const attrs = data.data
|
|
354
|
+
const attrs = getAttributes(data.data);
|
|
341
355
|
const img_url = attrs.url.startsWith("http") ? attrs.url : creds.host + attrs.url;
|
|
342
356
|
const img_width = attrs.width;
|
|
343
357
|
const img_height = attrs.height;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicpkgs/plasmic-strapi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.159",
|
|
4
4
|
"description": "Plasmic Strapi components.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"qs": "^6.11.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@plasmicapp/host": "1.0.
|
|
41
|
+
"@plasmicapp/host": "1.0.209",
|
|
42
42
|
"@plasmicapp/query": "0.1.79",
|
|
43
43
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
44
44
|
"@types/dlv": "^1.1.2",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"tsup": "^7.2.0",
|
|
54
54
|
"typescript": "^5.2.2"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "a68b0dbe021bc38f355643251cf4150d949f92c6"
|
|
57
57
|
}
|