@bryntum/taskboard-vue-3-thin 7.1.1
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 +53 -0
- package/lib/chunks/-hGMKDT-.js +279 -0
- package/lib/chunks/-hGMKDT-.js.map +1 -0
- package/lib/chunks/2MugSr70.js +382 -0
- package/lib/chunks/2MugSr70.js.map +1 -0
- package/lib/chunks/2RRMFKHJ.js +306 -0
- package/lib/chunks/2RRMFKHJ.js.map +1 -0
- package/lib/chunks/B13cxldI.js +279 -0
- package/lib/chunks/B13cxldI.js.map +1 -0
- package/lib/chunks/B32q-UcS.js +277 -0
- package/lib/chunks/B32q-UcS.js.map +1 -0
- package/lib/chunks/BP22d7g9.js +279 -0
- package/lib/chunks/BP22d7g9.js.map +1 -0
- package/lib/chunks/BS3VqRMT.js +382 -0
- package/lib/chunks/BS3VqRMT.js.map +1 -0
- package/lib/chunks/BUqJrgcM.js +279 -0
- package/lib/chunks/BUqJrgcM.js.map +1 -0
- package/lib/chunks/BZslhDhE.js +320 -0
- package/lib/chunks/BZslhDhE.js.map +1 -0
- package/lib/chunks/BkWE4YMJ.js +295 -0
- package/lib/chunks/BkWE4YMJ.js.map +1 -0
- package/lib/chunks/C8Ls3rwH.js +267 -0
- package/lib/chunks/C8Ls3rwH.js.map +1 -0
- package/lib/chunks/CIGedStG.js +320 -0
- package/lib/chunks/CIGedStG.js.map +1 -0
- package/lib/chunks/CPFlJHkf.js +313 -0
- package/lib/chunks/CPFlJHkf.js.map +1 -0
- package/lib/chunks/CQPtNMld.js +549 -0
- package/lib/chunks/CQPtNMld.js.map +1 -0
- package/lib/chunks/CaXNovsW.js +237 -0
- package/lib/chunks/CaXNovsW.js.map +1 -0
- package/lib/chunks/ComLVoEW.js +384 -0
- package/lib/chunks/ComLVoEW.js.map +1 -0
- package/lib/chunks/DO9RkP9d.js +547 -0
- package/lib/chunks/DO9RkP9d.js.map +1 -0
- package/lib/chunks/DT9dLbVS.js +382 -0
- package/lib/chunks/DT9dLbVS.js.map +1 -0
- package/lib/chunks/imR2_gHl.js +316 -0
- package/lib/chunks/imR2_gHl.js.map +1 -0
- package/lib/chunks/ujL-F7eG.js +307 -0
- package/lib/chunks/ujL-F7eG.js.map +1 -0
- package/lib/chunks/wXZJ9FAX.js +384 -0
- package/lib/chunks/wXZJ9FAX.js.map +1 -0
- package/lib/components/BryntumColumnCombo.js +5 -0
- package/lib/components/BryntumColumnCombo.js.map +1 -0
- package/lib/components/BryntumColumnFilterField.js +5 -0
- package/lib/components/BryntumColumnFilterField.js.map +1 -0
- package/lib/components/BryntumColumnPickerButton.js +5 -0
- package/lib/components/BryntumColumnPickerButton.js.map +1 -0
- package/lib/components/BryntumColumnScrollButton.js +5 -0
- package/lib/components/BryntumColumnScrollButton.js.map +1 -0
- package/lib/components/BryntumProjectCombo.js +5 -0
- package/lib/components/BryntumProjectCombo.js.map +1 -0
- package/lib/components/BryntumResourcesCombo.js +5 -0
- package/lib/components/BryntumResourcesCombo.js.map +1 -0
- package/lib/components/BryntumSwimlaneCombo.js +5 -0
- package/lib/components/BryntumSwimlaneCombo.js.map +1 -0
- package/lib/components/BryntumSwimlaneFilterField.js +5 -0
- package/lib/components/BryntumSwimlaneFilterField.js.map +1 -0
- package/lib/components/BryntumSwimlanePickerButton.js +5 -0
- package/lib/components/BryntumSwimlanePickerButton.js.map +1 -0
- package/lib/components/BryntumSwimlaneScrollButton.js +5 -0
- package/lib/components/BryntumSwimlaneScrollButton.js.map +1 -0
- package/lib/components/BryntumTagCombo.js +5 -0
- package/lib/components/BryntumTagCombo.js.map +1 -0
- package/lib/components/BryntumTaskBoard.js +5 -0
- package/lib/components/BryntumTaskBoard.js.map +1 -0
- package/lib/components/BryntumTaskBoardBase.js +5 -0
- package/lib/components/BryntumTaskBoardBase.js.map +1 -0
- package/lib/components/BryntumTaskBoardFieldFilterPicker.js +5 -0
- package/lib/components/BryntumTaskBoardFieldFilterPicker.js.map +1 -0
- package/lib/components/BryntumTaskBoardFieldFilterPickerGroup.js +5 -0
- package/lib/components/BryntumTaskBoardFieldFilterPickerGroup.js.map +1 -0
- package/lib/components/BryntumTaskBoardProjectModel.js +5 -0
- package/lib/components/BryntumTaskBoardProjectModel.js.map +1 -0
- package/lib/components/BryntumTaskColorCombo.js +5 -0
- package/lib/components/BryntumTaskColorCombo.js.map +1 -0
- package/lib/components/BryntumTaskFilterField.js +5 -0
- package/lib/components/BryntumTaskFilterField.js.map +1 -0
- package/lib/components/BryntumTodoListField.js +5 -0
- package/lib/components/BryntumTodoListField.js.map +1 -0
- package/lib/components/BryntumUndoRedo.js +5 -0
- package/lib/components/BryntumUndoRedo.js.map +1 -0
- package/lib/components/BryntumZoomSlider.js +5 -0
- package/lib/components/BryntumZoomSlider.js.map +1 -0
- package/lib/helper/WrapperHelper.js +291 -0
- package/lib/helper/WrapperHelper.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +45 -0
- package/lib/index.js.map +1 -0
- package/license.pdf +0 -0
- package/licenses.md +310 -0
- package/package.json +27 -0
- package/src/components/BryntumColumnCombo.vue +1346 -0
- package/src/components/BryntumColumnComboProps.ts +846 -0
- package/src/components/BryntumColumnFilterField.vue +1120 -0
- package/src/components/BryntumColumnFilterFieldProps.ts +664 -0
- package/src/components/BryntumColumnPickerButton.vue +997 -0
- package/src/components/BryntumColumnPickerButtonProps.ts +563 -0
- package/src/components/BryntumColumnScrollButton.vue +997 -0
- package/src/components/BryntumColumnScrollButtonProps.ts +563 -0
- package/src/components/BryntumProjectCombo.vue +1347 -0
- package/src/components/BryntumProjectComboProps.ts +846 -0
- package/src/components/BryntumResourcesCombo.vue +1345 -0
- package/src/components/BryntumResourcesComboProps.ts +845 -0
- package/src/components/BryntumSwimlaneCombo.vue +1345 -0
- package/src/components/BryntumSwimlaneComboProps.ts +845 -0
- package/src/components/BryntumSwimlaneFilterField.vue +1133 -0
- package/src/components/BryntumSwimlaneFilterFieldProps.ts +675 -0
- package/src/components/BryntumSwimlanePickerButton.vue +997 -0
- package/src/components/BryntumSwimlanePickerButtonProps.ts +563 -0
- package/src/components/BryntumSwimlaneScrollButton.vue +997 -0
- package/src/components/BryntumSwimlaneScrollButtonProps.ts +563 -0
- package/src/components/BryntumTagCombo.vue +1350 -0
- package/src/components/BryntumTagComboProps.ts +849 -0
- package/src/components/BryntumTaskBoard.vue +2432 -0
- package/src/components/BryntumTaskBoardBase.vue +2430 -0
- package/src/components/BryntumTaskBoardBaseProps.ts +976 -0
- package/src/components/BryntumTaskBoardFieldFilterPicker.vue +1021 -0
- package/src/components/BryntumTaskBoardFieldFilterPickerGroup.vue +1079 -0
- package/src/components/BryntumTaskBoardFieldFilterPickerGroupProps.ts +651 -0
- package/src/components/BryntumTaskBoardFieldFilterPickerProps.ts +612 -0
- package/src/components/BryntumTaskBoardProjectModel.vue +894 -0
- package/src/components/BryntumTaskBoardProjectModelProps.ts +409 -0
- package/src/components/BryntumTaskBoardProps.ts +977 -0
- package/src/components/BryntumTaskColorCombo.vue +1097 -0
- package/src/components/BryntumTaskColorComboProps.ts +642 -0
- package/src/components/BryntumTaskFilterField.vue +1133 -0
- package/src/components/BryntumTaskFilterFieldProps.ts +675 -0
- package/src/components/BryntumTodoListField.vue +1087 -0
- package/src/components/BryntumTodoListFieldProps.ts +636 -0
- package/src/components/BryntumUndoRedo.vue +957 -0
- package/src/components/BryntumUndoRedoProps.ts +570 -0
- package/src/components/BryntumZoomSlider.vue +910 -0
- package/src/components/BryntumZoomSliderProps.ts +530 -0
- package/src/helper/WrapperHelper.ts +573 -0
- package/src/index.ts +46 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue 3 widget helper
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { type ComponentInternalInstance, nextTick } from 'vue';
|
|
6
|
+
import { type VueConfig, Widget } from '@bryntum/core-thin';
|
|
7
|
+
|
|
8
|
+
declare global {
|
|
9
|
+
interface Window {
|
|
10
|
+
bryntum: {
|
|
11
|
+
isTestEnv?: boolean;
|
|
12
|
+
vue?: {
|
|
13
|
+
isVueConfig?: (config: any) => boolean;
|
|
14
|
+
handleVueContent?: (widget: Widget, html: VueConfig) => void;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface RenderElement extends HTMLElement {
|
|
21
|
+
vueKey: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type Data = Record<string, unknown>;
|
|
25
|
+
|
|
26
|
+
type SuppressNew<T> = { [K in keyof T]: T[ K ] }
|
|
27
|
+
|
|
28
|
+
type AnyConstructor<
|
|
29
|
+
Instance extends object = object,
|
|
30
|
+
Static extends object = object
|
|
31
|
+
> = (new (...input: any[]) => Instance) & SuppressNew<Static>
|
|
32
|
+
|
|
33
|
+
type AnyWidget = AnyConstructor<any, any>;
|
|
34
|
+
|
|
35
|
+
type RenderData = {
|
|
36
|
+
record: any,
|
|
37
|
+
row: any,
|
|
38
|
+
column: any,
|
|
39
|
+
cellElement: RenderElement
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type VueTeleportConfig = {
|
|
43
|
+
vue: boolean,
|
|
44
|
+
is: string,
|
|
45
|
+
bind?: object
|
|
46
|
+
on?: object
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type WidgetData<T extends AnyWidget> = {
|
|
50
|
+
instanceClass: T,
|
|
51
|
+
instanceName: string
|
|
52
|
+
isView?: boolean,
|
|
53
|
+
dataStores?: object,
|
|
54
|
+
projectStores?: boolean,
|
|
55
|
+
configNames: string[]
|
|
56
|
+
propertyConfigNames: string[]
|
|
57
|
+
propertyNames: string[]
|
|
58
|
+
eventNames: string[]
|
|
59
|
+
featureNames?: string[]
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type WidgetConfig<T extends AnyWidget> = {
|
|
63
|
+
me?: ComponentInternalInstance;
|
|
64
|
+
widgetData: WidgetData<T>,
|
|
65
|
+
emit: (...args: any[]) => any
|
|
66
|
+
element: HTMLDivElement;
|
|
67
|
+
processCellContent?: Function;
|
|
68
|
+
processEventContent?: Function;
|
|
69
|
+
processWidgetContent?: Function;
|
|
70
|
+
hasFrameworkRenderer?: Function;
|
|
71
|
+
toRaw?: Function
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type BryntumConfig = Record<string, any> & {
|
|
75
|
+
vueComponent?: Object,
|
|
76
|
+
listeners: Record<string, Function>,
|
|
77
|
+
features: {},
|
|
78
|
+
processCellContent: Function,
|
|
79
|
+
processEventContent: Function,
|
|
80
|
+
processWidgetContent: Function;
|
|
81
|
+
hasFrameworkRenderer: Function
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export class WrapperHelper {
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Development warning. Showed when environment is set to 'development'
|
|
88
|
+
* @param {String} clsName vue component instance
|
|
89
|
+
* @param {String} msg console message
|
|
90
|
+
*/
|
|
91
|
+
static devWarning(clsName: string, msg: string) {
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
if (window.bryntum?.isTestEnv || process.env.NODE_ENV === 'development') {
|
|
94
|
+
console.warn(`Bryntum${clsName}Component development warning!\n${msg}\n` +
|
|
95
|
+
'Please check Vue integration guide: https://bryntum.com/products/grid/docs/guide/Grid/integration/vue/guide'
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static devWarningContainer(clsName: string, containerParam: string) {
|
|
101
|
+
WrapperHelper.devWarning(clsName,
|
|
102
|
+
`Using "${containerParam}" parameter for configuration is not recommended.\n` +
|
|
103
|
+
'Widget is placed automatically inside it\'s container element.\n' +
|
|
104
|
+
`Solution: remove "${containerParam}" parameter from configuration.`
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static devWarningConfigProp(clsName: string, prop: string) {
|
|
109
|
+
WrapperHelper.devWarning(clsName,
|
|
110
|
+
`Using "${prop}" parameter for configuration is not recommended.\n` +
|
|
111
|
+
`Solution: Use separate parameter for each "${prop}" value to enable reactive updates of the API instance`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static devWarningUpdateProp(clsName: string, prop: string) {
|
|
116
|
+
WrapperHelper.devWarning(clsName,
|
|
117
|
+
`"${prop}" is a static config option for component constructor only. No runtime changes are supported!`
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static camelize(str: string) {
|
|
122
|
+
return str.replace(/-./g, s => (s[1] || '').toUpperCase());
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static capitalize(str: string) {
|
|
126
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Returns `true` if the provided configuration object is valid for Vue processing.
|
|
131
|
+
* @param {*} config
|
|
132
|
+
* @returns {Boolean}
|
|
133
|
+
*/
|
|
134
|
+
static isVueConfig(config: any): boolean {
|
|
135
|
+
return Boolean(config?.vue);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Creates bryntum component config from vue component
|
|
140
|
+
* @param {Object} context
|
|
141
|
+
* @param {Object} context.me vue component instance
|
|
142
|
+
* @param {Object} context.widgetData reference to data
|
|
143
|
+
* @param {Function} context.emit reference to emit
|
|
144
|
+
* @param {Object} context.element HTML element
|
|
145
|
+
* @param {Function} context.processCellContent cell renderer method
|
|
146
|
+
* @param {Function} context.processEventContent event renderer method
|
|
147
|
+
* @param {Function} context.processWidgetContent widget renderer method
|
|
148
|
+
* @param {Function} context.hasFrameworkRenderer checks presence of vue renderer
|
|
149
|
+
* @param {Function} context.toRaw Vue fn to unwrap reactive object
|
|
150
|
+
* @returns {Object} config object
|
|
151
|
+
*/
|
|
152
|
+
static createConfig<T extends AnyWidget>({
|
|
153
|
+
me,
|
|
154
|
+
widgetData,
|
|
155
|
+
emit,
|
|
156
|
+
element,
|
|
157
|
+
processCellContent,
|
|
158
|
+
processEventContent,
|
|
159
|
+
processWidgetContent,
|
|
160
|
+
hasFrameworkRenderer,
|
|
161
|
+
toRaw
|
|
162
|
+
}: WidgetConfig<T>) {
|
|
163
|
+
|
|
164
|
+
const
|
|
165
|
+
props: Record<string, any> = {},
|
|
166
|
+
vProps = me!.vnode!.props! || {};
|
|
167
|
+
|
|
168
|
+
for (const key of Object.keys(vProps)) {
|
|
169
|
+
// Convert possible kebab keys to camelCase
|
|
170
|
+
props[this.camelize(key)] = vProps[key];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const
|
|
174
|
+
{
|
|
175
|
+
instanceClass,
|
|
176
|
+
instanceName
|
|
177
|
+
} = widgetData,
|
|
178
|
+
isValidProp = (propName: string) => props[propName] !== undefined,
|
|
179
|
+
configNames = (widgetData.configNames || []).filter(isValidProp),
|
|
180
|
+
propertyConfigNames = (widgetData.propertyConfigNames || []).filter(isValidProp),
|
|
181
|
+
propertyNames = (widgetData.propertyNames || []).filter(isValidProp),
|
|
182
|
+
featureNames = (widgetData.featureNames || []).filter(isValidProp),
|
|
183
|
+
// Disable event listeners for onProps, which are duplicating functions with preventable result support
|
|
184
|
+
eventNames = widgetData.eventNames.filter(eventName => !isValidProp(eventName) && !props[`on${this.capitalize(eventName)}`]),
|
|
185
|
+
bryntumConfig = {
|
|
186
|
+
vueComponent : me,
|
|
187
|
+
listeners : {},
|
|
188
|
+
features : {},
|
|
189
|
+
processCellContent,
|
|
190
|
+
processEventContent,
|
|
191
|
+
processWidgetContent,
|
|
192
|
+
hasFrameworkRenderer
|
|
193
|
+
} as BryntumConfig;
|
|
194
|
+
|
|
195
|
+
// Setup events listeners
|
|
196
|
+
eventNames.forEach(eventName => bryntumConfig.listeners[eventName] = (params: any) => emit(eventName, params));
|
|
197
|
+
|
|
198
|
+
// Setup configs
|
|
199
|
+
[
|
|
200
|
+
...configNames,
|
|
201
|
+
...propertyConfigNames,
|
|
202
|
+
...featureNames
|
|
203
|
+
].forEach(propName => {
|
|
204
|
+
WrapperHelper.applyPropValue(bryntumConfig, propName, props[propName], true, toRaw);
|
|
205
|
+
if (['features', 'config'].includes(propName)) {
|
|
206
|
+
WrapperHelper.devWarningConfigProp(instanceClass.$name, propName);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// Add vue wrapper class name
|
|
211
|
+
bryntumConfig.cls = (bryntumConfig.cls || '') + ` b-vue-${instanceClass.$name.toLowerCase()}-container`;
|
|
212
|
+
|
|
213
|
+
// Prepare watch arrays
|
|
214
|
+
widgetData.configNames = configNames;
|
|
215
|
+
widgetData.propertyNames = [
|
|
216
|
+
...configNames,
|
|
217
|
+
...propertyNames,
|
|
218
|
+
...propertyConfigNames,
|
|
219
|
+
...featureNames
|
|
220
|
+
];
|
|
221
|
+
|
|
222
|
+
// Cleanup unused instance arrays
|
|
223
|
+
widgetData.eventNames = [];
|
|
224
|
+
widgetData.propertyConfigNames = [];
|
|
225
|
+
widgetData.featureNames = [];
|
|
226
|
+
|
|
227
|
+
// If component has no container specified in config then use adopt to Wrapper's element
|
|
228
|
+
const
|
|
229
|
+
containerParam = [
|
|
230
|
+
'adopt',
|
|
231
|
+
'appendTo',
|
|
232
|
+
'insertAfter',
|
|
233
|
+
'insertBefore'
|
|
234
|
+
].find((prop: string) => bryntumConfig[prop]);
|
|
235
|
+
|
|
236
|
+
if (!containerParam) {
|
|
237
|
+
if (instanceName === 'Button') {
|
|
238
|
+
// Button should always be <a> or <button> inside owner element
|
|
239
|
+
bryntumConfig.appendTo = element;
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
bryntumConfig.adopt = element;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
WrapperHelper.devWarningContainer(instanceClass.$name, containerParam);
|
|
247
|
+
}
|
|
248
|
+
return bryntumConfig;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Setup store events relay
|
|
253
|
+
* @param {Object} data reference to data
|
|
254
|
+
* @param {Object} instance bryntum widget instance
|
|
255
|
+
*/
|
|
256
|
+
static relayStores(data: any, instance: any) {
|
|
257
|
+
const { dataStores, projectStores } = data;
|
|
258
|
+
|
|
259
|
+
if (dataStores) {
|
|
260
|
+
Object.keys(dataStores).forEach(storeName => {
|
|
261
|
+
const store = projectStores ? instance.project[storeName] : instance[storeName];
|
|
262
|
+
if (store) {
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
if (store.syncDataOnLoad == null && !store.readUrl && !store.lazyLoad && (!store.crudManager || !store.crudManager.loadUrl)) {
|
|
266
|
+
store.syncDataOnLoad = true;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
// Makes relaying store events configurable but off by default
|
|
272
|
+
if (instance && instance.relayStoreEvents) {
|
|
273
|
+
store.relayAll(instance, dataStores[storeName]);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
delete data.dataStores;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Creates bryntum Widget from vue component
|
|
283
|
+
* @param {Object} config
|
|
284
|
+
* @param {Object} config.me vue component instance
|
|
285
|
+
* @param {Object} config.widgetData reference to data
|
|
286
|
+
* @param {Function} config.emit reference to emit
|
|
287
|
+
* @param {Object} config.element HTML element
|
|
288
|
+
* @param {Function} config.processCellContent cell renderer method
|
|
289
|
+
* @param {Function} config.hasFrameworkRenderer check the presence of vue renderer
|
|
290
|
+
* @param {Function} config.toRaw Vue fn to unwrap reactive object
|
|
291
|
+
* @returns {Object} widget object
|
|
292
|
+
*/
|
|
293
|
+
static createWidget<T extends AnyWidget>(config: WidgetConfig<T>): InstanceType<T> {
|
|
294
|
+
const
|
|
295
|
+
{ instanceClass } = config.widgetData,
|
|
296
|
+
cfg = WrapperHelper.createConfig(config);
|
|
297
|
+
return (instanceClass.$name === 'Widget' ? Widget.create(cfg) : new instanceClass(cfg)) as InstanceType<T>;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Applies property value to Bryntum config or instance.
|
|
302
|
+
* @param {Object} configOrInstance target object
|
|
303
|
+
* @param {String} prop property name
|
|
304
|
+
* @param {Object} value value
|
|
305
|
+
* @param {Boolean} [isConfig] config setting mode
|
|
306
|
+
* @param {Function} [toRaw] Vue fn to unwrap reactive object
|
|
307
|
+
*/
|
|
308
|
+
static applyPropValue(configOrInstance: any, prop: string, value: any, isConfig = true, toRaw?: Function) {
|
|
309
|
+
|
|
310
|
+
if (prop === 'project') {
|
|
311
|
+
// Allow use ProjectModel component as project
|
|
312
|
+
if (value && typeof value === 'object') {
|
|
313
|
+
configOrInstance[prop] = value.instance ? value.instance.value || value.instance : value;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
else if (prop === 'features' && typeof value === 'object') {
|
|
317
|
+
Object.keys(value).forEach(key => WrapperHelper.applyPropValue(configOrInstance, `${key}Feature`, value[key], isConfig, toRaw));
|
|
318
|
+
}
|
|
319
|
+
else if (prop === 'config' && typeof value === 'object') {
|
|
320
|
+
Object.keys(value).forEach(key => WrapperHelper.applyPropValue(configOrInstance, key, value[key], isConfig, toRaw));
|
|
321
|
+
}
|
|
322
|
+
else if (prop === 'columns' && !isConfig) {
|
|
323
|
+
configOrInstance['columns'].data = value;
|
|
324
|
+
}
|
|
325
|
+
else if (prop.endsWith('Feature')) {
|
|
326
|
+
const
|
|
327
|
+
features = configOrInstance['features'],
|
|
328
|
+
featureName = prop.replace('Feature', '');
|
|
329
|
+
if (isConfig) {
|
|
330
|
+
features[featureName] = value;
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
const feature = features[featureName];
|
|
334
|
+
if (feature) {
|
|
335
|
+
feature.setConfig(value);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
configOrInstance[prop] = toRaw ? toRaw(value) : value;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Creates watches for vue component properties
|
|
346
|
+
* @param {Object} me vue component instance
|
|
347
|
+
* @param {Object} instance bryntum widget instance
|
|
348
|
+
* @param {Object} props reference to props
|
|
349
|
+
* @param {Object} data reference to data
|
|
350
|
+
* @param {Function} watcher watch method reference (Accepts: prop and newValue)
|
|
351
|
+
*/
|
|
352
|
+
static watchProps<T extends AnyWidget>(
|
|
353
|
+
instance: InstanceType<T>,
|
|
354
|
+
data: WidgetData<T>,
|
|
355
|
+
watcher: (prop: string, callback: (value: any) => void) => void) {
|
|
356
|
+
const
|
|
357
|
+
{
|
|
358
|
+
configNames,
|
|
359
|
+
propertyNames,
|
|
360
|
+
instanceClass
|
|
361
|
+
} = data;
|
|
362
|
+
|
|
363
|
+
propertyNames.forEach(prop => watcher(prop, newValue => {
|
|
364
|
+
const value = Array.isArray(newValue) ? newValue.slice() : newValue;
|
|
365
|
+
WrapperHelper.applyPropValue(instance, prop, value, false);
|
|
366
|
+
|
|
367
|
+
// Check if property is a config and notify
|
|
368
|
+
if (configNames.includes(prop)) {
|
|
369
|
+
WrapperHelper.devWarningUpdateProp(instanceClass.$name, prop);
|
|
370
|
+
}
|
|
371
|
+
}));
|
|
372
|
+
|
|
373
|
+
// Cleanup unused instance arrays
|
|
374
|
+
data.configNames = [];
|
|
375
|
+
data.propertyNames = [];
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Called from Widget.js to add the Vue component to teleports
|
|
380
|
+
* @param {Object} context
|
|
381
|
+
* @param {Widget} context.widget Widget which content is rendered by the Vue component
|
|
382
|
+
* @param {Object} context.html Object containing the Vue component properties and event listeners
|
|
383
|
+
*/
|
|
384
|
+
static processWidgetContent({ widget, html }: { widget: Widget; html: VueTeleportConfig }) {
|
|
385
|
+
const
|
|
386
|
+
{ is, bind = {}, vue, on = {} } = html,
|
|
387
|
+
// @ts-ignore
|
|
388
|
+
{ vueComponent } = this,
|
|
389
|
+
{ teleports : { value : teleports } } = vueComponent.provides,
|
|
390
|
+
{ contentElement : to, id } = widget;
|
|
391
|
+
|
|
392
|
+
if (vue) {
|
|
393
|
+
const key = `key-${id}`;
|
|
394
|
+
|
|
395
|
+
// delete the teleport with the same key if any
|
|
396
|
+
if (teleports.has(key)) {
|
|
397
|
+
teleports.delete(key);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
nextTick(() => {
|
|
401
|
+
teleports.set(key, { bind, on, key, is, to });
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Handles the content provided by a Vue component for the widget.
|
|
408
|
+
* @param {Widget} widget Owner widget
|
|
409
|
+
* @param {String} html The HTML content to be processed
|
|
410
|
+
*/
|
|
411
|
+
static handleVueContent(widget: Widget, html: VueConfig): void {
|
|
412
|
+
// Called when a Vue component is to provide the widget content
|
|
413
|
+
const
|
|
414
|
+
hasTeleports = (element: any) => Boolean(element.vueComponent?.provides?.teleports),
|
|
415
|
+
parentView = widget.closest(hasTeleports) as any,
|
|
416
|
+
// Find a view (grid, scheduler, etc.) which has `teleports` defined. It also has `processWidgetContent`
|
|
417
|
+
view = parentView?.vueComponent ? parentView : Widget.query(hasTeleports);
|
|
418
|
+
|
|
419
|
+
view?.processWidgetContent?.({ widget, html });
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Event renderer method
|
|
424
|
+
* @param {Object} context
|
|
425
|
+
* @param {*} context.jsx
|
|
426
|
+
* @param {DomConfig} context.domConfig
|
|
427
|
+
* @param {HTMLElement} context.targetElement
|
|
428
|
+
* @param {Boolean} context.isRelease
|
|
429
|
+
* @returns {Boolean}
|
|
430
|
+
*/
|
|
431
|
+
static processEventContent({
|
|
432
|
+
// Core passes it as jsx for React wrappers.
|
|
433
|
+
// Let's rename it to a more appropriate name.
|
|
434
|
+
jsx : rendererConfig,
|
|
435
|
+
domConfig,
|
|
436
|
+
targetElement,
|
|
437
|
+
isRelease
|
|
438
|
+
}: {
|
|
439
|
+
jsx: { [key: string]: any },
|
|
440
|
+
domConfig: any;
|
|
441
|
+
isRelease: boolean;
|
|
442
|
+
targetElement: HTMLElement & { vueKey: string }
|
|
443
|
+
scrolling: boolean
|
|
444
|
+
}) {
|
|
445
|
+
|
|
446
|
+
let wrap: any = targetElement,
|
|
447
|
+
returnValue = false;
|
|
448
|
+
|
|
449
|
+
// @ts-ignore
|
|
450
|
+
const domConfigData = this.isVertical ? domConfig?.elementData?.renderData : domConfig?.elementData;
|
|
451
|
+
|
|
452
|
+
if (WrapperHelper.isVueConfig(rendererConfig) && rendererConfig?.is) {
|
|
453
|
+
if (domConfig?.dataset?.isMilestone) {
|
|
454
|
+
wrap = targetElement.parentElement!.parentElement!.parentElement!;
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
wrap = targetElement.parentElement!.parentElement!;
|
|
458
|
+
}
|
|
459
|
+
const
|
|
460
|
+
// Vertical nests renderData, while horizontal does not
|
|
461
|
+
// @ts-ignore
|
|
462
|
+
wrapData = this.isVertical ? wrap.elementData.renderData : wrap.elementData,
|
|
463
|
+
{ assignmentRecord } = isRelease ? domConfigData : wrapData,
|
|
464
|
+
{ eventRecord } = wrapData,
|
|
465
|
+
{ vueComponent } = this as any,
|
|
466
|
+
{ teleports : { value : teleports } } = vueComponent.provides,
|
|
467
|
+
|
|
468
|
+
// Recurring events are handled a bit differently so get the flag
|
|
469
|
+
isRecurring = eventRecord.isRecurring || eventRecord.isOccurrence,
|
|
470
|
+
key = `assignment-${assignmentRecord?.id}${isRecurring ? '-' + eventRecord.id : ''}`;
|
|
471
|
+
|
|
472
|
+
if (wrap.vueKey) {
|
|
473
|
+
teleports.delete(wrap.vueKey);
|
|
474
|
+
}
|
|
475
|
+
const
|
|
476
|
+
bind = { ...rendererConfig },
|
|
477
|
+
{ is, on = {} } = bind;
|
|
478
|
+
|
|
479
|
+
delete bind.is;
|
|
480
|
+
delete bind.on;
|
|
481
|
+
|
|
482
|
+
nextTick(() => {
|
|
483
|
+
teleports.set(key, {
|
|
484
|
+
bind,
|
|
485
|
+
key,
|
|
486
|
+
is,
|
|
487
|
+
on,
|
|
488
|
+
to : targetElement,
|
|
489
|
+
generation : assignmentRecord.generation
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
wrap.vueKey = key;
|
|
495
|
+
returnValue = true;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
return returnValue;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Cell renderer method
|
|
503
|
+
* @param {Object} context
|
|
504
|
+
* @param {RenderData} context.rendererData
|
|
505
|
+
* @param {*} context.rendererHtml
|
|
506
|
+
* @returns {Boolean}
|
|
507
|
+
*/
|
|
508
|
+
static processCellContent({ rendererData, rendererHtml }: { rendererData: RenderData, rendererHtml: any }) {
|
|
509
|
+
const { record, column, cellElement, row } = rendererData;
|
|
510
|
+
|
|
511
|
+
// Only run for cells with vue renderers
|
|
512
|
+
if (WrapperHelper.isVueConfig(column.data) && column.data?.renderer) {
|
|
513
|
+
const
|
|
514
|
+
// `this` is a caller component
|
|
515
|
+
{ vueComponent } = this as any,
|
|
516
|
+
// `teleports` is javascript Map object
|
|
517
|
+
{ teleports : { value : teleports } } = vueComponent.provides,
|
|
518
|
+
key = `${column.id}-${record.id}`,
|
|
519
|
+
renderElement = column.tree
|
|
520
|
+
? cellElement.querySelector('.b-tree-cell-value')
|
|
521
|
+
: cellElement;
|
|
522
|
+
|
|
523
|
+
// If the cell already has a teleport, release it
|
|
524
|
+
if (cellElement.vueKey) {
|
|
525
|
+
teleports.delete(cellElement.vueKey);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
const
|
|
529
|
+
bind = { ...rendererHtml },
|
|
530
|
+
{ is, on = {} } = bind;
|
|
531
|
+
|
|
532
|
+
delete bind.is;
|
|
533
|
+
delete bind.on;
|
|
534
|
+
|
|
535
|
+
// Create new teleport
|
|
536
|
+
nextTick(() => {
|
|
537
|
+
// Only teleport if the row is still used for the same record. Since this happens async, we might have
|
|
538
|
+
// scrolled over the entire block of rows since the render
|
|
539
|
+
if (row.id === record.id) {
|
|
540
|
+
teleports.set(key, {
|
|
541
|
+
bind,
|
|
542
|
+
key,
|
|
543
|
+
is,
|
|
544
|
+
on,
|
|
545
|
+
to : renderElement,
|
|
546
|
+
generation : record.generation
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
// Link cell to the teleport, to be able to release it above
|
|
552
|
+
cellElement.vueKey = key;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
*
|
|
558
|
+
* @param {Object} context
|
|
559
|
+
* @param {*} context.cellContent Content to be rendered in cell (set by renderer)
|
|
560
|
+
* @param {*} context.column Column being rendered
|
|
561
|
+
* @returns {Boolean} `true` if there is a Vue Renderer in this cell, `false` otherwise
|
|
562
|
+
*/
|
|
563
|
+
static hasFrameworkRenderer({ cellContent, column }: { cellContent: any, column: any }) {
|
|
564
|
+
return cellContent && typeof cellContent === 'object' && WrapperHelper.isVueConfig(column?.data);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// Expose wrapper methods on window.bryntum
|
|
569
|
+
window.bryntum = window.bryntum || {};
|
|
570
|
+
window.bryntum.vue = {
|
|
571
|
+
isVueConfig : WrapperHelper.isVueConfig,
|
|
572
|
+
handleVueContent : WrapperHelper.handleVueContent
|
|
573
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue 3 wrappers
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export { default as BryntumColumnCombo } from './components/BryntumColumnCombo.vue';
|
|
6
|
+
export * from './components/BryntumColumnComboProps';
|
|
7
|
+
export { default as BryntumColumnFilterField } from './components/BryntumColumnFilterField.vue';
|
|
8
|
+
export * from './components/BryntumColumnFilterFieldProps';
|
|
9
|
+
export { default as BryntumColumnPickerButton } from './components/BryntumColumnPickerButton.vue';
|
|
10
|
+
export * from './components/BryntumColumnPickerButtonProps';
|
|
11
|
+
export { default as BryntumColumnScrollButton } from './components/BryntumColumnScrollButton.vue';
|
|
12
|
+
export * from './components/BryntumColumnScrollButtonProps';
|
|
13
|
+
export { default as BryntumProjectCombo } from './components/BryntumProjectCombo.vue';
|
|
14
|
+
export * from './components/BryntumProjectComboProps';
|
|
15
|
+
export { default as BryntumTaskBoardProjectModel } from './components/BryntumTaskBoardProjectModel.vue';
|
|
16
|
+
export * from './components/BryntumTaskBoardProjectModelProps';
|
|
17
|
+
export { default as BryntumResourcesCombo } from './components/BryntumResourcesCombo.vue';
|
|
18
|
+
export * from './components/BryntumResourcesComboProps';
|
|
19
|
+
export { default as BryntumSwimlaneCombo } from './components/BryntumSwimlaneCombo.vue';
|
|
20
|
+
export * from './components/BryntumSwimlaneComboProps';
|
|
21
|
+
export { default as BryntumSwimlaneFilterField } from './components/BryntumSwimlaneFilterField.vue';
|
|
22
|
+
export * from './components/BryntumSwimlaneFilterFieldProps';
|
|
23
|
+
export { default as BryntumSwimlanePickerButton } from './components/BryntumSwimlanePickerButton.vue';
|
|
24
|
+
export * from './components/BryntumSwimlanePickerButtonProps';
|
|
25
|
+
export { default as BryntumSwimlaneScrollButton } from './components/BryntumSwimlaneScrollButton.vue';
|
|
26
|
+
export * from './components/BryntumSwimlaneScrollButtonProps';
|
|
27
|
+
export { default as BryntumTagCombo } from './components/BryntumTagCombo.vue';
|
|
28
|
+
export * from './components/BryntumTagComboProps';
|
|
29
|
+
export { default as BryntumTaskBoard } from './components/BryntumTaskBoard.vue';
|
|
30
|
+
export * from './components/BryntumTaskBoardProps';
|
|
31
|
+
export { default as BryntumTaskBoardBase } from './components/BryntumTaskBoardBase.vue';
|
|
32
|
+
export * from './components/BryntumTaskBoardBaseProps';
|
|
33
|
+
export { default as BryntumTaskBoardFieldFilterPicker } from './components/BryntumTaskBoardFieldFilterPicker.vue';
|
|
34
|
+
export * from './components/BryntumTaskBoardFieldFilterPickerProps';
|
|
35
|
+
export { default as BryntumTaskBoardFieldFilterPickerGroup } from './components/BryntumTaskBoardFieldFilterPickerGroup.vue';
|
|
36
|
+
export * from './components/BryntumTaskBoardFieldFilterPickerGroupProps';
|
|
37
|
+
export { default as BryntumTaskColorCombo } from './components/BryntumTaskColorCombo.vue';
|
|
38
|
+
export * from './components/BryntumTaskColorComboProps';
|
|
39
|
+
export { default as BryntumTaskFilterField } from './components/BryntumTaskFilterField.vue';
|
|
40
|
+
export * from './components/BryntumTaskFilterFieldProps';
|
|
41
|
+
export { default as BryntumTodoListField } from './components/BryntumTodoListField.vue';
|
|
42
|
+
export * from './components/BryntumTodoListFieldProps';
|
|
43
|
+
export { default as BryntumUndoRedo } from './components/BryntumUndoRedo.vue';
|
|
44
|
+
export * from './components/BryntumUndoRedoProps';
|
|
45
|
+
export { default as BryntumZoomSlider } from './components/BryntumZoomSlider.vue';
|
|
46
|
+
export * from './components/BryntumZoomSliderProps';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|