@ws-ui/store 0.1.0
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/README.md +1 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +168 -0
- package/dist/index.js.map +1 -0
- package/dist/index.module.js +167 -0
- package/dist/index.module.js.map +1 -0
- package/package.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @ws-ui/store
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { IEditor } from "@ws-ui/common";
|
|
2
|
+
import { PayloadAction } from "@reduxjs/toolkit";
|
|
3
|
+
export const saveContent: import("@reduxjs/toolkit").AsyncThunk<{
|
|
4
|
+
path: string;
|
|
5
|
+
content: any;
|
|
6
|
+
}, {
|
|
7
|
+
path: string;
|
|
8
|
+
editor: IEditor<any, any>;
|
|
9
|
+
}, {
|
|
10
|
+
state: AppState;
|
|
11
|
+
}>;
|
|
12
|
+
export interface ITab<Raw = string, Parsed = string, Extra = any> {
|
|
13
|
+
path: string;
|
|
14
|
+
name: string;
|
|
15
|
+
editor: string;
|
|
16
|
+
content: {
|
|
17
|
+
raw: Raw;
|
|
18
|
+
parsed: Parsed;
|
|
19
|
+
};
|
|
20
|
+
extra: Extra;
|
|
21
|
+
}
|
|
22
|
+
export type ITabsState = {
|
|
23
|
+
editors: {
|
|
24
|
+
[key: string]: ITab;
|
|
25
|
+
};
|
|
26
|
+
selected: number;
|
|
27
|
+
};
|
|
28
|
+
export const tabsSlice: import("@reduxjs/toolkit").Slice<ITabsState, {
|
|
29
|
+
setContent: (state: import("immer/dist/internal").WritableDraft<ITabsState>, action: PayloadAction<{
|
|
30
|
+
path: string;
|
|
31
|
+
content: any;
|
|
32
|
+
type?: 'raw' | 'parsed';
|
|
33
|
+
}>) => void;
|
|
34
|
+
addTab: (state: import("immer/dist/internal").WritableDraft<ITabsState>, action: PayloadAction<ITab<any, any>>) => void;
|
|
35
|
+
setActiveIndex(state: import("immer/dist/internal").WritableDraft<ITabsState>, action: PayloadAction<number>): void;
|
|
36
|
+
}, "tabs">;
|
|
37
|
+
export const setContent: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
38
|
+
path: string;
|
|
39
|
+
content: any;
|
|
40
|
+
type?: "raw" | "parsed" | undefined;
|
|
41
|
+
}, string>, addTab: import("@reduxjs/toolkit").ActionCreatorWithPayload<ITab<any, any, any>, string>, setActiveIndex: import("@reduxjs/toolkit").ActionCreatorWithPayload<number, string>;
|
|
42
|
+
export const selectTab: (path: string) => ((state: {
|
|
43
|
+
tabs: import("index").ITabsState;
|
|
44
|
+
}) => import("index").ITab<string, string, any>) & import("reselect").OutputSelectorFields<(args_0: import("index").ITabsState) => import("index").ITab<string, string, any> & {
|
|
45
|
+
clearCache: () => void;
|
|
46
|
+
}> & {
|
|
47
|
+
clearCache: () => void;
|
|
48
|
+
};
|
|
49
|
+
export const selectActiveIndex: ((state: {
|
|
50
|
+
tabs: import("index").ITabsState;
|
|
51
|
+
}) => number) & import("reselect").OutputSelectorFields<(args_0: import("index").ITabsState) => number & {
|
|
52
|
+
clearCache: () => void;
|
|
53
|
+
}> & {
|
|
54
|
+
clearCache: () => void;
|
|
55
|
+
};
|
|
56
|
+
export const selectTabsArray: ((state: {
|
|
57
|
+
tabs: import("index").ITabsState;
|
|
58
|
+
}) => import("index").ITab<string, string, any>[]) & import("reselect").OutputSelectorFields<(args_0: import("index").ITabsState) => import("index").ITab<string, string, any>[] & {
|
|
59
|
+
clearCache: () => void;
|
|
60
|
+
}> & {
|
|
61
|
+
clearCache: () => void;
|
|
62
|
+
};
|
|
63
|
+
export const selectTabs: ((state: {
|
|
64
|
+
tabs: import("index").ITabsState;
|
|
65
|
+
}) => {
|
|
66
|
+
[key: string]: import("index").ITab<string, string, any>;
|
|
67
|
+
}) & import("reselect").OutputSelectorFields<(args_0: import("index").ITabsState) => {
|
|
68
|
+
[key: string]: import("index").ITab<string, string, any>;
|
|
69
|
+
} & {
|
|
70
|
+
clearCache: () => void;
|
|
71
|
+
}> & {
|
|
72
|
+
clearCache: () => void;
|
|
73
|
+
};
|
|
74
|
+
interface AppState {
|
|
75
|
+
tabs: ITabsState;
|
|
76
|
+
}
|
|
77
|
+
export const store: import("@reduxjs/toolkit").EnhancedStore<import("redux").CombinedState<{
|
|
78
|
+
tabs: import("index").ITabsState;
|
|
79
|
+
}>, import("redux").AnyAction, [import("redux-thunk").ThunkMiddleware<import("redux").CombinedState<{
|
|
80
|
+
tabs: import("index").ITabsState;
|
|
81
|
+
}>, import("redux").AnyAction, null> | import("redux-thunk").ThunkMiddleware<import("redux").CombinedState<{
|
|
82
|
+
tabs: import("index").ITabsState;
|
|
83
|
+
}>, import("redux").AnyAction, undefined>]>;
|
|
84
|
+
export type AppDispatch = typeof store.dispatch;
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;AAIA,OAAO,MAAM;UAEH,MAAM;aACH,GAAG;;UAGN,MAAM;YACJ,QAAQ,GAAG,EAAE,GAAG,CAAC;;WAGlB,QAAQ;EAOjB,CAAC;AClBH,sBAAsB,GAAG,GAAG,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,GAAG,GAAG;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE;QACP,GAAG,EAAE,GAAG,CAAC;QACT,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,KAAK,EAAE,KAAK,CAAC;CACd;AACD,yBAAyB;IACvB,OAAO,EAAE;QACP,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;KACrB,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAyCF,OAAO,MAAM;yFAMC,cAAc;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,GAAG,CAAC;QACb,IAAI,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;KACzB,CAAC;qFAOoB,cAAc,KAAK,GAAG,EAAE,GAAG,CAAC,CAAC;2FAGvB,cAAc,MAAM,CAAC;UAUrD,CAAC;AAGH,OAAO;UA1BO,MAAM;aACH,GAAG;;yLA0BD,CAAC;ACrFpB,OAAO,MAAM,kBAAmB,MAAM;;;;;;CAInC,CAAC;AAEJ,OAAO,MAAM;;;;;;CAGZ,CAAC;AAEF,OAAO,MAAM;;;;;;CAGZ,CAAC;AAEF,OAAO,MAAM;;;;;;;;;;CAGZ,CAAC;AElBF;IACE,IAAI,EAAE,UAAU,CAAC;CAClB;ACRD,OAAO,MAAM;;;;;;2CAEX,CAAC;AAEH,0BAA0B,OAAO,MAAM,QAAQ,CAAC","sources":["packages/core/store/src/packages/core/store/src/reducers/tabs/thunks.ts","packages/core/store/src/packages/core/store/src/reducers/tabs/reducer.ts","packages/core/store/src/packages/core/store/src/reducers/tabs/selector.ts","packages/core/store/src/packages/core/store/src/reducers/tabs/index.ts","packages/core/store/src/packages/core/store/src/reducers/index.ts","packages/core/store/src/packages/core/store/src/configureStore.ts","packages/core/store/src/packages/core/store/src/index.ts","packages/core/store/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,"export * from './configureStore';\nexport * from './reducers/tabs';\n\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
var $74iSd$reduxjstoolkit = require("@reduxjs/toolkit");
|
|
2
|
+
|
|
3
|
+
function $parcel$exportWildcard(dest, source) {
|
|
4
|
+
Object.keys(source).forEach(function(key) {
|
|
5
|
+
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(dest, key, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function get() {
|
|
12
|
+
return source[key];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return dest;
|
|
18
|
+
}
|
|
19
|
+
function $parcel$export(e, n, v, s) {
|
|
20
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
21
|
+
}
|
|
22
|
+
function $parcel$defineInteropFlag(a) {
|
|
23
|
+
Object.defineProperty(a, '__esModule', {value: true, configurable: true});
|
|
24
|
+
}
|
|
25
|
+
var $762d6bf1dc5d9eb3$exports = {};
|
|
26
|
+
|
|
27
|
+
$parcel$export($762d6bf1dc5d9eb3$exports, "store", () => $762d6bf1dc5d9eb3$export$6f57813fe9f31bf9);
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var $eb4150e4f4196a9f$exports = {};
|
|
31
|
+
|
|
32
|
+
$parcel$defineInteropFlag($eb4150e4f4196a9f$exports);
|
|
33
|
+
|
|
34
|
+
$parcel$export($eb4150e4f4196a9f$exports, "default", () => $eb4150e4f4196a9f$export$2e2bcd8739ae039);
|
|
35
|
+
var $6a84af33bc911c55$exports = {};
|
|
36
|
+
|
|
37
|
+
$parcel$defineInteropFlag($6a84af33bc911c55$exports);
|
|
38
|
+
|
|
39
|
+
$parcel$export($6a84af33bc911c55$exports, "tabsSlice", () => $6a84af33bc911c55$export$e778b58c904d1aed);
|
|
40
|
+
$parcel$export($6a84af33bc911c55$exports, "default", () => $6a84af33bc911c55$export$2e2bcd8739ae039);
|
|
41
|
+
$parcel$export($6a84af33bc911c55$exports, "setContent", () => $6a84af33bc911c55$export$431313f2afd011e2);
|
|
42
|
+
$parcel$export($6a84af33bc911c55$exports, "addTab", () => $6a84af33bc911c55$export$e12b5b94ee768f0b);
|
|
43
|
+
$parcel$export($6a84af33bc911c55$exports, "setActiveIndex", () => $6a84af33bc911c55$export$c7da68a4a8c33a39);
|
|
44
|
+
|
|
45
|
+
var $053193bf6f06c9c5$exports = {};
|
|
46
|
+
|
|
47
|
+
$parcel$export($053193bf6f06c9c5$exports, "saveContent", () => $053193bf6f06c9c5$export$5fb9a4eb43b36fa1);
|
|
48
|
+
|
|
49
|
+
const $053193bf6f06c9c5$export$5fb9a4eb43b36fa1 = $74iSd$reduxjstoolkit.createAsyncThunk('tabs/saveContent', async ({ path: path , editor: editor }, { getState: getState })=>{
|
|
50
|
+
const tab = getState().tabs.editors[path];
|
|
51
|
+
const parsed = await editor.serialize(tab.content.parsed);
|
|
52
|
+
return {
|
|
53
|
+
path: path,
|
|
54
|
+
content: parsed
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
const $6a84af33bc911c55$var$initialState = {
|
|
60
|
+
editors: {
|
|
61
|
+
'editor/radio1': {
|
|
62
|
+
name: 'radio1',
|
|
63
|
+
path: 'editor/radio1',
|
|
64
|
+
editor: 'RadioEditor',
|
|
65
|
+
content: {
|
|
66
|
+
raw: 'value1',
|
|
67
|
+
parsed: {
|
|
68
|
+
checked: 'value1'
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
'editor/radio2': {
|
|
73
|
+
name: 'radio2',
|
|
74
|
+
path: 'editor/radio2',
|
|
75
|
+
editor: 'RadioEditor',
|
|
76
|
+
content: {
|
|
77
|
+
raw: 'value2',
|
|
78
|
+
parsed: {
|
|
79
|
+
checked: 'value1'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
'editor/text1': {
|
|
84
|
+
name: 'radio1',
|
|
85
|
+
path: 'editor/text1',
|
|
86
|
+
editor: 'TextEditor',
|
|
87
|
+
content: {
|
|
88
|
+
raw: '1',
|
|
89
|
+
parsed: {
|
|
90
|
+
text: 'value1'
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
selected: 0
|
|
96
|
+
};
|
|
97
|
+
const $6a84af33bc911c55$export$e778b58c904d1aed = $74iSd$reduxjstoolkit.createSlice({
|
|
98
|
+
name: 'tabs',
|
|
99
|
+
initialState: $6a84af33bc911c55$var$initialState,
|
|
100
|
+
reducers: {
|
|
101
|
+
setContent: (state, action)=>{
|
|
102
|
+
const found = state.editors[action.payload.path];
|
|
103
|
+
if (!found) return;
|
|
104
|
+
found.content[action.payload.type || 'parsed'] = action.payload.content;
|
|
105
|
+
},
|
|
106
|
+
addTab: (state, action)=>{
|
|
107
|
+
state.editors[action.payload.path] = action.payload;
|
|
108
|
+
},
|
|
109
|
+
setActiveIndex (state, action) {
|
|
110
|
+
state.selected = action.payload;
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
extraReducers: (builder)=>{
|
|
114
|
+
builder.addCase($053193bf6f06c9c5$export$5fb9a4eb43b36fa1.fulfilled, (state, action)=>{
|
|
115
|
+
state.editors[action.payload.path].content.raw = action.payload.content;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
var $6a84af33bc911c55$export$2e2bcd8739ae039 = $6a84af33bc911c55$export$e778b58c904d1aed;
|
|
120
|
+
const { setContent: $6a84af33bc911c55$export$431313f2afd011e2 , addTab: $6a84af33bc911c55$export$e12b5b94ee768f0b , setActiveIndex: $6a84af33bc911c55$export$c7da68a4a8c33a39 } = $6a84af33bc911c55$export$e778b58c904d1aed.actions;
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
var $1a1c9cbe6666ff0c$exports = {};
|
|
125
|
+
|
|
126
|
+
$parcel$export($1a1c9cbe6666ff0c$exports, "selectTab", () => $1a1c9cbe6666ff0c$export$67a66ee6a2b09b52);
|
|
127
|
+
$parcel$export($1a1c9cbe6666ff0c$exports, "selectActiveIndex", () => $1a1c9cbe6666ff0c$export$95fb15d7bb7a8a94);
|
|
128
|
+
$parcel$export($1a1c9cbe6666ff0c$exports, "selectTabsArray", () => $1a1c9cbe6666ff0c$export$7119fc11e7bfee52);
|
|
129
|
+
$parcel$export($1a1c9cbe6666ff0c$exports, "selectTabs", () => $1a1c9cbe6666ff0c$export$1257191dd6a3cacf);
|
|
130
|
+
|
|
131
|
+
const $1a1c9cbe6666ff0c$var$selectTabsState = $74iSd$reduxjstoolkit.createSelector((state)=>state
|
|
132
|
+
, (state)=>state.tabs
|
|
133
|
+
);
|
|
134
|
+
const $1a1c9cbe6666ff0c$export$67a66ee6a2b09b52 = (path)=>$74iSd$reduxjstoolkit.createSelector($1a1c9cbe6666ff0c$var$selectTabsState, (state)=>state.editors[path]
|
|
135
|
+
)
|
|
136
|
+
;
|
|
137
|
+
const $1a1c9cbe6666ff0c$export$95fb15d7bb7a8a94 = $74iSd$reduxjstoolkit.createSelector($1a1c9cbe6666ff0c$var$selectTabsState, (state)=>state.selected
|
|
138
|
+
);
|
|
139
|
+
const $1a1c9cbe6666ff0c$export$7119fc11e7bfee52 = $74iSd$reduxjstoolkit.createSelector($1a1c9cbe6666ff0c$var$selectTabsState, (state)=>Object.values(state.editors)
|
|
140
|
+
);
|
|
141
|
+
const $1a1c9cbe6666ff0c$export$1257191dd6a3cacf = $74iSd$reduxjstoolkit.createSelector($1a1c9cbe6666ff0c$var$selectTabsState, (state)=>state.editors
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
var $eb4150e4f4196a9f$export$2e2bcd8739ae039 = $6a84af33bc911c55$export$2e2bcd8739ae039.reducer;
|
|
147
|
+
$parcel$exportWildcard($eb4150e4f4196a9f$exports, $6a84af33bc911c55$exports);
|
|
148
|
+
$parcel$exportWildcard($eb4150e4f4196a9f$exports, $1a1c9cbe6666ff0c$exports);
|
|
149
|
+
$parcel$exportWildcard($eb4150e4f4196a9f$exports, $053193bf6f06c9c5$exports);
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
const $1b5bcdccfb8e38e8$var$stateReducer = $74iSd$reduxjstoolkit.combineReducers({
|
|
153
|
+
tabs: $6a84af33bc911c55$export$e778b58c904d1aed.reducer
|
|
154
|
+
});
|
|
155
|
+
var $1b5bcdccfb8e38e8$export$2e2bcd8739ae039 = $1b5bcdccfb8e38e8$var$stateReducer;
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
const $762d6bf1dc5d9eb3$export$6f57813fe9f31bf9 = $74iSd$reduxjstoolkit.configureStore({
|
|
159
|
+
reducer: $1b5bcdccfb8e38e8$export$2e2bcd8739ae039
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
$parcel$exportWildcard(module.exports, $762d6bf1dc5d9eb3$exports);
|
|
165
|
+
$parcel$exportWildcard(module.exports, $eb4150e4f4196a9f$exports);
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AKIO,KAAK,CAAC,yCAAW,GAAG,sCAAgB,CAYzC,CAAkB,0BAAS,CAAC,OAAC,IAAI,WAAE,MAAM,EAAC,CAAC,EAAE,CAAC,WAAC,QAAQ,EAAC,CAAC,GAAK,CAAC;IAC/D,KAAK,CAAC,GAAG,GAAG,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI;IAExC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM;IACxD,MAAM,CAAC,CAAC;cAAC,IAAI;QAAE,OAAO,EAAE,MAAM;IAAC,CAAC;AAClC,CAAC;;;ADDD,KAAK,CAAC,kCAAY,GAAe,CAAC;IAChC,OAAO,EAAE,CAAC;QACR,CAAe,gBAAE,CAAC;YAChB,IAAI,EAAE,CAAQ;YACd,IAAI,EAAE,CAAe;YACrB,MAAM,EAAE,CAAa;YACrB,OAAO,EAAE,CAAC;gBACR,GAAG,EAAE,CAAQ;gBACb,MAAM,EAAE,CAAC;oBACP,OAAO,EAAE,CAAQ;gBACnB,CAAC;YACH,C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,CAAC,OAAO,CAAC,yCAAW,CAAC,SAAS,GAAG,KAAK,EAAE,MAAM,GAAK,CAAC;YACzD,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,GAC5C,MAAM,CAAC,OAAO,CAAC,OAAO;QAC1B,CAAC;IACH,CAAC;AACH,CAAC;IAED,wCAAyB,GAAV,yCAAS;AACjB,KAAK,CAAC,CAAC,aAAC,yCAAU,WAAE,yCAAM,mBAAE,yCAAc,EAAC,CAAC,GACjD,yCAAS,CAAC,OAAO;;;;;;;;;;;AE1FnB,KAAK,CAAC,qCAAe,GAAG,oCAAc,EACnC,KAAe,GAAK,KAAK;GACzB,KAAe,GAAK,KAAK,CAAC,IAAI;;AAG1B,KAAK,CAAC,yCAAS,IAAI,IAAY,GACpC,oCAAc,CACZ,qCAAe,GACd,KAAK,GAAK,KAAK,CAAC,OAAO,CAAC,IAAI;;;AAG1B,KAAK,CAAC,yCAAiB,GAAG,oCAAc,CAC7C,qCAAe,GACd,KAAK,GAAK,KAAK,CAAC,QAAQ;;AAGpB,KAAK,CAAC,yCAAe,GAAG,oCAAc,CAC3C,qCAAe,GACd,KAAK,GAAK,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO;;AAGjC,KAAK,CAAC,yCAAU,GAAG,oCAAc,CACtC,qCAAe,GACd,KAAK,GAAK,KAAK,CAAC,OAAO;;;;;IHxB1B,wCAA6B,GAAd,wCAAK,CAAC,OAAO;;;;;;ADC5B,KAAK,CAAC,kCAAY,GAAG,qCAAe,CAAC,CAAC;IACpC,IAAI,EAAE,yCAAS,CAAC,OAAO;AACzB,CAAC;IAED,wCAA4B,GAAb,kCAAY;;;ADJpB,KAAK,CAAC,yCAAK,GAAG,oCAAc,CAAC,CAAC;IACnC,OAAO,EAAE,wCAAY;AACvB,CAAC","sources":["packages/core/store/src/index.ts","packages/core/store/src/configureStore.ts","packages/core/store/src/reducers/index.ts","packages/core/store/src/reducers/tabs/index.ts","packages/core/store/src/reducers/tabs/reducer.ts","packages/core/store/src/reducers/tabs/thunks.ts","packages/core/store/src/reducers/tabs/selector.ts"],"sourcesContent":["export * from './configureStore';\nexport * from './reducers/tabs';\n\n","import { configureStore } from '@reduxjs/toolkit';\nimport stateReducer from './reducers';\n\nexport const store = configureStore({\n reducer: stateReducer,\n});\n\nexport type AppDispatch = typeof store.dispatch;\n","import { combineReducers } from '@reduxjs/toolkit';\nimport { tabsSlice, ITabsState } from './tabs';\n\nconst stateReducer = combineReducers({\n tabs: tabsSlice.reducer,\n});\n\nexport default stateReducer;\n\nexport interface AppState {\n tabs: ITabsState;\n};\n","import slice from './reducer';\n\nexport default slice.reducer;\nexport * from './reducer';\nexport * from './selector';\nexport * from './thunks';\n","import { createSlice, PayloadAction } from '@reduxjs/toolkit';\nimport { saveContent } from './thunks';\n\nexport interface ITab<Raw = string, Parsed = string, Extra = any> {\n path: string;\n name: string;\n editor: string;\n content: {\n raw: Raw;\n parsed: Parsed;\n };\n extra: Extra;\n}\nexport type ITabsState = {\n editors: {\n [key: string]: ITab;\n };\n selected: number;\n};\n\nconst initialState: ITabsState = {\n editors: {\n 'editor/radio1': {\n name: 'radio1',\n path: 'editor/radio1',\n editor: 'RadioEditor',\n content: {\n raw: 'value1',\n parsed: {\n checked: 'value1',\n },\n },\n } as ITab<any, any>,\n 'editor/radio2': {\n name: 'radio2',\n path: 'editor/radio2',\n editor: 'RadioEditor',\n content: {\n raw: 'value2',\n parsed: {\n checked: 'value1',\n },\n },\n } as ITab<any, any>,\n 'editor/text1': {\n name: 'radio1',\n path: 'editor/text1',\n editor: 'TextEditor',\n content: {\n raw: '1',\n parsed: {\n text: 'value1',\n },\n },\n } as ITab<any, any>,\n },\n selected: 0,\n};\n\nexport const tabsSlice = createSlice({\n name: 'tabs',\n initialState,\n reducers: {\n setContent: (\n state,\n action: PayloadAction<{\n path: string;\n content: any;\n type?: 'raw' | 'parsed';\n }>,\n ) => {\n const found = state.editors[action.payload.path];\n if (!found) return;\n found.content[action.payload.type || 'parsed'] =\n action.payload.content;\n },\n addTab: (state, action: PayloadAction<ITab<any, any>>) => {\n state.editors[action.payload.path] = action.payload;\n },\n setActiveIndex(state, action: PayloadAction<number>) {\n state.selected = action.payload;\n },\n },\n extraReducers: (builder) => {\n builder.addCase(saveContent.fulfilled, (state, action) => {\n state.editors[action.payload.path].content.raw =\n action.payload.content;\n });\n },\n});\n\nexport default tabsSlice;\nexport const { setContent, addTab, setActiveIndex } =\n tabsSlice.actions;\n","import { createAsyncThunk } from '@reduxjs/toolkit';\nimport { IEditor } from '@ws-ui/common';\nimport { AppState } from '..';\n\nexport const saveContent = createAsyncThunk<\n {\n path: string;\n content: any;\n },\n {\n path: string;\n editor: IEditor<any, any>;\n },\n {\n state: AppState;\n }\n>('tabs/saveContent', async ({ path, editor }, { getState }) => {\n const tab = getState().tabs.editors[path];\n\n const parsed = await editor.serialize(tab.content.parsed);\n return { path, content: parsed };\n});\n","import { createSelector } from '@reduxjs/toolkit';\nimport { AppState } from '..';\n\nconst selectTabsState = createSelector(\n (state: AppState) => state,\n (state: AppState) => state.tabs,\n);\n\nexport const selectTab = (path: string) =>\n createSelector(\n selectTabsState,\n (state) => state.editors[path],\n );\n\nexport const selectActiveIndex = createSelector(\n selectTabsState,\n (state) => state.selected,\n);\n\nexport const selectTabsArray = createSelector(\n selectTabsState,\n (state) => Object.values(state.editors),\n);\n\nexport const selectTabs = createSelector(\n selectTabsState,\n (state) => state.editors,\n);\n"],"names":[],"version":3,"file":"index.js.map"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import {configureStore as $5vCxb$configureStore, combineReducers as $5vCxb$combineReducers, createSlice as $5vCxb$createSlice, createAsyncThunk as $5vCxb$createAsyncThunk, createSelector as $5vCxb$createSelector} from "@reduxjs/toolkit";
|
|
2
|
+
|
|
3
|
+
function $parcel$export(e, n, v, s) {
|
|
4
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
5
|
+
}
|
|
6
|
+
function $parcel$defineInteropFlag(a) {
|
|
7
|
+
Object.defineProperty(a, '__esModule', {value: true, configurable: true});
|
|
8
|
+
}
|
|
9
|
+
function $parcel$exportWildcard(dest, source) {
|
|
10
|
+
Object.keys(source).forEach(function(key) {
|
|
11
|
+
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
Object.defineProperty(dest, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function get() {
|
|
18
|
+
return source[key];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return dest;
|
|
24
|
+
}
|
|
25
|
+
var $607db421e4df5242$exports = {};
|
|
26
|
+
|
|
27
|
+
$parcel$export($607db421e4df5242$exports, "store", () => $607db421e4df5242$export$6f57813fe9f31bf9);
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var $43ff650760856779$exports = {};
|
|
31
|
+
|
|
32
|
+
$parcel$defineInteropFlag($43ff650760856779$exports);
|
|
33
|
+
|
|
34
|
+
$parcel$export($43ff650760856779$exports, "default", () => $43ff650760856779$export$2e2bcd8739ae039);
|
|
35
|
+
var $6e0c0412de6dd794$exports = {};
|
|
36
|
+
|
|
37
|
+
$parcel$defineInteropFlag($6e0c0412de6dd794$exports);
|
|
38
|
+
|
|
39
|
+
$parcel$export($6e0c0412de6dd794$exports, "tabsSlice", () => $6e0c0412de6dd794$export$e778b58c904d1aed);
|
|
40
|
+
$parcel$export($6e0c0412de6dd794$exports, "default", () => $6e0c0412de6dd794$export$2e2bcd8739ae039);
|
|
41
|
+
$parcel$export($6e0c0412de6dd794$exports, "setContent", () => $6e0c0412de6dd794$export$431313f2afd011e2);
|
|
42
|
+
$parcel$export($6e0c0412de6dd794$exports, "addTab", () => $6e0c0412de6dd794$export$e12b5b94ee768f0b);
|
|
43
|
+
$parcel$export($6e0c0412de6dd794$exports, "setActiveIndex", () => $6e0c0412de6dd794$export$c7da68a4a8c33a39);
|
|
44
|
+
|
|
45
|
+
var $d7c749f6643d2657$exports = {};
|
|
46
|
+
|
|
47
|
+
$parcel$export($d7c749f6643d2657$exports, "saveContent", () => $d7c749f6643d2657$export$5fb9a4eb43b36fa1);
|
|
48
|
+
|
|
49
|
+
const $d7c749f6643d2657$export$5fb9a4eb43b36fa1 = $5vCxb$createAsyncThunk('tabs/saveContent', async ({ path: path , editor: editor }, { getState: getState })=>{
|
|
50
|
+
const tab = getState().tabs.editors[path];
|
|
51
|
+
const parsed = await editor.serialize(tab.content.parsed);
|
|
52
|
+
return {
|
|
53
|
+
path: path,
|
|
54
|
+
content: parsed
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
const $6e0c0412de6dd794$var$initialState = {
|
|
60
|
+
editors: {
|
|
61
|
+
'editor/radio1': {
|
|
62
|
+
name: 'radio1',
|
|
63
|
+
path: 'editor/radio1',
|
|
64
|
+
editor: 'RadioEditor',
|
|
65
|
+
content: {
|
|
66
|
+
raw: 'value1',
|
|
67
|
+
parsed: {
|
|
68
|
+
checked: 'value1'
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
'editor/radio2': {
|
|
73
|
+
name: 'radio2',
|
|
74
|
+
path: 'editor/radio2',
|
|
75
|
+
editor: 'RadioEditor',
|
|
76
|
+
content: {
|
|
77
|
+
raw: 'value2',
|
|
78
|
+
parsed: {
|
|
79
|
+
checked: 'value1'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
'editor/text1': {
|
|
84
|
+
name: 'radio1',
|
|
85
|
+
path: 'editor/text1',
|
|
86
|
+
editor: 'TextEditor',
|
|
87
|
+
content: {
|
|
88
|
+
raw: '1',
|
|
89
|
+
parsed: {
|
|
90
|
+
text: 'value1'
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
selected: 0
|
|
96
|
+
};
|
|
97
|
+
const $6e0c0412de6dd794$export$e778b58c904d1aed = $5vCxb$createSlice({
|
|
98
|
+
name: 'tabs',
|
|
99
|
+
initialState: $6e0c0412de6dd794$var$initialState,
|
|
100
|
+
reducers: {
|
|
101
|
+
setContent: (state, action)=>{
|
|
102
|
+
const found = state.editors[action.payload.path];
|
|
103
|
+
if (!found) return;
|
|
104
|
+
found.content[action.payload.type || 'parsed'] = action.payload.content;
|
|
105
|
+
},
|
|
106
|
+
addTab: (state, action)=>{
|
|
107
|
+
state.editors[action.payload.path] = action.payload;
|
|
108
|
+
},
|
|
109
|
+
setActiveIndex (state, action) {
|
|
110
|
+
state.selected = action.payload;
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
extraReducers: (builder)=>{
|
|
114
|
+
builder.addCase($d7c749f6643d2657$export$5fb9a4eb43b36fa1.fulfilled, (state, action)=>{
|
|
115
|
+
state.editors[action.payload.path].content.raw = action.payload.content;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
var $6e0c0412de6dd794$export$2e2bcd8739ae039 = $6e0c0412de6dd794$export$e778b58c904d1aed;
|
|
120
|
+
const { setContent: $6e0c0412de6dd794$export$431313f2afd011e2 , addTab: $6e0c0412de6dd794$export$e12b5b94ee768f0b , setActiveIndex: $6e0c0412de6dd794$export$c7da68a4a8c33a39 } = $6e0c0412de6dd794$export$e778b58c904d1aed.actions;
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
var $753f9120f3cbae79$exports = {};
|
|
125
|
+
|
|
126
|
+
$parcel$export($753f9120f3cbae79$exports, "selectTab", () => $753f9120f3cbae79$export$67a66ee6a2b09b52);
|
|
127
|
+
$parcel$export($753f9120f3cbae79$exports, "selectActiveIndex", () => $753f9120f3cbae79$export$95fb15d7bb7a8a94);
|
|
128
|
+
$parcel$export($753f9120f3cbae79$exports, "selectTabsArray", () => $753f9120f3cbae79$export$7119fc11e7bfee52);
|
|
129
|
+
$parcel$export($753f9120f3cbae79$exports, "selectTabs", () => $753f9120f3cbae79$export$1257191dd6a3cacf);
|
|
130
|
+
|
|
131
|
+
const $753f9120f3cbae79$var$selectTabsState = $5vCxb$createSelector((state)=>state
|
|
132
|
+
, (state)=>state.tabs
|
|
133
|
+
);
|
|
134
|
+
const $753f9120f3cbae79$export$67a66ee6a2b09b52 = (path)=>$5vCxb$createSelector($753f9120f3cbae79$var$selectTabsState, (state)=>state.editors[path]
|
|
135
|
+
)
|
|
136
|
+
;
|
|
137
|
+
const $753f9120f3cbae79$export$95fb15d7bb7a8a94 = $5vCxb$createSelector($753f9120f3cbae79$var$selectTabsState, (state)=>state.selected
|
|
138
|
+
);
|
|
139
|
+
const $753f9120f3cbae79$export$7119fc11e7bfee52 = $5vCxb$createSelector($753f9120f3cbae79$var$selectTabsState, (state)=>Object.values(state.editors)
|
|
140
|
+
);
|
|
141
|
+
const $753f9120f3cbae79$export$1257191dd6a3cacf = $5vCxb$createSelector($753f9120f3cbae79$var$selectTabsState, (state)=>state.editors
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
var $43ff650760856779$export$2e2bcd8739ae039 = $6e0c0412de6dd794$export$2e2bcd8739ae039.reducer;
|
|
147
|
+
$parcel$exportWildcard($43ff650760856779$exports, $6e0c0412de6dd794$exports);
|
|
148
|
+
$parcel$exportWildcard($43ff650760856779$exports, $753f9120f3cbae79$exports);
|
|
149
|
+
$parcel$exportWildcard($43ff650760856779$exports, $d7c749f6643d2657$exports);
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
const $fcde70f2d5431e07$var$stateReducer = $5vCxb$combineReducers({
|
|
153
|
+
tabs: $6e0c0412de6dd794$export$e778b58c904d1aed.reducer
|
|
154
|
+
});
|
|
155
|
+
var $fcde70f2d5431e07$export$2e2bcd8739ae039 = $fcde70f2d5431e07$var$stateReducer;
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
const $607db421e4df5242$export$6f57813fe9f31bf9 = $5vCxb$configureStore({
|
|
159
|
+
reducer: $fcde70f2d5431e07$export$2e2bcd8739ae039
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
export {$607db421e4df5242$export$6f57813fe9f31bf9 as store, $6e0c0412de6dd794$export$e778b58c904d1aed as tabsSlice, $6e0c0412de6dd794$export$431313f2afd011e2 as setContent, $6e0c0412de6dd794$export$e12b5b94ee768f0b as addTab, $6e0c0412de6dd794$export$c7da68a4a8c33a39 as setActiveIndex, $753f9120f3cbae79$export$67a66ee6a2b09b52 as selectTab, $753f9120f3cbae79$export$95fb15d7bb7a8a94 as selectActiveIndex, $753f9120f3cbae79$export$7119fc11e7bfee52 as selectTabsArray, $753f9120f3cbae79$export$1257191dd6a3cacf as selectTabs, $d7c749f6643d2657$export$5fb9a4eb43b36fa1 as saveContent};
|
|
167
|
+
//# sourceMappingURL=index.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AKIO,KAAK,CAAC,yCAAW,GAAG,uBAAgB,CAYzC,CAAkB,0BAAS,CAAC,OAAC,IAAI,WAAE,MAAM,EAAC,CAAC,EAAE,CAAC,WAAC,QAAQ,EAAC,CAAC,GAAK,CAAC;IAC/D,KAAK,CAAC,GAAG,GAAG,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI;IAExC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM;IACxD,MAAM,CAAC,CAAC;cAAC,IAAI;QAAE,OAAO,EAAE,MAAM;IAAC,CAAC;AAClC,CAAC;;;ADDD,KAAK,CAAC,kCAAY,GAAe,CAAC;IAChC,OAAO,EAAE,CAAC;QACR,CAAe,gBAAE,CAAC;YAChB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4B,GAAb,kCAAY;;;ADJpB,KAAK,CAAC,yCAAK,GAAG,qBAAc,CAAC,CAAC;IACnC,OAAO,EAAE,wCAAY;AACvB,CAAC","sources":["packages/core/store/src/index.ts","packages/core/store/src/configureStore.ts","packages/core/store/src/reducers/index.ts","packages/core/store/src/reducers/tabs/index.ts","packages/core/store/src/reducers/tabs/reducer.ts","packages/core/store/src/reducers/tabs/thunks.ts","packages/core/store/src/reducers/tabs/selector.ts"],"sourcesContent":["export * from './configureStore';\nexport * from './reducers/tabs';\n\n","import { configureStore } from '@reduxjs/toolkit';\nimport stateReducer from './reducers';\n\nexport const store = configureStore({\n reducer: stateReducer,\n});\n\nexport type AppDispatch = typeof store.dispatch;\n","import { combineReducers } from '@reduxjs/toolkit';\nimport { tabsSlice, ITabsState } from './tabs';\n\nconst stateReducer = combineReducers({\n tabs: tabsSlice.reducer,\n});\n\nexport default stateReducer;\n\nexport interface AppState {\n tabs: ITabsState;\n};\n","import slice from './reducer';\n\nexport default slice.reducer;\nexport * from './reducer';\nexport * from './selector';\nexport * from './thunks';\n","import { createSlice, PayloadAction } from '@reduxjs/toolkit';\nimport { saveContent } from './thunks';\n\nexport interface ITab<Raw = string, Parsed = string, Extra = any> {\n path: string;\n name: string;\n editor: string;\n content: {\n raw: Raw;\n parsed: Parsed;\n };\n extra: Extra;\n}\nexport type ITabsState = {\n editors: {\n [key: string]: ITab;\n };\n selected: number;\n};\n\nconst initialState: ITabsState = {\n editors: {\n 'editor/radio1': {\n name: 'radio1',\n path: 'editor/radio1',\n editor: 'RadioEditor',\n content: {\n raw: 'value1',\n parsed: {\n checked: 'value1',\n },\n },\n } as ITab<any, any>,\n 'editor/radio2': {\n name: 'radio2',\n path: 'editor/radio2',\n editor: 'RadioEditor',\n content: {\n raw: 'value2',\n parsed: {\n checked: 'value1',\n },\n },\n } as ITab<any, any>,\n 'editor/text1': {\n name: 'radio1',\n path: 'editor/text1',\n editor: 'TextEditor',\n content: {\n raw: '1',\n parsed: {\n text: 'value1',\n },\n },\n } as ITab<any, any>,\n },\n selected: 0,\n};\n\nexport const tabsSlice = createSlice({\n name: 'tabs',\n initialState,\n reducers: {\n setContent: (\n state,\n action: PayloadAction<{\n path: string;\n content: any;\n type?: 'raw' | 'parsed';\n }>,\n ) => {\n const found = state.editors[action.payload.path];\n if (!found) return;\n found.content[action.payload.type || 'parsed'] =\n action.payload.content;\n },\n addTab: (state, action: PayloadAction<ITab<any, any>>) => {\n state.editors[action.payload.path] = action.payload;\n },\n setActiveIndex(state, action: PayloadAction<number>) {\n state.selected = action.payload;\n },\n },\n extraReducers: (builder) => {\n builder.addCase(saveContent.fulfilled, (state, action) => {\n state.editors[action.payload.path].content.raw =\n action.payload.content;\n });\n },\n});\n\nexport default tabsSlice;\nexport const { setContent, addTab, setActiveIndex } =\n tabsSlice.actions;\n","import { createAsyncThunk } from '@reduxjs/toolkit';\nimport { IEditor } from '@ws-ui/common';\nimport { AppState } from '..';\n\nexport const saveContent = createAsyncThunk<\n {\n path: string;\n content: any;\n },\n {\n path: string;\n editor: IEditor<any, any>;\n },\n {\n state: AppState;\n }\n>('tabs/saveContent', async ({ path, editor }, { getState }) => {\n const tab = getState().tabs.editors[path];\n\n const parsed = await editor.serialize(tab.content.parsed);\n return { path, content: parsed };\n});\n","import { createSelector } from '@reduxjs/toolkit';\nimport { AppState } from '..';\n\nconst selectTabsState = createSelector(\n (state: AppState) => state,\n (state: AppState) => state.tabs,\n);\n\nexport const selectTab = (path: string) =>\n createSelector(\n selectTabsState,\n (state) => state.editors[path],\n );\n\nexport const selectActiveIndex = createSelector(\n selectTabsState,\n (state) => state.selected,\n);\n\nexport const selectTabsArray = createSelector(\n selectTabsState,\n (state) => Object.values(state.editors),\n);\n\nexport const selectTabs = createSelector(\n selectTabsState,\n (state) => state.editors,\n);\n"],"names":[],"version":3,"file":"index.module.js.map"}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ws-ui/store",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"source": "src/index.ts",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.module.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"scripts": {
|
|
15
|
+
"clean": "rm -rf dist",
|
|
16
|
+
"version": "yarn version"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://developer.4d.com/4d-web-studio/",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://git-ps.wakanda.io/4d/web-studio/webstudio.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://git-ps.wakanda.io/4d/web-studio/webstudio/-/issues"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@reduxjs/toolkit": "^1.7.1",
|
|
28
|
+
"react-redux": "^7.2.6"
|
|
29
|
+
}
|
|
30
|
+
}
|