@antcde/component-library 0.1.33 → 0.1.35-rc.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.
Files changed (40) hide show
  1. package/dist/build/uno.js +2 -0
  2. package/dist/build/uno.shortcuts.js +2 -2
  3. package/dist/index.js +35640 -35642
  4. package/dist/types/components/AntNoticeAlert.vue.d.ts +2 -2
  5. package/dist/types/components/AntTourZone/index.vue.d.ts +1 -1
  6. package/dist/types/components/BaseAppCard/index.vue.d.ts +2 -2
  7. package/dist/types/components/BaseAppCardSkeleton.vue.d.ts +1 -1
  8. package/dist/types/components/BaseConfirmDialog.vue.d.ts +2 -2
  9. package/dist/types/components/BaseDeleteDialog.vue.d.ts +5 -5
  10. package/dist/types/components/BaseDialog.vue.d.ts +2 -2
  11. package/dist/types/components/BaseLimitedButton.vue.d.ts +5 -5
  12. package/dist/types/components/BulkLabelsMenu.vue.d.ts +2 -2
  13. package/dist/types/components/FilePreviewContent/usePreviewDetails.d.ts +1 -1
  14. package/dist/types/components/ScriptTrigger/composables/useTableSelection.d.ts +16 -0
  15. package/dist/types/components/ScriptTrigger/context.d.ts +2 -2
  16. package/dist/types/components/StackedLabels/index.vue.d.ts +1 -1
  17. package/dist/types/components/TasksFlow/components/nodes/_DurationEditor.vue.d.ts +2 -2
  18. package/dist/types/components/TasksFlow/components/nodes/_UserPicker.vue.d.ts +2 -2
  19. package/dist/types/components/TasksFlow/composables/useEdgeConditionTables.d.ts +16 -0
  20. package/dist/types/components/TasksFlow/composables/useFlowEdgeConditionState.d.ts +1 -1
  21. package/dist/types/components/TasksFlow/composables/useTaskFlow.d.ts +1 -1
  22. package/dist/types/components/form/AntDialogShell.vue.d.ts +7 -7
  23. package/dist/types/components/form/AntScopePanel.vue.d.ts +2 -2
  24. package/dist/types/deprecated.d.ts +974 -0
  25. package/dist/types/index.d.ts +2 -45
  26. package/lib/build/fonts.css +26 -0
  27. package/lib/build/uno.shortcuts.ts +2 -2
  28. package/lib/build/uno.ts +2 -0
  29. package/lib/build/vuetify.ts +4 -1
  30. package/package.json +25 -36
  31. package/lib/ForgeViewer/ForgeViewer.vue +0 -43
  32. package/lib/ForgeViewer/index.ts +0 -4
  33. package/lib/ForgeViewer/lang/translations/de.json +0 -6
  34. package/lib/ForgeViewer/lang/translations/en.json +0 -6
  35. package/lib/ForgeViewer/lang/translations/nl.json +0 -6
  36. package/lib/ForgeViewer/useForgeViewer.ts +0 -401
  37. package/lib/GisViewer/GisViewer.vue +0 -67
  38. package/lib/GisViewer/GisViewerAppBar.vue +0 -34
  39. package/lib/GisViewer/index.ts +0 -3
  40. package/lib/GisViewer/useGisViewer.ts +0 -415
@@ -1,415 +0,0 @@
1
- import type { TableRecords } from '@antcde/connect-ts'
2
- import type { UseCommsClient } from '@antcde/vue-utils'
3
- import Graphic from '@arcgis/core/Graphic'
4
- import GraphicsLayer from '@arcgis/core/layers/GraphicsLayer'
5
- import Map from '@arcgis/core/Map'
6
- import SimpleFillSymbol from '@arcgis/core/symbols/SimpleFillSymbol'
7
- import SimpleLineSymbol from '@arcgis/core/symbols/SimpleLineSymbol'
8
- import MapView from '@arcgis/core/views/MapView'
9
- import LayerList from '@arcgis/core/widgets/LayerList'
10
- import SketchWidget from '@arcgis/core/widgets/Sketch'
11
- import { onUnmounted, ref, shallowRef, watch } from 'vue'
12
-
13
- export interface Project {
14
- id: string
15
- name: string
16
- }
17
-
18
- export interface ApplicationProps {
19
- client: UseCommsClient
20
- widgets?: object
21
- drawings?: object
22
- }
23
-
24
- export interface GisComposable {
25
- map: any
26
- view: any
27
- featureLayerView: any
28
- sketchLayer: any
29
- widgets: any
30
- }
31
-
32
- const ZOOM = 12
33
- const BASEMAP = 'topo-vector'
34
-
35
- export const GIS_VIEWER_WIDGETS = {
36
- HOME: 'home',
37
- LAYER_LIST: 'layerList',
38
- SEARCH: 'search',
39
- ZOOM: 'zoom',
40
- BASEMAP_TOGGLE: 'basemapToggle',
41
- BASEMAP_GALLERY: 'basemapGallery',
42
- MEASUREMENT: 'measurement',
43
- SKETCH: 'sketch',
44
- RFI: 'rfi',
45
- } as const
46
-
47
- type WidgetType = typeof GIS_VIEWER_WIDGETS[keyof typeof GIS_VIEWER_WIDGETS]
48
-
49
- export function useGisViewer({ client, widgets = {} }: ApplicationProps, containerValue: string) {
50
- const container = ref(containerValue)
51
- const gisViewer = shallowRef<GisComposable>({
52
- map: null,
53
- view: null,
54
- featureLayerView: null,
55
- sketchLayer: null,
56
- widgets: {},
57
- })
58
-
59
- const { connect: antConnect, context } = client
60
-
61
- // Fetch records for the project
62
- const fetchMapProperties = async (projectId: string): Promise<TableRecords | null> => {
63
- try {
64
- return await antConnect.tables.queryTables(createTableQueryPayload(projectId)) as TableRecords
65
- }
66
- catch (error) {
67
- console.error('Error fetching records:', error)
68
- return null
69
- }
70
- }
71
-
72
- const clearSketch = () => {
73
- if (gisViewer.value?.sketchLayer) {
74
- // Clear existing drawings in the layer
75
- gisViewer.value?.sketchLayer.removeAll()
76
- }
77
- }
78
-
79
- const getSketch = () => {
80
- const items = gisViewer.value?.sketchLayer?.graphics?.items || []
81
- return items.map((i: any) => ({
82
- symbol: {
83
- type: i.symbol.type,
84
- size: i.symbol.size,
85
- style: i.symbol.style,
86
- color: i.symbol.color.toRgba(),
87
- width: i.symbol.width,
88
- outline: i.symbol.outline
89
- ? {
90
- type: i.symbol.outline.type,
91
- color: i.symbol.outline.color.toRgba(),
92
- width: i.symbol.outline.width,
93
- }
94
- : undefined,
95
- },
96
- geometry: {
97
- spatialReference: i.geometry.spatialReference,
98
- type: i.geometry.type,
99
- paths: i.geometry.paths,
100
- rings: i.geometry.rings,
101
- latitude: i.geometry.latitude,
102
- longitude: i.geometry.longitude,
103
- },
104
- }))
105
- }
106
-
107
- const addSketchLayer = (sketchWidget: any) => {
108
- const layer = new GraphicsLayer({ title: 'Sketch' })
109
- gisViewer.value.map.add(layer)
110
- sketchWidget.layer = layer
111
- gisViewer.value.sketchLayer = layer
112
- }
113
-
114
- const removeSketchLayer = (sketchWidget: any) => {
115
- sketchWidget.layer = undefined
116
- gisViewer.value.sketchLayer.destroy()
117
- gisViewer.value.map.remove(gisViewer.value.sketchLayer)
118
- gisViewer.value.sketchLayer = null
119
- }
120
-
121
- const toggleWidget = (widget: WidgetType, state: boolean) => {
122
- if (widget && gisViewer.value) {
123
- const widgetTarget = gisViewer.value.widgets[widget]
124
- widgetTarget.visible = state
125
- if (widget === GIS_VIEWER_WIDGETS.SKETCH) {
126
- if (state) {
127
- addSketchLayer(widgetTarget)
128
- }
129
- else {
130
- removeSketchLayer(widgetTarget)
131
- }
132
- }
133
- }
134
- }
135
-
136
- const setSketchColor = (rgbColor: { r: number, g: number, b: number }) => {
137
- if (!rgbColor) {
138
- throw new Error('Color not available')
139
- }
140
-
141
- const { r, g, b } = rgbColor
142
- const items = gisViewer.value?.sketchLayer?.graphics?.items || []
143
- items.forEach((i: any) => {
144
- if (i?.symbol?.type === 'simple-line') {
145
- i.symbol.color = [r, g, b, 0.9]
146
- }
147
- else if (i?.symbol?.type === 'simple-fill') {
148
- i.symbol.color = [r, g, b, 0.4]
149
- i.symbol.outline.color = [r, g, b, 0.9]
150
- }
151
- })
152
-
153
- const widgetViewModel = gisViewer.value?.widgets?.sketch?.viewModel
154
- if (widgetViewModel) {
155
- widgetViewModel.polylineSymbol = {
156
- type: 'simple-line',
157
- color: [r, g, b, 1],
158
- width: 2,
159
- style: 'solid',
160
- }
161
- widgetViewModel.polygonSymbol = {
162
- type: 'simple-fill',
163
- color: [r, g, b, 0.4],
164
- outline: {
165
- color: [r, g, b, 0.9],
166
- width: 2,
167
- },
168
- }
169
- }
170
-
171
- // To force rerender LayerView on color change
172
- const graphic = gisViewer.value?.sketchLayer?.graphics?.items[0]?.clone()
173
- if (graphic) {
174
- gisViewer.value?.sketchLayer.add(graphic)
175
- gisViewer.value?.sketchLayer.remove(graphic)
176
- }
177
- }
178
-
179
- const drawDrawings = (title: string, drawings: any) => {
180
- const map = gisViewer.value.map // Assuming your map instance is accessible through gisViewer
181
- if (!map) {
182
- console.error('Map not initialized')
183
- return
184
- }
185
-
186
- // Check if a layer with the same title already exists
187
- let existingLayer = map.layers.find((layer: any) => layer.title === title) as GraphicsLayer | undefined
188
-
189
- if (existingLayer) {
190
- // Clear existing drawings in the layer
191
- existingLayer.removeAll()
192
- }
193
- else {
194
- map.layers.destroyAll()
195
- // Create a new GraphicsLayer if one does not already exist
196
- existingLayer = new GraphicsLayer({ title })
197
- map.add(existingLayer)
198
- }
199
-
200
- // Iterate over the drawings array and create Graphics for each one
201
- drawings.forEach((drawing: any) => {
202
- const graphic = new Graphic({
203
- geometry: drawing.geometry, // Use the geometry from the drawing
204
- symbol: drawing.symbol, // Use the symbol from the drawing
205
- })
206
-
207
- // Add the graphic to the existing (or newly created) graphicsLayer
208
- existingLayer.add(graphic)
209
- })
210
- }
211
-
212
- const loadSketchGraphics = (drawings: any[]) => {
213
- if (gisViewer.value.sketchLayer) {
214
- clearSketch()
215
- drawings.forEach((drawing: any) => {
216
- const graphic = new Graphic({
217
- geometry: drawing.geometry, // Use the geometry from the drawing
218
- symbol: drawing.symbol, // Use the symbol from the drawing
219
- })
220
- gisViewer.value?.sketchLayer.add(graphic)
221
- })
222
- const graphics = gisViewer.value.sketchLayer.graphics.items
223
- if (graphics.length > 0) {
224
- const lastGraphic = graphics[graphics.length - 1]
225
- if (lastGraphic.geometry) {
226
- const zoom = gisViewer.value?.view?.zoom
227
- // Get the center of the graphic's geometry (or use its centroid if it's not a point)
228
- const targetGeometry = lastGraphic.geometry
229
- const targetPoint = targetGeometry.type === 'point' ? targetGeometry : targetGeometry.extent.center
230
-
231
- const screenPoint = gisViewer.value?.view.toScreen(targetPoint)
232
-
233
- const offsetScreenPoint = {
234
- x: screenPoint.x,
235
- y: screenPoint.y + 250, // Scroll 250 pixels up to show graphic above the planner
236
- }
237
-
238
- // Convert the offset screen coordinates back to map coordinates
239
- const offsetMapPoint = gisViewer.value?.view.toMap(offsetScreenPoint)
240
-
241
- // Use goTo with the offset map point as the new center
242
- gisViewer.value?.view.goTo({
243
- center: offsetMapPoint,
244
- zoom: zoom || ZOOM,
245
- }).catch((error: any) => {
246
- console.error('Error going to the offset point:', error)
247
- })
248
- }
249
- }
250
- else {
251
- console.warn('No graphics available in the sketch layer.')
252
- }
253
- }
254
- }
255
-
256
- const initializeViewer = async (containerId: string, mapProperties: any) => {
257
- const { basemap, zoom, center, ground, basemap_opacity, ground_opacity } = mapProperties
258
-
259
- // Create a new map with the basemap from the recordsResponse
260
- const map = new Map({
261
- basemap: basemap || BASEMAP, // Use the response basemap, or fallback to default
262
- })
263
-
264
- // Set basemap opacity
265
- if (basemap_opacity !== undefined) {
266
- map.layers.forEach((layer) => {
267
- // FIXME: strange value that we have no in types
268
- // @ts-expect-error strange value that we have no in types
269
- if (layer.type === 'basemap') {
270
- layer.opacity = basemap_opacity // Set the opacity of the basemap
271
- }
272
- })
273
- }
274
-
275
- // Set ground (elevation layer)
276
- if (ground) {
277
- map.ground = {
278
- // @ts-expect-error JS stuff
279
- layers: [{ id: 'world-elevation', opacity: ground_opacity || 1 }],
280
- }
281
- }
282
-
283
- gisViewer.value.map = map
284
-
285
- // Convert the center from string format "[longitude, latitude]" to an array
286
- const parsedCenter = center ? JSON.parse(center) : [-118.805, 34.027] // Default center if none provided
287
-
288
- // Create a new MapView with the map, center, and zoom from the recordsResponse
289
- const view = new MapView({
290
- map,
291
- container: containerId,
292
- center: parsedCenter, // Use the center from the response
293
- zoom: zoom || ZOOM, // Use the zoom level from the response, or fallback to default
294
- })
295
-
296
- gisViewer.value.view = view
297
-
298
- const loadWidgets = (gisViewer: GisComposable, view: MapView, widgets: object) => {
299
- Object.entries(widgets).forEach(([key, enabled]) => {
300
- if (!enabled)
301
- return
302
-
303
- switch (key) {
304
- case GIS_VIEWER_WIDGETS.LAYER_LIST: {
305
- const layerList = new LayerList({ view })
306
- gisViewer.widgets[GIS_VIEWER_WIDGETS.LAYER_LIST] = layerList
307
- view.ui.add(layerList, 'top-right')
308
- break
309
- }
310
-
311
- case GIS_VIEWER_WIDGETS.SKETCH: {
312
- const sketchWidget = new SketchWidget({
313
- view,
314
- visible: false,
315
- creationMode: 'update',
316
- })
317
-
318
- sketchWidget.viewModel.polylineSymbol = new SimpleLineSymbol({
319
- type: 'simple-line',
320
- color: [0, 0, 0, 1],
321
- width: 2,
322
- style: 'solid',
323
- })
324
-
325
- sketchWidget.viewModel.polygonSymbol = new SimpleFillSymbol({
326
- type: 'simple-fill',
327
- color: [0, 0, 0, 0.4],
328
- outline: {
329
- color: [0, 0, 0, 0.9],
330
- width: 2,
331
- },
332
- })
333
-
334
- gisViewer.widgets[GIS_VIEWER_WIDGETS.SKETCH] = sketchWidget
335
- view.ui.add(sketchWidget, {
336
- position: 'top-left',
337
- index: 0,
338
- })
339
- break
340
- }
341
-
342
- // Add more widgets as needed
343
- }
344
- })
345
- }
346
-
347
- // Load widgets based on the provided config
348
- await view.when(() => {
349
- loadWidgets(gisViewer.value, view, widgets)
350
- })
351
-
352
- // Clean up the view and its resources on unmount
353
- onUnmounted(() => {
354
- if (view) {
355
- view.destroy()
356
- }
357
- })
358
- }
359
-
360
- const records = ref<TableRecords | null>(null)
361
-
362
- watch(
363
- () => context.value.project?.id,
364
- async projectId => projectId && (records.value = await fetchMapProperties(projectId)),
365
- { immediate: true },
366
- )
367
-
368
- watch(
369
- () => [records.value, container.value] as const,
370
- async ([records, newContainer]) => {
371
- if (!newContainer)
372
- return
373
-
374
- if (records?.properties?.records && records?.properties?.records?.length > 0) {
375
- const mapProperties = records?.properties.records[0] // Extract map properties
376
-
377
- // Initialize the viewer with map properties
378
- await initializeViewer(newContainer, mapProperties)
379
- }
380
- },
381
- { immediate: true },
382
- )
383
-
384
- return {
385
- toggleWidget,
386
- drawDrawings,
387
- getSketch,
388
- clearSketch,
389
- setSketchColor,
390
- loadSketchGraphics,
391
- gisViewer,
392
- container,
393
- }
394
- }
395
-
396
- function createTableQueryPayload(projectId: string) {
397
- return {
398
- tables: [
399
- {
400
- name: 'CFFA_GIS_PROPERTIES',
401
- project: projectId,
402
- as: 'properties',
403
- columns: [
404
- 'token',
405
- 'basemap',
406
- 'basemap_opacity',
407
- 'ground',
408
- 'ground_opacity',
409
- 'zoom',
410
- 'center',
411
- ].map(name => ({ name })),
412
- },
413
- ],
414
- }
415
- }