@blaze-cms/react-page-builder 0.124.0-alpha.12 → 0.124.0-alpha.15
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/CHANGELOG.md +30 -0
- package/lib/application/query/index.js +8 -2
- package/lib/application/query/index.js.map +1 -1
- package/lib/components/Card/CardFactory.js +37 -5
- package/lib/components/Card/CardFactory.js.map +1 -1
- package/lib/components/CarouselWrapper.js +2 -2
- package/lib/components/CarouselWrapper.js.map +1 -1
- package/lib/components/ItemListButton/ItemListButton.js +168 -0
- package/lib/components/ItemListButton/ItemListButton.js.map +1 -0
- package/lib/components/ItemListButton/index.js +16 -0
- package/lib/components/ItemListButton/index.js.map +1 -0
- package/lib/components/ItemListCounter/ItemListCounter.js +114 -0
- package/lib/components/ItemListCounter/ItemListCounter.js.map +1 -0
- package/lib/components/ItemListCounter/index.js +16 -0
- package/lib/components/ItemListCounter/index.js.map +1 -0
- package/lib/components/List/ListBuilder.js +12 -6
- package/lib/components/List/ListBuilder.js.map +1 -1
- package/lib/components/List/ListFactory.js +26 -7
- package/lib/components/List/ListFactory.js.map +1 -1
- package/lib/components/index.js +10 -0
- package/lib/components/index.js.map +1 -1
- package/lib/constants/index.js +8 -2
- package/lib/constants/index.js.map +1 -1
- package/lib/helpers/build-raw-query.js.map +1 -1
- package/lib/helpers/get-item-list-data.js +17 -0
- package/lib/helpers/get-item-list-data.js.map +1 -0
- package/lib/helpers/get-item-list-id.js +20 -0
- package/lib/helpers/get-item-list-id.js.map +1 -0
- package/lib/helpers/get-item-list-ids.js +28 -0
- package/lib/helpers/get-item-list-ids.js.map +1 -0
- package/lib/helpers/index.js +24 -0
- package/lib/helpers/index.js.map +1 -1
- package/lib-es/application/query/index.js +44 -1
- package/lib-es/application/query/index.js.map +1 -1
- package/lib-es/components/Card/CardFactory.js +34 -8
- package/lib-es/components/Card/CardFactory.js.map +1 -1
- package/lib-es/components/CarouselWrapper.js +2 -2
- package/lib-es/components/CarouselWrapper.js.map +1 -1
- package/lib-es/components/ItemListButton/ItemListButton.js +117 -0
- package/lib-es/components/ItemListButton/ItemListButton.js.map +1 -0
- package/lib-es/components/ItemListButton/index.js +3 -0
- package/lib-es/components/ItemListButton/index.js.map +1 -0
- package/lib-es/components/ItemListCounter/ItemListCounter.js +67 -0
- package/lib-es/components/ItemListCounter/ItemListCounter.js.map +1 -0
- package/lib-es/components/ItemListCounter/index.js +3 -0
- package/lib-es/components/ItemListCounter/index.js.map +1 -0
- package/lib-es/components/List/ListBuilder.js +12 -6
- package/lib-es/components/List/ListBuilder.js.map +1 -1
- package/lib-es/components/List/ListFactory.js +26 -9
- package/lib-es/components/List/ListFactory.js.map +1 -1
- package/lib-es/components/index.js +6 -0
- package/lib-es/components/index.js.map +1 -1
- package/lib-es/constants/index.js +3 -1
- package/lib-es/constants/index.js.map +1 -1
- package/lib-es/helpers/build-raw-query.js.map +1 -1
- package/lib-es/helpers/get-item-list-data.js +7 -0
- package/lib-es/helpers/get-item-list-data.js.map +1 -0
- package/lib-es/helpers/get-item-list-id.js +10 -0
- package/lib-es/helpers/get-item-list-id.js.map +1 -0
- package/lib-es/helpers/get-item-list-ids.js +13 -0
- package/lib-es/helpers/get-item-list-ids.js.map +1 -0
- package/lib-es/helpers/index.js +3 -0
- package/lib-es/helpers/index.js.map +1 -1
- package/package.json +2 -2
- package/src/application/query/index.js +50 -1
- package/src/components/Card/CardFactory.js +27 -7
- package/src/components/CarouselWrapper.js +2 -2
- package/src/components/ItemListButton/ItemListButton.js +107 -0
- package/src/components/ItemListButton/index.js +3 -0
- package/src/components/ItemListCounter/ItemListCounter.js +67 -0
- package/src/components/ItemListCounter/index.js +3 -0
- package/src/components/List/ListBuilder.js +10 -5
- package/src/components/List/ListFactory.js +47 -12
- package/src/components/index.js +6 -0
- package/src/constants/index.js +4 -1
- package/src/helpers/build-raw-query.js +1 -0
- package/src/helpers/get-item-list-data.js +6 -0
- package/src/helpers/get-item-list-id.js +10 -0
- package/src/helpers/get-item-list-ids.js +10 -0
- package/src/helpers/index.js +3 -0
- package/tests/unit/src/components/__snapshots__/index.test.js.snap +8 -0
- package/tests/unit/src/helpers/get-item-list-data.test.js +28 -0
- package/tests/unit/src/helpers/get-item-list-id.test.js +20 -0
- package/tests/unit/src/helpers/get-item-list-ids.test.js +19 -0
package/lib/helpers/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/helpers/index.js"],"sourcesContent":["export { default as buildInheritedFilters } from './build-inherited-filters';\nexport { default as buildLinkExtraProps } from './build-link-extra-props';\nexport { default as buildPropsQuery } from './build-props-query';\nexport { default as buildQueryFields } from './build-query-fields';\nexport { default as buildRawQuery } from './build-raw-query';\nexport { default as buildRawQueryBase } from './build-raw-query-base';\nexport { default as buildSearchValuesCheckboxSelect } from './build-search-values-checkbox-select';\nexport { default as buildSearchValuesText } from './build-search-values-text';\nexport { default as buildSetFilters } from './build-set-filters';\nexport { default as checkPropsToUse } from './check-props-to-use';\nexport { default as getElasticsearchOperator } from './get-elasticsearch-operator';\nexport { default as getClickWrapperOptions } from './get-click-wrapper-options';\nexport { default as getEntitiesWithBanner } from './get-entities-with-banner';\nexport { default as getEntityData } from './get-entity-data';\nexport { default as getEntityRenderProps } from './get-entity-render-props';\nexport { default as getGenericProps } from './get-generic-props';\nexport { default as getGenericRenderVariables } from './get-generic-render-variables';\nexport { default as getImageIds } from './get-image-ids';\nexport { default as getInheritedFilters } from './get-inherited-filters';\nexport { default as getModifiers } from './get-modifiers';\nexport { default as getNotEqualQuery } from './get-not-equal-query';\nexport { default as getPaginationIndex } from './get-pagination-index';\nexport { default as getParsedSummaryValue } from './get-parsed-summary-value';\nexport { default as getQueryFilters } from './get-query-filters';\nexport { default as getQueryProps } from './get-query-props';\nexport { default as getRequiredSchemas } from './get-required-schemas';\nexport { default as getSearchFilterType } from './get-search-filter-type';\nexport { default as getUnpublishedEntityName } from './get-unpublished-entity-name';\nexport { default as getWrappedValueWithLink } from './get-wrapped-value-with-link';\nexport { default as getItemsToDisplayIds } from './get-items-to-display-ids';\nexport { default as isBrowser } from './is-browser';\nexport { default as isFilterEntitysId } from './is-filter-entitys-id';\nexport { default as isObject } from './is-object';\nexport { default as isUsingRelationImage } from './is-using-relation-image';\nexport { default as parsePropsToDisplay } from './parse-props-to-display';\nexport { default as renderChildren } from './render-children';\nexport { default as shouldRenderWaypoint } from './should-render-waypoint';\nexport { default as shouldShowProperty } from './should-show-property';\nexport { default as sortResponseData } from './sort-response-data';\nexport { default as splitChildren } from './split-children';\nexport { default as getCurrentOffset } from './get-current-offset';\nexport { default as updateChildrensParent } from './update-childrens-parent';\nexport { default as getDisplayCountData } from './get-display-count-data';\nexport { default as buildImageProperties } from './build-image-properties';\nexport { default as getUpdatedFilterBy } from './get-updated-filter-by';\nexport { default as checkForError } from './check-for-error';\nexport { default as removeUnwantedCharacters } from './remove-unwanted-characters';\nexport { default as hasChildren } from './has-children';\nexport { default as removeExtraItems } from './remove-extra-items';\nexport { default as getParsedPropValues } from './get-parsed-prop-values';\nexport { default as getSanitizedPropValues } from './get-sanitized-prop-values';\nexport { default as appendImages } from './append-images';\nexport { default as parseTextBlock } from './parse-TextBlock';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/helpers/index.js"],"sourcesContent":["export { default as buildInheritedFilters } from './build-inherited-filters';\nexport { default as buildLinkExtraProps } from './build-link-extra-props';\nexport { default as buildPropsQuery } from './build-props-query';\nexport { default as buildQueryFields } from './build-query-fields';\nexport { default as buildRawQuery } from './build-raw-query';\nexport { default as buildRawQueryBase } from './build-raw-query-base';\nexport { default as buildSearchValuesCheckboxSelect } from './build-search-values-checkbox-select';\nexport { default as buildSearchValuesText } from './build-search-values-text';\nexport { default as buildSetFilters } from './build-set-filters';\nexport { default as checkPropsToUse } from './check-props-to-use';\nexport { default as getElasticsearchOperator } from './get-elasticsearch-operator';\nexport { default as getClickWrapperOptions } from './get-click-wrapper-options';\nexport { default as getEntitiesWithBanner } from './get-entities-with-banner';\nexport { default as getEntityData } from './get-entity-data';\nexport { default as getEntityRenderProps } from './get-entity-render-props';\nexport { default as getGenericProps } from './get-generic-props';\nexport { default as getGenericRenderVariables } from './get-generic-render-variables';\nexport { default as getImageIds } from './get-image-ids';\nexport { default as getInheritedFilters } from './get-inherited-filters';\nexport { default as getModifiers } from './get-modifiers';\nexport { default as getNotEqualQuery } from './get-not-equal-query';\nexport { default as getPaginationIndex } from './get-pagination-index';\nexport { default as getParsedSummaryValue } from './get-parsed-summary-value';\nexport { default as getQueryFilters } from './get-query-filters';\nexport { default as getQueryProps } from './get-query-props';\nexport { default as getRequiredSchemas } from './get-required-schemas';\nexport { default as getSearchFilterType } from './get-search-filter-type';\nexport { default as getUnpublishedEntityName } from './get-unpublished-entity-name';\nexport { default as getWrappedValueWithLink } from './get-wrapped-value-with-link';\nexport { default as getItemsToDisplayIds } from './get-items-to-display-ids';\nexport { default as isBrowser } from './is-browser';\nexport { default as isFilterEntitysId } from './is-filter-entitys-id';\nexport { default as isObject } from './is-object';\nexport { default as isUsingRelationImage } from './is-using-relation-image';\nexport { default as parsePropsToDisplay } from './parse-props-to-display';\nexport { default as renderChildren } from './render-children';\nexport { default as shouldRenderWaypoint } from './should-render-waypoint';\nexport { default as shouldShowProperty } from './should-show-property';\nexport { default as sortResponseData } from './sort-response-data';\nexport { default as splitChildren } from './split-children';\nexport { default as getCurrentOffset } from './get-current-offset';\nexport { default as updateChildrensParent } from './update-childrens-parent';\nexport { default as getDisplayCountData } from './get-display-count-data';\nexport { default as buildImageProperties } from './build-image-properties';\nexport { default as getUpdatedFilterBy } from './get-updated-filter-by';\nexport { default as checkForError } from './check-for-error';\nexport { default as removeUnwantedCharacters } from './remove-unwanted-characters';\nexport { default as hasChildren } from './has-children';\nexport { default as removeExtraItems } from './remove-extra-items';\nexport { default as getParsedPropValues } from './get-parsed-prop-values';\nexport { default as getSanitizedPropValues } from './get-sanitized-prop-values';\nexport { default as appendImages } from './append-images';\nexport { default as parseTextBlock } from './parse-TextBlock';\nexport { default as getItemListId } from './get-item-list-id';\nexport { default as getItemListIds } from './get-item-list-ids';\nexport { default as getItemListData } from './get-item-list-data';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA"}
|
|
@@ -165,5 +165,48 @@ const getPublishedContent = entity => `
|
|
|
165
165
|
}
|
|
166
166
|
`;
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
const getItemList = gql`
|
|
169
|
+
query getItemList($id: String!) {
|
|
170
|
+
getItemList(id: $id) {
|
|
171
|
+
listItems {
|
|
172
|
+
itemId
|
|
173
|
+
itemEntity
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
`;
|
|
178
|
+
const addItemsToList = gql`
|
|
179
|
+
mutation addItemsToList(
|
|
180
|
+
$name: String!
|
|
181
|
+
$id: String
|
|
182
|
+
$listItems: [AddItemsToListInputListItemsItem]!
|
|
183
|
+
) {
|
|
184
|
+
addItemsToList(input: { name: $name, id: $id, listItems: $listItems }) {
|
|
185
|
+
result {
|
|
186
|
+
id
|
|
187
|
+
listItems {
|
|
188
|
+
itemId
|
|
189
|
+
itemEntity
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
`;
|
|
195
|
+
const removeItemsFromList = gql`
|
|
196
|
+
mutation removeItemsFromList(
|
|
197
|
+
$listId: String!
|
|
198
|
+
$listItems: [RemoveItemsFromListInputListItemsItem]!
|
|
199
|
+
) {
|
|
200
|
+
removeItemsFromList(input: { id: $listId, listItems: $listItems }) {
|
|
201
|
+
result {
|
|
202
|
+
id
|
|
203
|
+
listItems {
|
|
204
|
+
itemId
|
|
205
|
+
itemEntity
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
`;
|
|
211
|
+
export { getEntitySchema, getSingleEntitySchema, getAction, getFiles, getFileById, generateMultiItemQuery, generateSingleItemQuery, getPublishedContent, getSearchPublishedContent, getCount, getMultipleSchema, getUser, getRecordParents, getItemList, addItemsToList, removeItemsFromList };
|
|
169
212
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["gql","upperFirst","defaultSchemaProps","getSearchPublishedContent","fields","getUser","userProps","getEntitySchema","getSingleEntitySchema","getRecordParents","queryName","getMultipleSchema","identifiers","queryString","map","id","join","getFiles","getFileById","getCount","action","generateQuery","props","generateMultiItemQuery","generateSingleItemQuery","getAction","query","getPublishedContent","entity"],"sources":["../../../src/application/query/index.js"],"sourcesContent":["import { gql } from '@apollo/client';\nimport upperFirst from 'lodash.upperfirst';\n\nconst defaultSchemaProps = `\n id\n identifier\n properties\n dynamicProperties\n actions\n interfaces\n relations\n __typename\n`;\n\nconst getSearchPublishedContent = fields => gql`\n query searchPublishedContent($rawQueryStringified: String!, $offset: Int, $limit: Int, $sort: String) {\n searchPublishedContent(rawQueryStringified: $rawQueryStringified, offset: $offset, limit: $limit, sort: $sort) {\n ${fields}\n }\n }\n `;\n\nconst getUser = userProps => gql`\n query getUser($id: String!) {\n getUser(id: $id) {\n id\n ${userProps}\n }\n }\n`;\n\nconst getEntitySchema = gql`\n query getEntitySchemas($identifier: String!) {\n getEntitySchemas(identifier: $identifier) {\n ${defaultSchemaProps}\n }\n }\n`;\n\nconst getSingleEntitySchema = gql`\n query getEntitySchema($id: String!) {\n getEntitySchema: getEntitySchema(id: $id) {\n ${defaultSchemaProps}\n }\n }\n`;\n\nconst getRecordParents = queryName => gql`\nquery getRecordParents($id: String!){\n recordParents: ${queryName}(id: $id){\n id,\n name,\n url,\n parents {\n id,\n name\n url\n }\n }\n}`;\n\nconst getMultipleSchema = identifiers => {\n const queryString = identifiers\n .map(\n id => `${id}: getEntitySchema(id: \"${id}\") {\n ${defaultSchemaProps}\n }`\n )\n .join(`\\n`);\n return gql`\n query {\n ${queryString}\n }`;\n};\n\nconst getFiles = gql`\n query getFiles($where: JSON!) {\n getFiles(where: $where) {\n id\n url\n data\n }\n }\n`;\n\nconst getFileById = gql`\n query getFile($id: String!) {\n getFile(id: $id) {\n id\n url\n data\n }\n }\n`;\n\nconst getCount = action => gql`query countData($where: JSON!) {\n ${action} (where: $where)\n }\n`;\n\nconst generateQuery = (action, props) => `\n query getEntityData(\n $where: JSON\n $limit: Int\n $offset: Int\n $sort: [${upperFirst(action)}SortItem]){\n ${action} (where: $where, limit: $limit, offset: $offset, sort: $sort){\n ${props}\n id\n __typename\n }\n }\n `;\nconst generateMultiItemQuery = (action, props) => gql`\n query getEntityData($where: JSON){\n ${action} (where: $where){\n ${props}\n id\n __typename\n }\n }\n `;\n\nconst generateSingleItemQuery = (action, props) => gql`\n query getEntityData($id: String!){\n entityData: ${action}(id: $id){\n ${props},\n id,\n __typename\n }\n }\n `;\n\n// TODO: extend function to handle properties and make them dynamic with a config schema for each entity.\nconst getAction = (action, props) => {\n const query = generateQuery(action, props);\n return gql`\n ${query}\n `;\n};\n\nconst getPublishedContent = entity => `\n query searchPublishedContent(\n $rawQueryStringified: String!\n $offset: Int\n $limit: Int\n $sort: String\n ) {\n searchPublishedContent(\n rawQueryStringified: $rawQueryStringified\n offset: $offset\n limit: $limit\n sort: $sort\n ) {\n results {\n ... on ${entity} {\n id\n name\n image {\n url\n __typename\n }\n url\n __typename\n }\n __typename\n }\n total\n __typename\n }\n }\n`;\n\nexport {\n getEntitySchema,\n getSingleEntitySchema,\n getAction,\n getFiles,\n getFileById,\n generateMultiItemQuery,\n generateSingleItemQuery,\n getPublishedContent,\n getSearchPublishedContent,\n getCount,\n getMultipleSchema,\n getUser,\n getRecordParents\n};\n"],"mappings":"AAAA,SAASA,GAAT,QAAoB,gBAApB;AACA,OAAOC,UAAP,MAAuB,mBAAvB;AAEA,MAAMC,kBAAkB,GAAI;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CATA;;AAWA,MAAMC,yBAAyB,GAAGC,MAAM,IAAIJ,GAAI;AAChD;AACA;AACA,UAAUI,MAAO;AACjB;AACA;AACA,GANA;;AAQA,MAAMC,OAAO,GAAGC,SAAS,IAAIN,GAAI;AACjC;AACA;AACA;AACA,QAAQM,SAAU;AAClB;AACA;AACA,CAPA;;AASA,MAAMC,eAAe,GAAGP,GAAI;AAC5B;AACA;AACA,QAAQE,kBAAmB;AAC3B;AACA;AACA,CANA;AAQA,MAAMM,qBAAqB,GAAGR,GAAI;AAClC;AACA;AACA,QAAQE,kBAAmB;AAC3B;AACA;AACA,CANA;;AAQA,MAAMO,gBAAgB,GAAGC,SAAS,IAAIV,GAAI;AAC1C;AACA,mBAAmBU,SAAU;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAZA;;AAcA,MAAMC,iBAAiB,GAAGC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A;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiBA,MAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CA9BA;;AAgCA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["gql","upperFirst","defaultSchemaProps","getSearchPublishedContent","fields","getUser","userProps","getEntitySchema","getSingleEntitySchema","getRecordParents","queryName","getMultipleSchema","identifiers","queryString","map","id","join","getFiles","getFileById","getCount","action","generateQuery","props","generateMultiItemQuery","generateSingleItemQuery","getAction","query","getPublishedContent","entity","getItemList","addItemsToList","removeItemsFromList"],"sources":["../../../src/application/query/index.js"],"sourcesContent":["import { gql } from '@apollo/client';\nimport upperFirst from 'lodash.upperfirst';\n\nconst defaultSchemaProps = `\n id\n identifier\n properties\n dynamicProperties\n actions\n interfaces\n relations\n __typename\n`;\n\nconst getSearchPublishedContent = fields => gql`\n query searchPublishedContent($rawQueryStringified: String!, $offset: Int, $limit: Int, $sort: String) {\n searchPublishedContent(rawQueryStringified: $rawQueryStringified, offset: $offset, limit: $limit, sort: $sort) {\n ${fields}\n }\n }\n `;\n\nconst getUser = userProps => gql`\n query getUser($id: String!) {\n getUser(id: $id) {\n id\n ${userProps}\n }\n }\n`;\n\nconst getEntitySchema = gql`\n query getEntitySchemas($identifier: String!) {\n getEntitySchemas(identifier: $identifier) {\n ${defaultSchemaProps}\n }\n }\n`;\n\nconst getSingleEntitySchema = gql`\n query getEntitySchema($id: String!) {\n getEntitySchema: getEntitySchema(id: $id) {\n ${defaultSchemaProps}\n }\n }\n`;\n\nconst getRecordParents = queryName => gql`\nquery getRecordParents($id: String!){\n recordParents: ${queryName}(id: $id){\n id,\n name,\n url,\n parents {\n id,\n name\n url\n }\n }\n}`;\n\nconst getMultipleSchema = identifiers => {\n const queryString = identifiers\n .map(\n id => `${id}: getEntitySchema(id: \"${id}\") {\n ${defaultSchemaProps}\n }`\n )\n .join(`\\n`);\n return gql`\n query {\n ${queryString}\n }`;\n};\n\nconst getFiles = gql`\n query getFiles($where: JSON!) {\n getFiles(where: $where) {\n id\n url\n data\n }\n }\n`;\n\nconst getFileById = gql`\n query getFile($id: String!) {\n getFile(id: $id) {\n id\n url\n data\n }\n }\n`;\n\nconst getCount = action => gql`query countData($where: JSON!) {\n ${action} (where: $where)\n }\n`;\n\nconst generateQuery = (action, props) => `\n query getEntityData(\n $where: JSON\n $limit: Int\n $offset: Int\n $sort: [${upperFirst(action)}SortItem]){\n ${action} (where: $where, limit: $limit, offset: $offset, sort: $sort){\n ${props}\n id\n __typename\n }\n }\n `;\nconst generateMultiItemQuery = (action, props) => gql`\n query getEntityData($where: JSON){\n ${action} (where: $where){\n ${props}\n id\n __typename\n }\n }\n `;\n\nconst generateSingleItemQuery = (action, props) => gql`\n query getEntityData($id: String!){\n entityData: ${action}(id: $id){\n ${props},\n id,\n __typename\n }\n }\n `;\n\n// TODO: extend function to handle properties and make them dynamic with a config schema for each entity.\nconst getAction = (action, props) => {\n const query = generateQuery(action, props);\n return gql`\n ${query}\n `;\n};\n\nconst getPublishedContent = entity => `\n query searchPublishedContent(\n $rawQueryStringified: String!\n $offset: Int\n $limit: Int\n $sort: String\n ) {\n searchPublishedContent(\n rawQueryStringified: $rawQueryStringified\n offset: $offset\n limit: $limit\n sort: $sort\n ) {\n results {\n ... on ${entity} {\n id\n name\n image {\n url\n __typename\n }\n url\n __typename\n }\n __typename\n }\n total\n __typename\n }\n }\n`;\n\nconst getItemList = gql`\n query getItemList($id: String!) {\n getItemList(id: $id) {\n listItems {\n itemId\n itemEntity\n }\n }\n }\n`;\n\nconst addItemsToList = gql`\n mutation addItemsToList(\n $name: String!\n $id: String\n $listItems: [AddItemsToListInputListItemsItem]!\n ) {\n addItemsToList(input: { name: $name, id: $id, listItems: $listItems }) {\n result {\n id\n listItems {\n itemId\n itemEntity\n }\n }\n }\n }\n`;\n\nconst removeItemsFromList = gql`\n mutation removeItemsFromList(\n $listId: String!\n $listItems: [RemoveItemsFromListInputListItemsItem]!\n ) {\n removeItemsFromList(input: { id: $listId, listItems: $listItems }) {\n result {\n id\n listItems {\n itemId\n itemEntity\n }\n }\n }\n }\n`;\n\nexport {\n getEntitySchema,\n getSingleEntitySchema,\n getAction,\n getFiles,\n getFileById,\n generateMultiItemQuery,\n generateSingleItemQuery,\n getPublishedContent,\n getSearchPublishedContent,\n getCount,\n getMultipleSchema,\n getUser,\n getRecordParents,\n getItemList,\n addItemsToList,\n removeItemsFromList\n};\n"],"mappings":"AAAA,SAASA,GAAT,QAAoB,gBAApB;AACA,OAAOC,UAAP,MAAuB,mBAAvB;AAEA,MAAMC,kBAAkB,GAAI;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CATA;;AAWA,MAAMC,yBAAyB,GAAGC,MAAM,IAAIJ,GAAI;AAChD;AACA;AACA,UAAUI,MAAO;AACjB;AACA;AACA,GANA;;AAQA,MAAMC,OAAO,GAAGC,SAAS,IAAIN,GAAI;AACjC;AACA;AACA;AACA,QAAQM,SAAU;AAClB;AACA;AACA,CAPA;;AASA,MAAMC,eAAe,GAAGP,GAAI;AAC5B;AACA;AACA,QAAQE,kBAAmB;AAC3B;AACA;AACA,CANA;AAQA,MAAMM,qBAAqB,GAAGR,GAAI;AAClC;AACA;AACA,QAAQE,kBAAmB;AAC3B;AACA;AACA,CANA;;AAQA,MAAMO,gBAAgB,GAAGC,SAAS,IAAIV,GAAI;AAC1C;AACA,mBAAmBU,SAAU;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAZA;;AAcA,MAAMC,iBAAiB,GAAGC,WAAW,IAAI;EACvC,MAAMC,WAAW,GAAGD,WAAW,CAC5BE,GADiB,CAEhBC,EAAE,IAAK,GAAEA,EAAG,0BAAyBA,EAAG;AAC9C,cAAcb,kBAAmB;AACjC,QAJsB,EAMjBc,IANiB,CAMX,IANW,CAApB;EAOA,OAAOhB,GAAI;AACb;AACA,QAAQa,WAAY;AACpB,MAHE;AAID,CAZD;;AAcA,MAAMI,QAAQ,GAAGjB,GAAI;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CARA;AAUA,MAAMkB,WAAW,GAAGlB,GAAI;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CARA;;AAUA,MAAMmB,QAAQ,GAAGC,MAAM,IAAIpB,GAAI;AAC/B,MAAMoB,MAAO;AACb;AACA,CAHA;;AAKA,MAAMC,aAAa,GAAG,CAACD,MAAD,EAASE,KAAT,KAAoB;AAC1C;AACA;AACA;AACA;AACA,cAAcrB,UAAU,CAACmB,MAAD,CAAS;AACjC,MAAMA,MAAO;AACb,QAAQE,KAAM;AACd;AACA;AACA;AACA;AACA,GAZA;;AAaA,MAAMC,sBAAsB,GAAG,CAACH,MAAD,EAASE,KAAT,KAAmBtB,GAAI;AACtD;AACA,MAAMoB,MAAO;AACb,QAAQE,KAAM;AACd;AACA;AACA;AACA;AACA,GARA;;AAUA,MAAME,uBAAuB,GAAG,CAACJ,MAAD,EAASE,KAAT,KAAmBtB,GAAI;AACvD;AACA,kBAAkBoB,MAAO;AACzB,MAAME,KAAM;AACZ;AACA;AACA;AACA;AACA,GARA,C,CAUA;;;AACA,MAAMG,SAAS,GAAG,CAACL,MAAD,EAASE,KAAT,KAAmB;EACnC,MAAMI,KAAK,GAAGL,aAAa,CAACD,MAAD,EAASE,KAAT,CAA3B;EACA,OAAOtB,GAAI;AACb,MAAM0B,KAAM;AACZ,GAFE;AAGD,CALD;;AAOA,MAAMC,mBAAmB,GAAGC,MAAM,IAAK;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiBA,MAAO;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CA9BA;;AAgCA,MAAMC,WAAW,GAAG7B,GAAI;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CATA;AAWA,MAAM8B,cAAc,GAAG9B,GAAI;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAhBA;AAkBA,MAAM+B,mBAAmB,GAAG/B,GAAI;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAfA;AAiBA,SACEO,eADF,EAEEC,qBAFF,EAGEiB,SAHF,EAIER,QAJF,EAKEC,WALF,EAMEK,sBANF,EAOEC,uBAPF,EAQEG,mBARF,EASExB,yBATF,EAUEgB,QAVF,EAWER,iBAXF,EAYEN,OAZF,EAaEI,gBAbF,EAcEoB,WAdF,EAeEC,cAfF,EAgBEC,mBAhBF"}
|
|
@@ -1,23 +1,37 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
const _excluded = ["entity", "propsToDisplay", "itemsToDisplay"],
|
|
3
|
+
const _excluded = ["entity", "propsToDisplay", "itemsToDisplay", "itemListName"],
|
|
4
4
|
_excluded2 = ["gridModifier"];
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { useQuery } from '@apollo/client';
|
|
7
|
+
import { useRouter } from 'next/router';
|
|
7
8
|
import PropTypes from 'prop-types';
|
|
8
|
-
import {
|
|
9
|
+
import { parseUrl } from 'query-string';
|
|
10
|
+
import { getSingleEntitySchema, getItemList } from '../../application/query';
|
|
9
11
|
import CardRender from './CardRender';
|
|
10
|
-
import { buildPropsQuery, getGenericProps, checkPropsToUse } from '../../helpers';
|
|
12
|
+
import { buildPropsQuery, getGenericProps, checkPropsToUse, getItemListId, getItemListIds } from '../../helpers';
|
|
11
13
|
import { WITH_BANNER } from '../../constants';
|
|
12
14
|
|
|
13
15
|
const CardFactory = _ref => {
|
|
14
16
|
let {
|
|
15
17
|
entity,
|
|
16
18
|
propsToDisplay,
|
|
17
|
-
itemsToDisplay
|
|
19
|
+
itemsToDisplay,
|
|
20
|
+
itemListName
|
|
18
21
|
} = _ref,
|
|
19
22
|
cardProps = _objectWithoutProperties(_ref, _excluded);
|
|
20
23
|
|
|
24
|
+
const router = useRouter();
|
|
25
|
+
const {
|
|
26
|
+
asPath
|
|
27
|
+
} = router;
|
|
28
|
+
const parsedQuery = asPath.replace(/%5D/g, ']').replace(/%5B/g, '[');
|
|
29
|
+
const {
|
|
30
|
+
query: {
|
|
31
|
+
itemListId: queryItemListId
|
|
32
|
+
} = {}
|
|
33
|
+
} = parseUrl(parsedQuery);
|
|
34
|
+
const itemListId = getItemListId(itemListName, queryItemListId);
|
|
21
35
|
const {
|
|
22
36
|
data,
|
|
23
37
|
error,
|
|
@@ -27,7 +41,16 @@ const CardFactory = _ref => {
|
|
|
27
41
|
id: entity
|
|
28
42
|
}
|
|
29
43
|
});
|
|
30
|
-
|
|
44
|
+
const {
|
|
45
|
+
data: itemListData = {},
|
|
46
|
+
loading: itemListLoading
|
|
47
|
+
} = useQuery(getItemList, {
|
|
48
|
+
variables: {
|
|
49
|
+
id: itemListId
|
|
50
|
+
},
|
|
51
|
+
skip: !itemListId
|
|
52
|
+
});
|
|
53
|
+
if (loading || itemListLoading) return '';
|
|
31
54
|
if (error) return error.message;
|
|
32
55
|
if (!data) return null;
|
|
33
56
|
const propsToDisplayValues = checkPropsToUse(propsToDisplay);
|
|
@@ -40,11 +63,12 @@ const CardFactory = _ref => {
|
|
|
40
63
|
cardRenderProps = _objectWithoutProperties(_getGenericProps, _excluded2);
|
|
41
64
|
|
|
42
65
|
const extraModifierForBanner = cardRenderProps.banner ? WITH_BANNER : '';
|
|
66
|
+
const itemListIds = getItemListIds(itemListData);
|
|
43
67
|
return /*#__PURE__*/React.createElement(CardRender, _extends({
|
|
44
68
|
gridModifier: `${gridModifier}${extraModifierForBanner}`,
|
|
45
69
|
bannerModifier: extraModifierForBanner,
|
|
46
70
|
entity: entity,
|
|
47
|
-
itemsToDisplay: itemsToDisplay,
|
|
71
|
+
itemsToDisplay: itemListIds || itemsToDisplay,
|
|
48
72
|
propsToDisplay: propsToDisplay,
|
|
49
73
|
entityFields: extraProps
|
|
50
74
|
}, cardRenderProps));
|
|
@@ -53,11 +77,13 @@ const CardFactory = _ref => {
|
|
|
53
77
|
CardFactory.propTypes = {
|
|
54
78
|
entity: PropTypes.string.isRequired,
|
|
55
79
|
propsToDisplay: PropTypes.array,
|
|
56
|
-
itemsToDisplay: PropTypes.array
|
|
80
|
+
itemsToDisplay: PropTypes.array,
|
|
81
|
+
itemListName: PropTypes.string
|
|
57
82
|
};
|
|
58
83
|
CardFactory.defaultProps = {
|
|
59
84
|
propsToDisplay: [],
|
|
60
|
-
itemsToDisplay: []
|
|
85
|
+
itemsToDisplay: [],
|
|
86
|
+
itemListName: ''
|
|
61
87
|
};
|
|
62
88
|
export default CardFactory;
|
|
63
89
|
//# sourceMappingURL=CardFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CardFactory.js","names":["React","useQuery","PropTypes","getSingleEntitySchema","CardRender","buildPropsQuery","getGenericProps","checkPropsToUse","WITH_BANNER","CardFactory","entity","propsToDisplay","itemsToDisplay","cardProps","data","error","loading","variables","id","message","propsToDisplayValues","extraProps","gridModifier","cardRenderProps","extraModifierForBanner","banner","propTypes","string","isRequired","array","defaultProps"],"sources":["../../../src/components/Card/CardFactory.js"],"sourcesContent":["import React from 'react';\nimport { useQuery } from '@apollo/client';\nimport PropTypes from 'prop-types';\nimport { getSingleEntitySchema } from '../../application/query';\nimport CardRender from './CardRender';\nimport {
|
|
1
|
+
{"version":3,"file":"CardFactory.js","names":["React","useQuery","useRouter","PropTypes","parseUrl","getSingleEntitySchema","getItemList","CardRender","buildPropsQuery","getGenericProps","checkPropsToUse","getItemListId","getItemListIds","WITH_BANNER","CardFactory","entity","propsToDisplay","itemsToDisplay","itemListName","cardProps","router","asPath","parsedQuery","replace","query","itemListId","queryItemListId","data","error","loading","variables","id","itemListData","itemListLoading","skip","message","propsToDisplayValues","extraProps","gridModifier","cardRenderProps","extraModifierForBanner","banner","itemListIds","propTypes","string","isRequired","array","defaultProps"],"sources":["../../../src/components/Card/CardFactory.js"],"sourcesContent":["import React from 'react';\nimport { useQuery } from '@apollo/client';\nimport { useRouter } from 'next/router';\nimport PropTypes from 'prop-types';\nimport { parseUrl } from 'query-string';\nimport { getSingleEntitySchema, getItemList } from '../../application/query';\nimport CardRender from './CardRender';\nimport {\n buildPropsQuery,\n getGenericProps,\n checkPropsToUse,\n getItemListId,\n getItemListIds\n} from '../../helpers';\nimport { WITH_BANNER } from '../../constants';\n\nconst CardFactory = ({ entity, propsToDisplay, itemsToDisplay, itemListName, ...cardProps }) => {\n const router = useRouter();\n const { asPath } = router;\n const parsedQuery = asPath.replace(/%5D/g, ']').replace(/%5B/g, '[');\n const { query: { itemListId: queryItemListId } = {} } = parseUrl(parsedQuery);\n const itemListId = getItemListId(itemListName, queryItemListId);\n const { data, error, loading } = useQuery(getSingleEntitySchema, {\n variables: { id: entity }\n });\n const { data: itemListData = {}, loading: itemListLoading } = useQuery(getItemList, {\n variables: { id: itemListId },\n skip: !itemListId\n });\n\n if (loading || itemListLoading) return '';\n if (error) return error.message;\n if (!data) return null;\n\n const propsToDisplayValues = checkPropsToUse(propsToDisplay);\n const extraProps = buildPropsQuery(data, propsToDisplayValues, cardProps) || '';\n const { gridModifier, ...cardRenderProps } = getGenericProps(cardProps);\n const extraModifierForBanner = cardRenderProps.banner ? WITH_BANNER : '';\n const itemListIds = getItemListIds(itemListData);\n\n return (\n <CardRender\n gridModifier={`${gridModifier}${extraModifierForBanner}`}\n bannerModifier={extraModifierForBanner}\n entity={entity}\n itemsToDisplay={itemListIds || itemsToDisplay}\n propsToDisplay={propsToDisplay}\n entityFields={extraProps}\n {...cardRenderProps}\n />\n );\n};\n\nCardFactory.propTypes = {\n entity: PropTypes.string.isRequired,\n propsToDisplay: PropTypes.array,\n itemsToDisplay: PropTypes.array,\n itemListName: PropTypes.string\n};\n\nCard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J,WAAf"}
|
|
@@ -95,7 +95,7 @@ const CarouselWrapper = ({
|
|
|
95
95
|
handleButtonNavigation();
|
|
96
96
|
}
|
|
97
97
|
}, /*#__PURE__*/React.createElement("i", {
|
|
98
|
-
className: "carousel--arrow__left"
|
|
98
|
+
className: "cards-carousel--arrow__left"
|
|
99
99
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
100
100
|
className: "cards-carousel--right-button-wrapper"
|
|
101
101
|
}, displayRight && /*#__PURE__*/React.createElement("button", {
|
|
@@ -106,7 +106,7 @@ const CarouselWrapper = ({
|
|
|
106
106
|
handleButtonNavigation(true);
|
|
107
107
|
}
|
|
108
108
|
}, /*#__PURE__*/React.createElement("i", {
|
|
109
|
-
className: "carousel--arrow__right"
|
|
109
|
+
className: "cards-carousel--arrow__right"
|
|
110
110
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
111
111
|
className: contentClassName,
|
|
112
112
|
ref: ref,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselWrapper.js","names":["React","useRef","useState","useEffect","PropTypes","CarouselWrapper","children","bannerModifier","itemsPerRow","enableAutoScroll","autoScrollTimer","arrowSize","ref","buttonDisplay","setButtonDisplays","displayLeft","displayRight","shouldAutoScroll","setShouldAutoScroll","autoScrollRef","current","id","setInterval","scrollCheck","clearInterval","handleButtonNavigation","offsetWidth","scrollWidth","handleScroll","scrollLeft","updatedDisplayLeft","updatedDisplayRight","direction","wrapperClassName","contentClassName","propTypes","string","number","oneOfType","arrayOf","node","bool","defaultProps"],"sources":["../../src/components/CarouselWrapper.js"],"sourcesContent":["import React, { useRef, useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\n\nconst CarouselWrapper = ({\n children,\n bannerModifier,\n itemsPerRow,\n enableAutoScroll,\n autoScrollTimer,\n arrowSize\n}) => {\n const ref = useRef();\n const [buttonDisplay, setButtonDisplays] = useState({ displayLeft: false, displayRight: true });\n const [shouldAutoScroll, setShouldAutoScroll] = useState(false);\n const autoScrollRef = useRef();\n\n useEffect(\n () => {\n autoScrollRef.current = shouldAutoScroll;\n const id = setInterval(scrollCheck, autoScrollTimer);\n function scrollCheck() {\n if (!autoScrollRef.current) {\n clearInterval(id);\n } else {\n handleButtonNavigation(true);\n }\n }\n\n return () => clearInterval(id);\n },\n [autoScrollTimer, shouldAutoScroll]\n );\n\n useEffect(\n () => {\n const {\n current: { offsetWidth, scrollWidth }\n } = ref;\n if (scrollWidth <= offsetWidth)\n setButtonDisplays({ displayLeft: false, displayRight: false });\n setShouldAutoScroll(enableAutoScroll);\n },\n [enableAutoScroll]\n );\n\n const handleScroll = () => {\n const {\n current: { offsetWidth, scrollLeft, scrollWidth }\n } = ref;\n const updatedDisplayLeft = !!scrollLeft;\n const updatedDisplayRight = scrollLeft + offsetWidth + 1 < scrollWidth;\n setButtonDisplays({ displayLeft: updatedDisplayLeft, displayRight: updatedDisplayRight });\n };\n\n const handleButtonNavigation = direction => {\n if (!ref || !ref.current) return;\n const {\n current: { offsetWidth, scrollLeft, scrollWidth }\n } = ref;\n\n if (autoScrollRef.current && scrollLeft + offsetWidth >= scrollWidth) {\n ref.current.scrollLeft = 0;\n } else {\n ref.current.scrollLeft = direction ? scrollLeft + offsetWidth : scrollLeft - offsetWidth;\n }\n };\n\n const { displayLeft, displayRight } = buttonDisplay;\n const wrapperClassName = `cards-carousel${bannerModifier}`;\n const contentClassName = `cards-carousel--content items-per-row-${itemsPerRow}`;\n\n return (\n <div className={wrapperClassName}>\n <div className=\"cards-carousel--left-button-wrapper\">\n {displayLeft && (\n <button\n type=\"button\"\n className=\"cards-carousel--button-back icon-button icon\"\n onClick={() => {\n setShouldAutoScroll(false);\n handleButtonNavigation();\n }}>\n <i className=\"carousel--arrow__left\" />\n </button>\n )}\n </div>\n <div className=\"cards-carousel--right-button-wrapper\">\n {displayRight && (\n <button\n type=\"button\"\n className=\"cards-carousel--button-forward icon-button icon\"\n onClick={() => {\n setShouldAutoScroll(false);\n handleButtonNavigation(true);\n }}>\n <i className=\"carousel--arrow__right\" />\n </button>\n )}\n </div>\n <div className={contentClassName} ref={ref} onScroll={handleScroll}>\n {children}\n </div>\n </div>\n );\n};\n\nCarouselWrapper.propTypes = {\n bannerModifier: PropTypes.string,\n itemsPerRow: PropTypes.number,\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),\n enableAutoScroll: PropTypes.bool,\n autoScrollTimer: PropTypes.number,\n arrowSize: PropTypes.number\n};\n\nCarouselWrapper.defaultProps = {\n itemsPerRow: 0,\n bannerModifier: '',\n children: [],\n enableAutoScroll: false,\n autoScrollTimer: 0,\n arrowSize: 14\n};\n\nexport default CarouselWrapper;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,MAAhB,EAAwBC,QAAxB,EAAkCC,SAAlC,QAAmD,OAAnD;AACA,OAAOC,SAAP,MAAsB,YAAtB;;AAEA,MAAMC,eAAe,GAAG,CAAC;EACvBC,QADuB;EAEvBC,cAFuB;EAGvBC,WAHuB;EAIvBC,gBAJuB;EAKvBC,eALuB;EAMvBC;AANuB,CAAD,KAOlB;EACJ,MAAMC,GAAG,GAAGX,MAAM,EAAlB;EACA,MAAM,CAACY,aAAD,EAAgBC,iBAAhB,IAAqCZ,QAAQ,CAAC;IAAEa,WAAW,EAAE,KAAf;IAAsBC,YAAY,EAAE;EAApC,CAAD,CAAnD;EACA,MAAM,CAACC,gBAAD,EAAmBC,mBAAnB,IAA0ChB,QAAQ,CAAC,KAAD,CAAxD;EACA,MAAMiB,aAAa,GAAGlB,MAAM,EAA5B;EAEAE,SAAS,CACP,MAAM;IACJgB,aAAa,CAACC,OAAd,GAAwBH,gBAAxB;IACA,MAAMI,EAAE,GAAGC,WAAW,CAACC,WAAD,EAAcb,eAAd,CAAtB;;IACA,SAASa,WAAT,GAAuB;MACrB,IAAI,CAACJ,aAAa,CAACC,OAAnB,EAA4B;QAC1BI,aAAa,CAACH,EAAD,CAAb;MACD,CAFD,MAEO;QACLI,sBAAsB,C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iC;AANK,CAA5B;AASAhC,eAAe,CAACqC,YAAhB,GAA+B;EAC7BlC,WAAW,EAAE,CADgB;EAE7BD,cAAc,EAAE,EAFa;EAG7BD,QAAQ,EAAE,EAHmB;EAI7BG,gBAAgB,EAAE,KAJW;EAK7BC,eAAe,EAAE,CALY;EAM7BC,SAAS,EAAE;AANkB,CAA/B;AASA,eAAeN,eAAf"}
|
|
1
|
+
{"version":3,"file":"CarouselWrapper.js","names":["React","useRef","useState","useEffect","PropTypes","CarouselWrapper","children","bannerModifier","itemsPerRow","enableAutoScroll","autoScrollTimer","arrowSize","ref","buttonDisplay","setButtonDisplays","displayLeft","displayRight","shouldAutoScroll","setShouldAutoScroll","autoScrollRef","current","id","setInterval","scrollCheck","clearInterval","handleButtonNavigation","offsetWidth","scrollWidth","handleScroll","scrollLeft","updatedDisplayLeft","updatedDisplayRight","direction","wrapperClassName","contentClassName","propTypes","string","number","oneOfType","arrayOf","node","bool","defaultProps"],"sources":["../../src/components/CarouselWrapper.js"],"sourcesContent":["import React, { useRef, useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\n\nconst CarouselWrapper = ({\n children,\n bannerModifier,\n itemsPerRow,\n enableAutoScroll,\n autoScrollTimer,\n arrowSize\n}) => {\n const ref = useRef();\n const [buttonDisplay, setButtonDisplays] = useState({ displayLeft: false, displayRight: true });\n const [shouldAutoScroll, setShouldAutoScroll] = useState(false);\n const autoScrollRef = useRef();\n\n useEffect(\n () => {\n autoScrollRef.current = shouldAutoScroll;\n const id = setInterval(scrollCheck, autoScrollTimer);\n function scrollCheck() {\n if (!autoScrollRef.current) {\n clearInterval(id);\n } else {\n handleButtonNavigation(true);\n }\n }\n\n return () => clearInterval(id);\n },\n [autoScrollTimer, shouldAutoScroll]\n );\n\n useEffect(\n () => {\n const {\n current: { offsetWidth, scrollWidth }\n } = ref;\n if (scrollWidth <= offsetWidth)\n setButtonDisplays({ displayLeft: false, displayRight: false });\n setShouldAutoScroll(enableAutoScroll);\n },\n [enableAutoScroll]\n );\n\n const handleScroll = () => {\n const {\n current: { offsetWidth, scrollLeft, scrollWidth }\n } = ref;\n const updatedDisplayLeft = !!scrollLeft;\n const updatedDisplayRight = scrollLeft + offsetWidth + 1 < scrollWidth;\n setButtonDisplays({ displayLeft: updatedDisplayLeft, displayRight: updatedDisplayRight });\n };\n\n const handleButtonNavigation = direction => {\n if (!ref || !ref.current) return;\n const {\n current: { offsetWidth, scrollLeft, scrollWidth }\n } = ref;\n\n if (autoScrollRef.current && scrollLeft + offsetWidth >= scrollWidth) {\n ref.current.scrollLeft = 0;\n } else {\n ref.current.scrollLeft = direction ? scrollLeft + offsetWidth : scrollLeft - offsetWidth;\n }\n };\n\n const { displayLeft, displayRight } = buttonDisplay;\n const wrapperClassName = `cards-carousel${bannerModifier}`;\n const contentClassName = `cards-carousel--content items-per-row-${itemsPerRow}`;\n\n return (\n <div className={wrapperClassName}>\n <div className=\"cards-carousel--left-button-wrapper\">\n {displayLeft && (\n <button\n type=\"button\"\n className=\"cards-carousel--button-back icon-button icon\"\n onClick={() => {\n setShouldAutoScroll(false);\n handleButtonNavigation();\n }}>\n <i className=\"cards-carousel--arrow__left\" />\n </button>\n )}\n </div>\n <div className=\"cards-carousel--right-button-wrapper\">\n {displayRight && (\n <button\n type=\"button\"\n className=\"cards-carousel--button-forward icon-button icon\"\n onClick={() => {\n setShouldAutoScroll(false);\n handleButtonNavigation(true);\n }}>\n <i className=\"cards-carousel--arrow__right\" />\n </button>\n )}\n </div>\n <div className={contentClassName} ref={ref} onScroll={handleScroll}>\n {children}\n </div>\n </div>\n );\n};\n\nCarouselWrapper.propTypes = {\n bannerModifier: PropTypes.string,\n itemsPerRow: PropTypes.number,\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),\n enableAutoScroll: PropTypes.bool,\n autoScrollTimer: PropTypes.number,\n arrowSize: PropTypes.number\n};\n\nCarouselWrapper.defaultProps = {\n itemsPerRow: 0,\n bannerModifier: '',\n children: [],\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kStarFill, BsBookmarkCheckFill, BsBookmarkStar, BsBookmarkXFill } from 'react-icons/bs';
|
|
4
|
+
import { useQuery, useMutation } from '@apollo/client';
|
|
5
|
+
import { getItemList, addItemsToList, removeItemsFromList } from '../../application/query';
|
|
6
|
+
import { getItemListData, getItemListId } from '../../helpers';
|
|
7
|
+
import { LIST_ITEM_LOCAL_KEY } from '../../constants';
|
|
8
|
+
|
|
9
|
+
const ItemListButton = ({
|
|
10
|
+
listName,
|
|
11
|
+
parent,
|
|
12
|
+
modifier
|
|
13
|
+
}) => {
|
|
14
|
+
const {
|
|
15
|
+
itemId,
|
|
16
|
+
itemEntity
|
|
17
|
+
} = parent;
|
|
18
|
+
const idFromStorage = getItemListId(listName);
|
|
19
|
+
const [listId, setListId] = useState(idFromStorage);
|
|
20
|
+
const [isHover, setIsHover] = useState(false);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const storageEventHandler = () => {
|
|
23
|
+
const newId = getItemListId(listName);
|
|
24
|
+
setListId(newId);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
window.addEventListener('storage', storageEventHandler);
|
|
28
|
+
return () => {
|
|
29
|
+
window.removeEventListener('storage', storageEventHandler);
|
|
30
|
+
};
|
|
31
|
+
}, [listName]);
|
|
32
|
+
|
|
33
|
+
const getIcon = () => {
|
|
34
|
+
if (isInList) return isHover ? BsBookmarkXFill : BsBookmarkCheckFill;
|
|
35
|
+
return isHover ? BsBookmarkStarFill : BsBookmarkStar;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const {
|
|
39
|
+
data,
|
|
40
|
+
error,
|
|
41
|
+
loading
|
|
42
|
+
} = useQuery(getItemList, {
|
|
43
|
+
variables: {
|
|
44
|
+
id: listId
|
|
45
|
+
},
|
|
46
|
+
skip: !listId
|
|
47
|
+
});
|
|
48
|
+
const [addListItem] = useMutation(addItemsToList, {
|
|
49
|
+
onCompleted: ({
|
|
50
|
+
addItemsToList: listAddResult
|
|
51
|
+
}) => {
|
|
52
|
+
const {
|
|
53
|
+
result: {
|
|
54
|
+
id
|
|
55
|
+
}
|
|
56
|
+
} = listAddResult;
|
|
57
|
+
|
|
58
|
+
if (!listId) {
|
|
59
|
+
localStorage.setItem(LIST_ITEM_LOCAL_KEY(listName), id);
|
|
60
|
+
window.dispatchEvent(new Event('storage'));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const [removeListItem] = useMutation(removeItemsFromList);
|
|
65
|
+
|
|
66
|
+
const clickHandler = () => {
|
|
67
|
+
setIsHover(false);
|
|
68
|
+
isInList ? removeListItem({
|
|
69
|
+
variables: {
|
|
70
|
+
listId,
|
|
71
|
+
listItems: [{
|
|
72
|
+
itemId,
|
|
73
|
+
itemEntity
|
|
74
|
+
}]
|
|
75
|
+
},
|
|
76
|
+
skip: !listId
|
|
77
|
+
}) : addListItem({
|
|
78
|
+
variables: {
|
|
79
|
+
name: listName,
|
|
80
|
+
id: listId,
|
|
81
|
+
listItems: [{
|
|
82
|
+
itemId,
|
|
83
|
+
itemEntity
|
|
84
|
+
}]
|
|
85
|
+
},
|
|
86
|
+
skip: !listId
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
if (loading) return '';
|
|
91
|
+
if (error) return error.message;
|
|
92
|
+
const listItems = getItemListData(data);
|
|
93
|
+
const isInList = !!listItems.find(({
|
|
94
|
+
itemId: idToCheck
|
|
95
|
+
}) => idToCheck === itemId);
|
|
96
|
+
const Icon = getIcon();
|
|
97
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
98
|
+
className: `item-list-button ${modifier}`,
|
|
99
|
+
role: "button",
|
|
100
|
+
onClick: clickHandler,
|
|
101
|
+
onMouseEnter: () => setIsHover(true),
|
|
102
|
+
onMouseLeave: () => setIsHover(false)
|
|
103
|
+
}, /*#__PURE__*/React.createElement("i", null, /*#__PURE__*/React.createElement(Icon, null)));
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
ItemListButton.propTypes = {
|
|
107
|
+
parent: PropTypes.object,
|
|
108
|
+
listName: PropTypes.string,
|
|
109
|
+
modifier: PropTypes.string
|
|
110
|
+
};
|
|
111
|
+
ItemListButton.defaultProps = {
|
|
112
|
+
parent: {},
|
|
113
|
+
listName: '',
|
|
114
|
+
modifier: ''
|
|
115
|
+
};
|
|
116
|
+
export default ItemListButton;
|
|
117
|
+
//# sourceMappingURL=ItemListButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemListButton.js","names":["React","useState","useEffect","PropTypes","BsBookmarkStarFill","BsBookmarkCheckFill","BsBookmarkStar","BsBookmarkXFill","useQuery","useMutation","getItemList","addItemsToList","removeItemsFromList","getItemListData","getItemListId","LIST_ITEM_LOCAL_KEY","ItemListButton","listName","parent","modifier","itemId","itemEntity","idFromStorage","listId","setListId","isHover","setIsHover","storageEventHandler","newId","window","addEventListener","removeEventListener","getIcon","isInList","data","error","loading","variables","id","skip","addListItem","onCompleted","listAddResult","result","localStorage","setItem","dispatchEvent","Event","removeListItem","clickHandler","listItems","name","message","find","idToCheck","Icon","propTypes","object","string","defaultProps"],"sources":["../../../src/components/ItemListButton/ItemListButton.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport {\n BsBookmarkStarFill,\n BsBookmarkCheckFill,\n BsBookmarkStar,\n BsBookmarkXFill\n} from 'react-icons/bs';\nimport { useQuery, useMutation } from '@apollo/client';\nimport { getItemList, addItemsToList, removeItemsFromList } from '../../application/query';\nimport { getItemListData, getItemListId } from '../../helpers';\nimport { LIST_ITEM_LOCAL_KEY } from '../../constants';\n\nconst ItemListButton = ({ listName, parent, modifier }) => {\n const { itemId, itemEntity } = parent;\n const idFromStorage = getItemListId(listName);\n const [listId, setListId] = useState(idFromStorage);\n const [isHover, setIsHover] = useState(false);\n\n useEffect(\n () => {\n const storageEventHandler = () => {\n const newId = getItemListId(listName);\n setListId(newId);\n };\n\n window.addEventListener('storage', storageEventHandler);\n\n return () => {\n window.removeEventListener('storage', storageEventHandler);\n };\n },\n [listName]\n );\n const getIcon = () => {\n if (isInList) return isHover ? BsBookmarkXFill : BsBookmarkCheckFill;\n return isHover ? BsBookmarkStarFill : BsBookmarkStar;\n };\n\n const { data, error, loading } = useQuery(getItemList, {\n variables: { id: listId },\n skip: !listId\n });\n\n const [addListItem] = useMutation(addItemsToList, {\n onCompleted: ({ addItemsToList: listAddResult }) => {\n const {\n result: { id }\n } = listAddResult;\n\n if (!listId) {\n localStorage.setItem(LIST_ITEM_LOCAL_KEY(listName), id);\n window.dispatchEvent(new Event('storage'));\n }\n }\n });\n\n const [removeListItem] = useMutation(removeItemsFromList);\n\n const clickHandler = () => {\n setIsHover(false);\n isInList\n ? removeListItem({\n variables: { listId, listItems: [{ itemId, itemEntity }] },\n skip: !listId\n })\n : addListItem({\n variables: { name: listName, id: listId, listItems: [{ itemId, itemEntity }] },\n skip: !listId\n });\n };\n\n if (loading) return '';\n if (error) return error.message;\n\n const listItems = getItemListData(data);\n const isInList = !!listItems.find(({ itemId: idToCheck }) => idToCheck === itemId);\n\n const Icon = getIcon();\n\n return (\n <div\n className={`item-list-button ${modifier}`}\n role=\"button\"\n onClick={clickHandler}\n onMouseEnter={() => setIsHover(true)}\n onMouseLeave={() => setIsHover(false)}>\n <i>\n <Icon />\n </i>\n </div>\n );\n};\n\nItemListButton.propTypes = {\n parent: PropTypes.object,\n listName: PropTypes.string,\n modifier: PropTypes.string\n};\n\nItemListButton.defaultProps = {\n parent: {},\n listName: '',\n modifier: ''\n};\n\nexport default ItemListButton;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SACEC,kBADF,EAEEC,mBAFF,EAGEC,cAHF,EAIEC,eAJF,QAKO,gBALP;AAMA,SAASC,QAAT,EAAmBC,WAAnB,QAAsC,gBAAtC;AACA,SAASC,WAAT,EAAsBC,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AI,EAAC,QAFP;IAGE,OAAO,EAAE8B,YAHX;IAIE,YAAY,EAAE,MAAMvB,UAAU,CAAC,IAAD,CAJhC;IAKE,YAAY,EAAE,MAAMA,UAAU,CAAC,KAAD;EALhC,gBAME,4CACE,oBAAC,IAAD,OADF,CANF,CADF;AAYD,CA/ED;;AAiFAV,cAAc,CAACwC,SAAf,GAA2B;EACzBtC,MAAM,EAAEf,SAAS,CAACsD,MADO;EAEzBxC,QAAQ,EAAEd,SAAS,CAACuD,MAFK;EAGzBvC,QAAQ,EAAEhB,SAAS,CAACuD;AAHK,CAA3B;AAMA1C,cAAc,CAAC2C,YAAf,GAA8B;EAC5BzC,MAAM,EAAE,EADoB;EAE5BD,QAAQ,EAAE,EAFkB;EAG5BE,QAAQ,EAAE;AAHkB,CAA9B;AAMA,eAAeH,cAAf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["ItemListButton"],"sources":["../../../src/components/ItemListButton/index.js"],"sourcesContent":["import ItemListButton from './ItemListButton';\n\nexport default ItemListButton;\n"],"mappings":"AAAA,OAAOA,cAAP,MAA2B,kBAA3B;AAEA,eAAeA,cAAf"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useRouter } from 'next/router';
|
|
4
|
+
import { useQuery } from '@apollo/client';
|
|
5
|
+
import { BsBookmarkStarFill, BsBookmarkStar } from 'react-icons/bs';
|
|
6
|
+
import { getItemList } from '../../application/query';
|
|
7
|
+
import { getItemListData, getItemListId } from '../../helpers';
|
|
8
|
+
|
|
9
|
+
const ItemListCounter = ({
|
|
10
|
+
listName,
|
|
11
|
+
modifier,
|
|
12
|
+
url
|
|
13
|
+
}) => {
|
|
14
|
+
const router = useRouter();
|
|
15
|
+
const idFromStorage = getItemListId(listName);
|
|
16
|
+
const [listId, setListId] = useState(idFromStorage);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const storageEventHandler = () => {
|
|
19
|
+
const newId = getItemListId(listName);
|
|
20
|
+
setListId(newId);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
window.addEventListener('storage', storageEventHandler);
|
|
24
|
+
return () => {
|
|
25
|
+
window.removeEventListener('storage', storageEventHandler);
|
|
26
|
+
};
|
|
27
|
+
}, [listName]);
|
|
28
|
+
const {
|
|
29
|
+
data,
|
|
30
|
+
error,
|
|
31
|
+
loading
|
|
32
|
+
} = useQuery(getItemList, {
|
|
33
|
+
variables: {
|
|
34
|
+
id: listId
|
|
35
|
+
},
|
|
36
|
+
skip: !listId
|
|
37
|
+
});
|
|
38
|
+
if (loading) return '';
|
|
39
|
+
if (error) return error.message;
|
|
40
|
+
const listItems = getItemListData(data);
|
|
41
|
+
const listLength = listItems.length;
|
|
42
|
+
const CounterIcon = listLength ? BsBookmarkStarFill : BsBookmarkStar;
|
|
43
|
+
|
|
44
|
+
const handleClick = () => router.push('/Resolver', `${url}?itemListId=${listId}`);
|
|
45
|
+
|
|
46
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
role: "button",
|
|
48
|
+
type: "button",
|
|
49
|
+
className: `icon-button item-list-counter ${modifier}`,
|
|
50
|
+
onClick: handleClick
|
|
51
|
+
}, /*#__PURE__*/React.createElement(CounterIcon, null), /*#__PURE__*/React.createElement("span", {
|
|
52
|
+
className: "icon-button__badge"
|
|
53
|
+
}, listLength));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
ItemListCounter.propTypes = {
|
|
57
|
+
url: PropTypes.string,
|
|
58
|
+
listName: PropTypes.string,
|
|
59
|
+
modifier: PropTypes.string
|
|
60
|
+
};
|
|
61
|
+
ItemListCounter.defaultProps = {
|
|
62
|
+
url: '',
|
|
63
|
+
listName: '',
|
|
64
|
+
modifier: ''
|
|
65
|
+
};
|
|
66
|
+
export default ItemListCounter;
|
|
67
|
+
//# sourceMappingURL=ItemListCounter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemListCounter.js","names":["React","useState","useEffect","PropTypes","useRouter","useQuery","BsBookmarkStarFill","BsBookmarkStar","getItemList","getItemListData","getItemListId","ItemListCounter","listName","modifier","url","router","idFromStorage","listId","setListId","storageEventHandler","newId","window","addEventListener","removeEventListener","data","error","loading","variables","id","skip","message","listItems","listLength","length","CounterIcon","handleClick","push","propTypes","string","defaultProps"],"sources":["../../../src/components/ItemListCounter/ItemListCounter.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport { useRouter } from 'next/router';\nimport { useQuery } from '@apollo/client';\nimport { BsBookmarkStarFill, BsBookmarkStar } from 'react-icons/bs';\nimport { getItemList } from '../../application/query';\nimport { getItemListData, getItemListId } from '../../helpers';\n\nconst ItemListCounter = ({ listName, modifier, url }) => {\n const router = useRouter();\n const idFromStorage = getItemListId(listName);\n const [listId, setListId] = useState(idFromStorage);\n\n useEffect(\n () => {\n const storageEventHandler = () => {\n const newId = getItemListId(listName);\n setListId(newId);\n };\n\n window.addEventListener('storage', storageEventHandler);\n\n return () => {\n window.removeEventListener('storage', storageEventHandler);\n };\n },\n [listName]\n );\n\n const { data, error, loading } = useQuery(getItemList, {\n variables: { id: listId },\n skip: !listId\n });\n\n if (loading) return '';\n if (error) return error.message;\n const listItems = getItemListData(data);\n const listLength = listItems.length;\n const CounterIcon = listLength ? BsBookmarkStarFill : BsBookmarkStar;\n\n const handleClick = () => router.push('/Resolver', `${url}?itemListId=${listId}`);\n\n return (\n <div\n role=\"button\"\n type=\"button\"\n className={`icon-button item-list-counter ${modifier}`}\n onClick={handleClick}>\n <CounterIcon />\n <span className=\"icon-button__badge\">{listLength}</span>\n </div>\n );\n};\n\nItemListCounter.propTypes = {\n url: PropTypes.string,\n listName: PropTypes.string,\n modifier: PropTypes.string\n};\n\nItemListCounter.defaultProps = {\n url: '',\n listName: '',\n modifier: ''\n};\n\nexport default ItemListCounter;\n"],"mappings":"AAAA,OA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AACE,MAA7B;EACA,MAAMC,WAAW,GAAGF,UAAU,GAAG1B,kBAAH,GAAwBC,cAAtD;;EAEA,MAAM4B,WAAW,GAAG,MAAMpB,MAAM,CAACqB,IAAP,CAAY,WAAZ,EAA0B,GAAEtB,GAAI,eAAcG,MAAO,EAArD,CAA1B;;EAEA,oBACE;IACE,IAAI,EAAC,QADP;IAEE,IAAI,EAAC,QAFP;IAGE,SAAS,EAAG,iCAAgCJ,QAAS,EAHvD;IAIE,OAAO,EAAEsB;EAJX,gBAKE,oBAAC,WAAD,OALF,eAME;IAAM,SAAS,EAAC;EAAhB,GAAsCH,UAAtC,CANF,CADF;AAUD,CA5CD;;AA8CArB,eAAe,CAAC0B,SAAhB,GAA4B;EAC1BvB,GAAG,EAAEX,SAAS,CAACmC,MADW;EAE1B1B,QAAQ,EAAET,SAAS,CAACmC,MAFM;EAG1BzB,QAAQ,EAAEV,SAAS,CAACmC;AAHM,CAA5B;AAMA3B,eAAe,CAAC4B,YAAhB,GAA+B;EAC7BzB,GAAG,EAAE,EADwB;EAE7BF,QAAQ,EAAE,EAFmB;EAG7BC,QAAQ,EAAE;AAHmB,CAA/B;AAMA,eAAeF,eAAf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["ItemListCounter"],"sources":["../../../src/components/ItemListCounter/index.js"],"sourcesContent":["import ItemListCounter from './ItemListCounter';\n\nexport default ItemListCounter;\n"],"mappings":"AAAA,OAAOA,eAAP,MAA4B,mBAA5B;AAEA,eAAeA,eAAf"}
|
|
@@ -46,13 +46,15 @@ const ListBuilder = props => {
|
|
|
46
46
|
requiredSchema,
|
|
47
47
|
searchValues,
|
|
48
48
|
azFilter,
|
|
49
|
-
sortProperties
|
|
49
|
+
sortProperties,
|
|
50
|
+
itemListIds
|
|
50
51
|
} = props;
|
|
51
52
|
const isInfinite = paginationType === INFINITE;
|
|
52
53
|
const listComponent = getListComponent(isCard, paginationType);
|
|
53
54
|
const propsToDisplayValues = checkPropsToUse(propsToDisplay);
|
|
54
55
|
const entityFields = buildPropsQuery(entitySchema, propsToDisplayValues, props) || '';
|
|
55
|
-
const
|
|
56
|
+
const itemsToDisplayToUse = itemListIds || itemsToDisplay;
|
|
57
|
+
const limitToUse = limit || itemsToDisplayToUse.length;
|
|
56
58
|
const shouldApplyDefaultSort = !sortProperties || !sortProperties.length;
|
|
57
59
|
const itemsPerPageToUse = getItemsPerPageToUse(itemsPerPage, limitToUse);
|
|
58
60
|
const initialOffset = getCurrentOffset(offset, itemsPerPageToUse, paginationIndex, limitToUse);
|
|
@@ -76,7 +78,7 @@ const ListBuilder = props => {
|
|
|
76
78
|
filterOperator,
|
|
77
79
|
relations,
|
|
78
80
|
stringProps
|
|
79
|
-
}, itemId,
|
|
81
|
+
}, itemId, itemsToDisplayToUse, shouldApplyDefaultSort, {
|
|
80
82
|
shouldReturnAggs: true,
|
|
81
83
|
isAZ
|
|
82
84
|
});
|
|
@@ -106,7 +108,7 @@ const ListBuilder = props => {
|
|
|
106
108
|
relations,
|
|
107
109
|
stringProps,
|
|
108
110
|
azFilter
|
|
109
|
-
}, itemId,
|
|
111
|
+
}, itemId, itemsToDisplayToUse, shouldApplyDefaultSort, {
|
|
110
112
|
shouldReturnAggs: false,
|
|
111
113
|
isAZ
|
|
112
114
|
});
|
|
@@ -130,7 +132,9 @@ const ListBuilder = props => {
|
|
|
130
132
|
listAggregations: updatedAggregations,
|
|
131
133
|
isAZ: isAZ,
|
|
132
134
|
azFilter: azFilter
|
|
133
|
-
}, props
|
|
135
|
+
}, props, {
|
|
136
|
+
itemsToDisplay: itemsToDisplayToUse
|
|
137
|
+
}));
|
|
134
138
|
};
|
|
135
139
|
|
|
136
140
|
ListBuilder.propTypes = {
|
|
@@ -159,11 +163,13 @@ ListBuilder.propTypes = {
|
|
|
159
163
|
filterOperator: PropTypes.string.isRequired,
|
|
160
164
|
paginationType: PropTypes.string,
|
|
161
165
|
azFilter: PropTypes.string,
|
|
162
|
-
sortProperties: PropTypes.array
|
|
166
|
+
sortProperties: PropTypes.array,
|
|
167
|
+
itemListIds: PropTypes.array
|
|
163
168
|
};
|
|
164
169
|
ListBuilder.defaultProps = {
|
|
165
170
|
entityData: {},
|
|
166
171
|
itemsToDisplay: [],
|
|
172
|
+
itemListIds: null,
|
|
167
173
|
limit: 0,
|
|
168
174
|
omitWrappers: false,
|
|
169
175
|
offset: 0,
|