@datawheel/bespoke 0.5.6 → 0.5.8
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 +5 -5
- package/dist/server.js +5 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1267,18 +1267,18 @@ var init_selectorQueryToVariable = __esm({
|
|
|
1267
1267
|
init_cms();
|
|
1268
1268
|
selectorQueryToVariable = (id, query, config) => {
|
|
1269
1269
|
const accessor = `selector${id}id`;
|
|
1270
|
-
const
|
|
1271
|
-
|
|
1272
|
-
|
|
1270
|
+
const locationValue = new URLSearchParams(typeof location !== "undefined" && location?.search ? location.search : "").get(accessor);
|
|
1271
|
+
const queryValue = new URLSearchParams(query).get(accessor);
|
|
1272
|
+
const selectorValue = locationValue || queryValue;
|
|
1273
1273
|
if (config.type === SELECTOR_TYPES.MULTI) {
|
|
1274
|
-
const queryIds =
|
|
1274
|
+
const queryIds = selectorValue ? selectorValue.split(",") : config.defaultValue;
|
|
1275
1275
|
const options = config.options.filter((d2) => queryIds.includes(d2.id));
|
|
1276
1276
|
return {
|
|
1277
1277
|
[`selector${id}id`]: queryIds,
|
|
1278
1278
|
[`selector${id}label`]: (options || []).map((d2) => d2.label)
|
|
1279
1279
|
};
|
|
1280
1280
|
}
|
|
1281
|
-
const queryId =
|
|
1281
|
+
const queryId = selectorValue && config.options.find((d2) => d2.id === selectorValue) ? selectorValue : config.defaultValue;
|
|
1282
1282
|
const option = config.options.find((d2) => d2.id === queryId);
|
|
1283
1283
|
return {
|
|
1284
1284
|
[`selector${id}id`]: queryId,
|
package/dist/server.js
CHANGED
|
@@ -4881,18 +4881,18 @@ function runSelector(id, logic, formatterFunctions, blockContext, replaceQuery =
|
|
|
4881
4881
|
// libs/selectors/selectorQueryToVariable.js
|
|
4882
4882
|
var selectorQueryToVariable = (id, query, config) => {
|
|
4883
4883
|
const accessor = `selector${id}id`;
|
|
4884
|
-
const
|
|
4885
|
-
|
|
4886
|
-
|
|
4884
|
+
const locationValue = new URLSearchParams(typeof location !== "undefined" && location?.search ? location.search : "").get(accessor);
|
|
4885
|
+
const queryValue = new URLSearchParams(query).get(accessor);
|
|
4886
|
+
const selectorValue = locationValue || queryValue;
|
|
4887
4887
|
if (config.type === SELECTOR_TYPES.MULTI) {
|
|
4888
|
-
const queryIds =
|
|
4888
|
+
const queryIds = selectorValue ? selectorValue.split(",") : config.defaultValue;
|
|
4889
4889
|
const options = config.options.filter((d2) => queryIds.includes(d2.id));
|
|
4890
4890
|
return {
|
|
4891
4891
|
[`selector${id}id`]: queryIds,
|
|
4892
4892
|
[`selector${id}label`]: (options || []).map((d2) => d2.label)
|
|
4893
4893
|
};
|
|
4894
4894
|
}
|
|
4895
|
-
const queryId =
|
|
4895
|
+
const queryId = selectorValue && config.options.find((d2) => d2.id === selectorValue) ? selectorValue : config.defaultValue;
|
|
4896
4896
|
const option = config.options.find((d2) => d2.id === queryId);
|
|
4897
4897
|
return {
|
|
4898
4898
|
[`selector${id}id`]: queryId,
|