@open-tender/cloud 0.1.42 → 0.1.44

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.
@@ -4,8 +4,8 @@ export interface TagsState {
4
4
  entities: Tags;
5
5
  error: RequestError;
6
6
  loading: RequestStatus;
7
- selectedTags: Tags | null;
8
- lookup: TagLookupEnhanced | null;
7
+ selectedTags: Tags;
8
+ lookup: TagLookupEnhanced;
9
9
  }
10
10
  export declare enum TagsActionType {
11
11
  FetchTags = "tags/fetchTags"
@@ -24,9 +24,9 @@ export declare const fetchTags: import("@reduxjs/toolkit").AsyncThunk<TagsPayloa
24
24
  fulfilledMeta?: unknown;
25
25
  rejectedMeta?: unknown;
26
26
  }>;
27
- export declare const resetTags: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"tags/resetTags">, setSelectedTags: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/setSelectedTags">;
27
+ export declare const resetTags: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"tags/resetTags">, setSelectedTags: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/setSelectedTags">, toggleTag: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/toggleTag">;
28
28
  export declare const selectTags: (state: AppState) => TagsState;
29
- export declare const selectSelectedTags: (state: AppState) => Tags | null;
29
+ export declare const selectSelectedTags: (state: AppState) => Tags;
30
30
  export declare const selectSelectedTagNames: ((state: import("redux").EmptyObject & {
31
31
  alerts: import("@open-tender/types").Alerts;
32
32
  notifications: import("@open-tender/types").Notifications;
@@ -85,7 +85,7 @@ export declare const selectSelectedTagNames: ((state: import("redux").EmptyObjec
85
85
  tags: TagsState;
86
86
  }) => string[]) & import("reselect").OutputSelectorFields<(args_0: {
87
87
  tags: Tags;
88
- selectedTags: Tags | null;
88
+ selectedTags: Tags;
89
89
  }) => string[], {
90
90
  clearCache: () => void;
91
91
  }> & {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.tagsReducer = exports.selectSelectedTagNames = exports.selectSelectedTags = exports.selectTags = exports.setSelectedTags = exports.resetTags = exports.fetchTags = exports.TagsActionType = void 0;
4
+ exports.tagsReducer = exports.selectSelectedTagNames = exports.selectSelectedTags = exports.selectTags = exports.toggleTag = exports.setSelectedTags = exports.resetTags = exports.fetchTags = exports.TagsActionType = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const toolkit_1 = require("@reduxjs/toolkit");
7
7
  const types_1 = require("./types");
@@ -18,7 +18,7 @@ const initialState = {
18
18
  entities: [],
19
19
  error: null,
20
20
  loading: 'idle',
21
- selectedTags: null,
21
+ selectedTags: [],
22
22
  lookup: {}
23
23
  };
24
24
  var TagsActionType;
@@ -41,17 +41,15 @@ const tagsSlice = (0, toolkit_1.createSlice)({
41
41
  initialState,
42
42
  reducers: {
43
43
  resetTags: () => initialState,
44
+ setSelectedTags: (state, action) => {
45
+ state.selectedTags = action.payload;
46
+ },
44
47
  toggleTag: (state, action) => {
45
- var _a;
46
48
  const tag = action.payload;
47
- const exists = (_a = state.selectedTags) === null || _a === void 0 ? void 0 : _a.find(i => i.tag_id === tag.tag_id);
48
- const current = state.selectedTags || [];
49
+ const exists = state.selectedTags.find(i => i.tag_id === tag.tag_id);
49
50
  state.selectedTags = exists
50
- ? current.filter(i => i.tag_id !== tag.tag_id)
51
- : [...current, tag];
52
- },
53
- setSelectedTags: (state, action) => {
54
- state.selectedTags = action.payload;
51
+ ? state.selectedTags.filter(i => i.tag_id !== tag.tag_id)
52
+ : [...state.selectedTags, tag];
55
53
  }
56
54
  },
57
55
  extraReducers: builder => {
@@ -71,7 +69,7 @@ const tagsSlice = (0, toolkit_1.createSlice)({
71
69
  });
72
70
  }
73
71
  });
74
- _a = tagsSlice.actions, exports.resetTags = _a.resetTags, exports.setSelectedTags = _a.setSelectedTags;
72
+ _a = tagsSlice.actions, exports.resetTags = _a.resetTags, exports.setSelectedTags = _a.setSelectedTags, exports.toggleTag = _a.toggleTag;
75
73
  const selectTags = (state) => state.tags;
76
74
  exports.selectTags = selectTags;
77
75
  const selectSelectedTags = (state) => state.tags.selectedTags;
@@ -4,8 +4,8 @@ export interface TagsState {
4
4
  entities: Tags;
5
5
  error: RequestError;
6
6
  loading: RequestStatus;
7
- selectedTags: Tags | null;
8
- lookup: TagLookupEnhanced | null;
7
+ selectedTags: Tags;
8
+ lookup: TagLookupEnhanced;
9
9
  }
10
10
  export declare enum TagsActionType {
11
11
  FetchTags = "tags/fetchTags"
@@ -24,9 +24,9 @@ export declare const fetchTags: import("@reduxjs/toolkit").AsyncThunk<TagsPayloa
24
24
  fulfilledMeta?: unknown;
25
25
  rejectedMeta?: unknown;
26
26
  }>;
27
- export declare const resetTags: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"tags/resetTags">, setSelectedTags: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/setSelectedTags">;
27
+ export declare const resetTags: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"tags/resetTags">, setSelectedTags: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/setSelectedTags">, toggleTag: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/toggleTag">;
28
28
  export declare const selectTags: (state: AppState) => TagsState;
29
- export declare const selectSelectedTags: (state: AppState) => Tags | null;
29
+ export declare const selectSelectedTags: (state: AppState) => Tags;
30
30
  export declare const selectSelectedTagNames: ((state: import("redux").EmptyObject & {
31
31
  alerts: import("@open-tender/types").Alerts;
32
32
  notifications: import("@open-tender/types").Notifications;
@@ -85,7 +85,7 @@ export declare const selectSelectedTagNames: ((state: import("redux").EmptyObjec
85
85
  tags: TagsState;
86
86
  }) => string[]) & import("reselect").OutputSelectorFields<(args_0: {
87
87
  tags: Tags;
88
- selectedTags: Tags | null;
88
+ selectedTags: Tags;
89
89
  }) => string[], {
90
90
  clearCache: () => void;
91
91
  }> & {
@@ -14,7 +14,7 @@ const initialState = {
14
14
  entities: [],
15
15
  error: null,
16
16
  loading: 'idle',
17
- selectedTags: null,
17
+ selectedTags: [],
18
18
  lookup: {}
19
19
  };
20
20
  export var TagsActionType;
@@ -37,17 +37,15 @@ const tagsSlice = createSlice({
37
37
  initialState,
38
38
  reducers: {
39
39
  resetTags: () => initialState,
40
+ setSelectedTags: (state, action) => {
41
+ state.selectedTags = action.payload;
42
+ },
40
43
  toggleTag: (state, action) => {
41
- var _a;
42
44
  const tag = action.payload;
43
- const exists = (_a = state.selectedTags) === null || _a === void 0 ? void 0 : _a.find(i => i.tag_id === tag.tag_id);
44
- const current = state.selectedTags || [];
45
+ const exists = state.selectedTags.find(i => i.tag_id === tag.tag_id);
45
46
  state.selectedTags = exists
46
- ? current.filter(i => i.tag_id !== tag.tag_id)
47
- : [...current, tag];
48
- },
49
- setSelectedTags: (state, action) => {
50
- state.selectedTags = action.payload;
47
+ ? state.selectedTags.filter(i => i.tag_id !== tag.tag_id)
48
+ : [...state.selectedTags, tag];
51
49
  }
52
50
  },
53
51
  extraReducers: builder => {
@@ -67,7 +65,7 @@ const tagsSlice = createSlice({
67
65
  });
68
66
  }
69
67
  });
70
- export const { resetTags, setSelectedTags } = tagsSlice.actions;
68
+ export const { resetTags, setSelectedTags, toggleTag } = tagsSlice.actions;
71
69
  export const selectTags = (state) => state.tags;
72
70
  export const selectSelectedTags = (state) => state.tags.selectedTags;
73
71
  export const selectSelectedTagNames = createSelector((state) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/cloud",
3
- "version": "0.1.42",
3
+ "version": "0.1.44",
4
4
  "description": "A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our cloud-based Order API.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",