@plasmicpkgs/plasmic-cms 0.0.269 → 0.0.271
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/context.d.ts +4 -0
- package/dist/plasmic-cms.cjs.development.js +72 -38
- package/dist/plasmic-cms.cjs.development.js.map +1 -1
- package/dist/plasmic-cms.cjs.production.min.js +1 -1
- package/dist/plasmic-cms.cjs.production.min.js.map +1 -1
- package/dist/plasmic-cms.esm.js +72 -38
- package/dist/plasmic-cms.esm.js.map +1 -1
- package/dist/schema.d.ts +30 -10
- package/package.json +2 -2
package/dist/context.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ export declare function TablesProvider({ children, tables, }: {
|
|
|
13
13
|
children?: React.ReactNode;
|
|
14
14
|
tables?: ApiCmsTable[];
|
|
15
15
|
}): React.JSX.Element;
|
|
16
|
+
export declare function TableSchemaProvider({ children, table, }: {
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
table?: string | undefined;
|
|
19
|
+
}): React.JSX.Element;
|
|
16
20
|
export declare function useQueryResults(table?: string): {
|
|
17
21
|
table: string;
|
|
18
22
|
rows: ApiCmsRow[];
|
|
@@ -648,6 +648,7 @@ var _excluded = ["databaseToken"];
|
|
|
648
648
|
var contextPrefix = "plasmicCms";
|
|
649
649
|
var databaseContextKey = contextPrefix + "Database";
|
|
650
650
|
var tablesContextKey = contextPrefix + "Tables";
|
|
651
|
+
var tableSchemaContextKey = contextPrefix + "TableSchema";
|
|
651
652
|
var collectionResultSuffix = "Collection";
|
|
652
653
|
var mkQueryContextKey = function mkQueryContextKey(table) {
|
|
653
654
|
return "" + contextPrefix + capitalizeFirst(table) + collectionResultSuffix;
|
|
@@ -699,16 +700,37 @@ function TablesProvider(_ref2) {
|
|
|
699
700
|
hidden: true
|
|
700
701
|
}, children);
|
|
701
702
|
}
|
|
703
|
+
function TableSchemaProvider(_ref3) {
|
|
704
|
+
var children = _ref3.children,
|
|
705
|
+
table = _ref3.table;
|
|
706
|
+
var tables = useTables();
|
|
707
|
+
var schema;
|
|
708
|
+
if (tables && (tables == null ? void 0 : tables.length) > 0) {
|
|
709
|
+
if (!table) {
|
|
710
|
+
var _tables$;
|
|
711
|
+
schema = (_tables$ = tables[0]) == null ? void 0 : _tables$.schema;
|
|
712
|
+
} else {
|
|
713
|
+
var _tables$find;
|
|
714
|
+
schema = tables == null || (_tables$find = tables.find(function (t) {
|
|
715
|
+
return (t == null ? void 0 : t.identifier) === table;
|
|
716
|
+
})) == null ? void 0 : _tables$find.schema;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
return React.createElement(host.DataProvider, {
|
|
720
|
+
name: tableSchemaContextKey,
|
|
721
|
+
data: schema
|
|
722
|
+
}, children);
|
|
723
|
+
}
|
|
702
724
|
function getClosestMatchingKeysBy(env, pred) {
|
|
703
725
|
return [].concat(Object.keys(env).reverse()).filter(function (key) {
|
|
704
726
|
return pred(key);
|
|
705
727
|
});
|
|
706
728
|
}
|
|
707
|
-
function QueryResultProvider(
|
|
708
|
-
var children =
|
|
709
|
-
table =
|
|
710
|
-
rows =
|
|
711
|
-
hidden =
|
|
729
|
+
function QueryResultProvider(_ref4) {
|
|
730
|
+
var children = _ref4.children,
|
|
731
|
+
table = _ref4.table,
|
|
732
|
+
rows = _ref4.rows,
|
|
733
|
+
hidden = _ref4.hidden;
|
|
712
734
|
return React.createElement(host.DataProvider, {
|
|
713
735
|
name: table ? mkModeContextKey(table) : undefined,
|
|
714
736
|
data: "rows",
|
|
@@ -783,19 +805,19 @@ function useCount(tables, table) {
|
|
|
783
805
|
}
|
|
784
806
|
return undefined;
|
|
785
807
|
}
|
|
786
|
-
function RowProvider(
|
|
787
|
-
var children =
|
|
788
|
-
table =
|
|
789
|
-
row =
|
|
808
|
+
function RowProvider(_ref5) {
|
|
809
|
+
var children = _ref5.children,
|
|
810
|
+
table = _ref5.table,
|
|
811
|
+
row = _ref5.row;
|
|
790
812
|
return React.createElement(host.DataProvider, {
|
|
791
813
|
name: mkRowContextKey(table),
|
|
792
814
|
data: row
|
|
793
815
|
}, children);
|
|
794
816
|
}
|
|
795
|
-
function CountProvider(
|
|
796
|
-
var children =
|
|
797
|
-
table =
|
|
798
|
-
count =
|
|
817
|
+
function CountProvider(_ref6) {
|
|
818
|
+
var children = _ref6.children,
|
|
819
|
+
table = _ref6.table,
|
|
820
|
+
count = _ref6.count;
|
|
799
821
|
return React.createElement(host.DataProvider, {
|
|
800
822
|
name: table ? mkModeContextKey(table) : undefined,
|
|
801
823
|
data: "count",
|
|
@@ -1032,9 +1054,10 @@ var cmsQueryRepeaterMeta = {
|
|
|
1032
1054
|
options: function options(_ref4, ctx) {
|
|
1033
1055
|
var _ctx$table;
|
|
1034
1056
|
var table = _ref4.table;
|
|
1035
|
-
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table = ctx == null ? void 0 : ctx.table) != null ? _ctx$table : table, ["number"
|
|
1057
|
+
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table = ctx == null ? void 0 : ctx.table) != null ? _ctx$table : table, ["number" /* NUMBER */, "boolean" /* BOOLEAN */, "text" /* TEXT */, "long-text" /* LONG_TEXT */, "ref" /* REF */]);
|
|
1036
1058
|
}
|
|
1037
1059
|
},
|
|
1060
|
+
|
|
1038
1061
|
filterValue: {
|
|
1039
1062
|
type: "string",
|
|
1040
1063
|
displayName: "Filter value",
|
|
@@ -1045,8 +1068,9 @@ var cmsQueryRepeaterMeta = {
|
|
|
1045
1068
|
displayName: "Order by",
|
|
1046
1069
|
description: "Field to order by.",
|
|
1047
1070
|
options: function options(_, ctx) {
|
|
1048
|
-
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, ctx == null ? void 0 : ctx.table, ["number"
|
|
1071
|
+
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, ctx == null ? void 0 : ctx.table, ["number" /* NUMBER */, "boolean" /* BOOLEAN */, "date-time" /* DATE_TIME */, "long-text" /* LONG_TEXT */, "text" /* TEXT */]);
|
|
1049
1072
|
},
|
|
1073
|
+
|
|
1050
1074
|
hidden: function hidden(ps) {
|
|
1051
1075
|
return ps.mode === "count";
|
|
1052
1076
|
}
|
|
@@ -1231,10 +1255,12 @@ function CmsQueryRepeater(_ref6) {
|
|
|
1231
1255
|
}, {
|
|
1232
1256
|
hideIfNotFound: false
|
|
1233
1257
|
}, inEditor, loadingMessage, forceLoadingState);
|
|
1234
|
-
return React.createElement(
|
|
1258
|
+
return React.createElement(TableSchemaProvider, {
|
|
1259
|
+
table: table
|
|
1260
|
+
}, React.createElement(CountProvider, {
|
|
1235
1261
|
table: table,
|
|
1236
1262
|
count: typeof (maybeData == null ? void 0 : maybeData.data) === "number" ? maybeData.data : undefined
|
|
1237
|
-
}, node);
|
|
1263
|
+
}, node));
|
|
1238
1264
|
} else {
|
|
1239
1265
|
var _node = renderMaybeData(maybeData, function (rows) {
|
|
1240
1266
|
if (rows.length === 0 || forceEmptyState) {
|
|
@@ -1250,12 +1276,14 @@ function CmsQueryRepeater(_ref6) {
|
|
|
1250
1276
|
}, {
|
|
1251
1277
|
hideIfNotFound: false
|
|
1252
1278
|
}, inEditor, loadingMessage, forceLoadingState);
|
|
1253
|
-
return React.createElement(
|
|
1279
|
+
return React.createElement(TableSchemaProvider, {
|
|
1280
|
+
table: table
|
|
1281
|
+
}, React.createElement(QueryResultProvider, {
|
|
1254
1282
|
rows: Array.isArray(maybeData == null ? void 0 : maybeData.data) ? maybeData.data : undefined,
|
|
1255
1283
|
table: table
|
|
1256
1284
|
}, noLayout ? React.createElement(React.Fragment, null, " ", _node, " ") : React.createElement("div", {
|
|
1257
1285
|
className: className
|
|
1258
|
-
}, " ", _node, " "));
|
|
1286
|
+
}, " ", _node, " ")));
|
|
1259
1287
|
}
|
|
1260
1288
|
}
|
|
1261
1289
|
var cmsRowFieldMeta = {
|
|
@@ -1287,8 +1315,9 @@ var cmsRowFieldMeta = {
|
|
|
1287
1315
|
options: function options(_ref8, ctx) {
|
|
1288
1316
|
var _ctx$table3;
|
|
1289
1317
|
var table = _ref8.table;
|
|
1290
|
-
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table3 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table3 : table, ["number"
|
|
1318
|
+
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table3 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table3 : table, ["number" /* NUMBER */, "boolean" /* BOOLEAN */, "text" /* TEXT */, "long-text" /* LONG_TEXT */, "date-time" /* DATE_TIME */, "rich-text" /* RICH_TEXT */, "image" /* IMAGE */, "file" /* FILE */, "enum" /* ENUM */]);
|
|
1291
1319
|
},
|
|
1320
|
+
|
|
1292
1321
|
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
1293
1322
|
var _ctx$fieldMeta, _ctx$fieldMeta2;
|
|
1294
1323
|
return (ctx == null || (_ctx$fieldMeta = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta.name) || (ctx == null || (_ctx$fieldMeta2 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta2.identifier);
|
|
@@ -1316,8 +1345,9 @@ var cmsRowFieldMeta = {
|
|
|
1316
1345
|
if (!fieldMeta) {
|
|
1317
1346
|
return true;
|
|
1318
1347
|
}
|
|
1319
|
-
return fieldMeta.type !== "date-time"
|
|
1348
|
+
return fieldMeta.type !== "date-time" /* DATE_TIME */;
|
|
1320
1349
|
},
|
|
1350
|
+
|
|
1321
1351
|
options: [{
|
|
1322
1352
|
label: "July 26, 2014",
|
|
1323
1353
|
value: "MMMM D, YYYY"
|
|
@@ -1393,7 +1423,7 @@ function CmsRowField(_ref10) {
|
|
|
1393
1423
|
table: res.table,
|
|
1394
1424
|
tables: tables,
|
|
1395
1425
|
field: field,
|
|
1396
|
-
typeFilters: ["text"
|
|
1426
|
+
typeFilters: ["text" /* TEXT */, "long-text" /* LONG_TEXT */, "rich-text" /* RICH_TEXT */]
|
|
1397
1427
|
}) : undefined;
|
|
1398
1428
|
if (tables) {
|
|
1399
1429
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
@@ -1420,7 +1450,7 @@ function CmsRowField(_ref10) {
|
|
|
1420
1450
|
if (!data) {
|
|
1421
1451
|
return null;
|
|
1422
1452
|
}
|
|
1423
|
-
if (fieldMeta.type === "date-time" && dateFormat) {
|
|
1453
|
+
if (fieldMeta.type === "date-time" /* DATE_TIME */ && dateFormat) {
|
|
1424
1454
|
data = dayjs(data).format(dateFormat);
|
|
1425
1455
|
}
|
|
1426
1456
|
return data ? renderValue(data, fieldMeta.type, _extends({
|
|
@@ -1471,7 +1501,7 @@ function CmsCount(_ref11) {
|
|
|
1471
1501
|
}, rest), new Intl.NumberFormat().format(res.count));
|
|
1472
1502
|
}
|
|
1473
1503
|
}
|
|
1474
|
-
var DEFAULT_TYPE_FILTERS = ["text"];
|
|
1504
|
+
var DEFAULT_TYPE_FILTERS = ["text" /* TEXT */];
|
|
1475
1505
|
function deriveInferredTableField(opts) {
|
|
1476
1506
|
var _tables$find;
|
|
1477
1507
|
var table = opts.table,
|
|
@@ -1494,14 +1524,15 @@ function assertNever(_) {
|
|
|
1494
1524
|
}
|
|
1495
1525
|
function renderValue(value, type, props) {
|
|
1496
1526
|
switch (type) {
|
|
1497
|
-
case "number"
|
|
1498
|
-
case "boolean"
|
|
1499
|
-
case "text"
|
|
1500
|
-
case "long-text"
|
|
1501
|
-
case "date-time"
|
|
1502
|
-
case "
|
|
1527
|
+
case "number" /* NUMBER */:
|
|
1528
|
+
case "boolean" /* BOOLEAN */:
|
|
1529
|
+
case "text" /* TEXT */:
|
|
1530
|
+
case "long-text" /* LONG_TEXT */:
|
|
1531
|
+
case "date-time" /* DATE_TIME */:
|
|
1532
|
+
case "enum" /* ENUM */:
|
|
1533
|
+
case "ref" /* REF */:
|
|
1503
1534
|
return React.createElement("div", Object.assign({}, props), value);
|
|
1504
|
-
case "rich-text"
|
|
1535
|
+
case "rich-text" /* RICH_TEXT */:
|
|
1505
1536
|
return React.createElement("div", Object.assign({
|
|
1506
1537
|
dangerouslySetInnerHTML: {
|
|
1507
1538
|
__html: value
|
|
@@ -1510,7 +1541,7 @@ function renderValue(value, type, props) {
|
|
|
1510
1541
|
whiteSpace: "normal"
|
|
1511
1542
|
}
|
|
1512
1543
|
}, props));
|
|
1513
|
-
case "image"
|
|
1544
|
+
case "image" /* IMAGE */:
|
|
1514
1545
|
if (value && typeof value === "object" && value.url && value.imageMeta) {
|
|
1515
1546
|
return React.createElement("img", Object.assign({
|
|
1516
1547
|
src: value.url,
|
|
@@ -1519,7 +1550,7 @@ function renderValue(value, type, props) {
|
|
|
1519
1550
|
}, props));
|
|
1520
1551
|
}
|
|
1521
1552
|
return null;
|
|
1522
|
-
case "file"
|
|
1553
|
+
case "file" /* FILE */:
|
|
1523
1554
|
if (value && typeof value === "object" && value.url && value.name) {
|
|
1524
1555
|
return React.createElement("a", Object.assign({
|
|
1525
1556
|
href: value.url,
|
|
@@ -1619,8 +1650,9 @@ function CmsRowLink(_ref13) {
|
|
|
1619
1650
|
table: res.table,
|
|
1620
1651
|
tables: tables,
|
|
1621
1652
|
field: field,
|
|
1622
|
-
typeFilters: ["file"
|
|
1653
|
+
typeFilters: ["file" /* FILE */, "text" /* TEXT */]
|
|
1623
1654
|
});
|
|
1655
|
+
|
|
1624
1656
|
if (tables) {
|
|
1625
1657
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1626
1658
|
setControlContextData == null || setControlContextData({
|
|
@@ -1640,7 +1672,7 @@ function CmsRowLink(_ref13) {
|
|
|
1640
1672
|
var childrenWithProps = React.Children.map(children, function (child) {
|
|
1641
1673
|
if (React.isValidElement(child)) {
|
|
1642
1674
|
var _React$cloneElement;
|
|
1643
|
-
return React.cloneElement(child, (_React$cloneElement = {}, _React$cloneElement[hrefProp] = fieldMeta.type === "file" ? value.url : prefix || suffix ? "" + (prefix || "") + value + (suffix || "") : value, _React$cloneElement));
|
|
1675
|
+
return React.cloneElement(child, (_React$cloneElement = {}, _React$cloneElement[hrefProp] = fieldMeta.type === "file" /* FILE */ ? value.url : prefix || suffix ? "" + (prefix || "") + value + (suffix || "") : value, _React$cloneElement));
|
|
1644
1676
|
}
|
|
1645
1677
|
return child;
|
|
1646
1678
|
});
|
|
@@ -1682,7 +1714,7 @@ var cmsRowImageMeta = {
|
|
|
1682
1714
|
options: function options(_ref14, ctx) {
|
|
1683
1715
|
var _ctx$table5;
|
|
1684
1716
|
var table = _ref14.table;
|
|
1685
|
-
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table5 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table5 : table, ["image"]);
|
|
1717
|
+
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table5 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table5 : table, ["image" /* IMAGE */]);
|
|
1686
1718
|
},
|
|
1687
1719
|
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
1688
1720
|
var _ctx$fieldMeta7, _ctx$fieldMeta8;
|
|
@@ -1713,8 +1745,9 @@ function CmsRowImage(_ref15) {
|
|
|
1713
1745
|
table: res.table,
|
|
1714
1746
|
tables: tables,
|
|
1715
1747
|
field: field,
|
|
1716
|
-
typeFilters: ["image"]
|
|
1748
|
+
typeFilters: ["image" /* IMAGE */]
|
|
1717
1749
|
});
|
|
1750
|
+
|
|
1718
1751
|
if (tables) {
|
|
1719
1752
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1720
1753
|
setControlContextData == null || setControlContextData({
|
|
@@ -1809,8 +1842,9 @@ function CmsRowFieldValue(_ref17) {
|
|
|
1809
1842
|
table: res.table,
|
|
1810
1843
|
tables: tables,
|
|
1811
1844
|
field: field,
|
|
1812
|
-
typeFilters: ["text"]
|
|
1845
|
+
typeFilters: ["text" /* TEXT */]
|
|
1813
1846
|
});
|
|
1847
|
+
|
|
1814
1848
|
if (tables) {
|
|
1815
1849
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1816
1850
|
setControlContextData == null || setControlContextData({
|