UNPKG

@shopify/app-bridge-host

Version:

App Bridge Host contains components and middleware to be consumed by the app's host, as well as the host itself. The middleware and `Frame` component are responsible for facilitating communication between the client and host, and used to act on actions se

50 lines (45 loc) 2.27 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var tslib = require('tslib'); var Actions = require('@shopify/app-bridge-core/actions'); var resourcePicker = require('@shopify/app-bridge-core/validate/actions/resourcePicker'); var defaultResourcePickerStore = null; function resourcePickerReducer(state, action) { if (state === void 0) { state = defaultResourcePickerStore; } var castAction = action; if (resourcePicker.validateAction(castAction)) { return state; } switch (action.type) { case Actions.ResourcePicker.Action.OPEN: case Actions.ResourcePicker.Action.UPDATE: { var open_1 = action.type === Actions.ResourcePicker.Action.OPEN ? true : (state && state.open) || false; var _a = castAction.payload, id = _a.id, initialQuery = _a.initialQuery, filterQuery = _a.filterQuery, initialSelectionIds = _a.initialSelectionIds, selectMultiple = _a.selectMultiple, showHidden = _a.showHidden, showVariants = _a.showVariants, showDraft = _a.showDraft, showArchived = _a.showArchived, showDraftBadge = _a.showDraftBadge, showArchivedBadge = _a.showArchivedBadge, resourceType = _a.resourceType, actionVerb = _a.actionVerb; return { id: id, initialQuery: initialQuery, filterQuery: filterQuery, initialSelectionIds: initialSelectionIds, selectMultiple: selectMultiple, showHidden: showHidden, showVariants: showVariants, showDraft: showDraft, showArchived: showArchived, showDraftBadge: showDraftBadge, showArchivedBadge: showArchivedBadge, resourceType: resourceType, actionVerb: actionVerb, open: open_1, }; } case Actions.ResourcePicker.Action.SELECT: case Actions.ResourcePicker.Action.CANCEL: case Actions.ResourcePicker.Action.CLOSE: { return tslib.__assign(tslib.__assign({}, state), { open: false }); } default: return state; } } exports.default = resourcePickerReducer; exports.defaultResourcePickerStore = defaultResourcePickerStore;