@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 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 queryObject = new URLSearchParams(
1271
- typeof location !== "undefined" && location?.search ? location.search : query
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 = queryObject.get(accessor) ? queryObject.get(accessor).split(",") : config.defaultValue;
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 = queryObject.get(accessor) && config.options.find((d2) => d2.id === queryObject.get(accessor)) ? queryObject.get(accessor) : config.defaultValue;
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 queryObject = new URLSearchParams(
4885
- typeof location !== "undefined" && location?.search ? location.search : query
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 = queryObject.get(accessor) ? queryObject.get(accessor).split(",") : config.defaultValue;
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 = queryObject.get(accessor) && config.options.find((d2) => d2.id === queryObject.get(accessor)) ? queryObject.get(accessor) : config.defaultValue;
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datawheel/bespoke",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "description": "Content management system for creating automated data reports",
5
5
  "exports": {
6
6
  ".": {