@operato/popup 8.0.0-alpha.51 → 8.0.0-beta.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/CHANGELOG.md +17 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/.editorconfig +0 -29
- package/.storybook/main.js +0 -3
- package/.storybook/preview.js +0 -52
- package/.storybook/server.mjs +0 -8
- package/src/index.ts +0 -7
- package/src/open-popup.ts +0 -166
- package/src/ox-floating-overlay.ts +0 -618
- package/src/ox-popup-list.ts +0 -577
- package/src/ox-popup-menu.ts +0 -247
- package/src/ox-popup-menuitem.ts +0 -187
- package/src/ox-popup.ts +0 -400
- package/src/ox-prompt.ts +0 -549
- package/src/position-converter.ts +0 -37
- package/stories/open-popup.stories.ts +0 -104
- package/stories/ox-popup-list-sortable.stories.ts +0 -215
- package/stories/ox-popup-list.stories.ts +0 -121
- package/stories/ox-popup-menu.stories.ts +0 -188
- package/stories/ox-popup.stories.ts +0 -79
- package/stories/ox-prompt-icon.stories.ts +0 -87
- package/stories/ox-prompt-normal.stories.ts +0 -80
- package/stories/ox-prompt.stories.ts +0 -82
- package/tsconfig.json +0 -25
- package/web-dev-server.config.mjs +0 -27
- package/web-test-runner.config.mjs +0 -41
package/src/open-popup.ts
DELETED
@@ -1,166 +0,0 @@
|
|
1
|
-
import './ox-floating-overlay.js'
|
2
|
-
|
3
|
-
import { html, render, TemplateResult } from 'lit'
|
4
|
-
|
5
|
-
import { OxFloatingOverlay } from './ox-floating-overlay.js'
|
6
|
-
|
7
|
-
/**
|
8
|
-
* Options for popup
|
9
|
-
*
|
10
|
-
* @typedef {Object} PopupOptions
|
11
|
-
* @property {String} [title] - popup title
|
12
|
-
* @property {'center' | 'next' | 'edge'} [hovering] - hovering position (default: 'center'). 'edge' : edge of the HEADERBAR, 'next' : next of the clicked position.
|
13
|
-
* @property {'large' | 'medium' | small'} [size] - popup size
|
14
|
-
* @property {Boolean} [closable] - set whether the close 'X' button is shown on top-right most position (default true)
|
15
|
-
* @property {Boolean} [escapable] - set whether the close popup with 'ESC' key (default true)
|
16
|
-
* @property {Boolean} [backdrop] - set whether to do background masking around the pop-up. If true, it becomes modal (default true)
|
17
|
-
* @property {Boolean} [movable] - set whether to be able to movable by the gesture dragging on header once the hovering option is 'center'
|
18
|
-
* @property {String} [help] - inline help link
|
19
|
-
*/
|
20
|
-
export type PopupOptions = {
|
21
|
-
title?: string
|
22
|
-
hovering?: 'center' | 'next' | 'edge'
|
23
|
-
size?: 'large' | 'medium' | 'small'
|
24
|
-
closable?: boolean
|
25
|
-
escapable?: boolean
|
26
|
-
backdrop?: boolean
|
27
|
-
movable?: boolean
|
28
|
-
help?: string
|
29
|
-
search?: {
|
30
|
-
value?: string
|
31
|
-
handler?: (closure: any, value: string) => void
|
32
|
-
placeholder?: string
|
33
|
-
autofocus?: boolean
|
34
|
-
}
|
35
|
-
filter?: {
|
36
|
-
handler?: (closure: any) => void
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
/**
|
41
|
-
* Popup handle object that will be returned openPopup
|
42
|
-
*
|
43
|
-
* @typedef {Object} PopupHandle
|
44
|
-
* @property {String} [name] - popup instance name
|
45
|
-
* @property {Function} [close] - call this function to close the popup.
|
46
|
-
* @property {Boolean} [closed] - state telling whether the popup is closed or not.
|
47
|
-
* @property {Function} [onclosed] - set callback function on close. It will be called when the popup about to close.
|
48
|
-
*/
|
49
|
-
export type PopupHandle = {
|
50
|
-
name: string
|
51
|
-
close: () => void
|
52
|
-
closed: boolean
|
53
|
-
onclosed?: () => void
|
54
|
-
}
|
55
|
-
|
56
|
-
/*
|
57
|
-
* popup handling
|
58
|
-
*
|
59
|
-
* popup은 overlay의 특별한 형태이다.
|
60
|
-
* popup은 open될 때, viewpart를 append 하며, close 될 때 viewpart를 remove 한다.
|
61
|
-
* - name: '$popup-${popupSequence}'
|
62
|
-
* - position: VIEWPART_POSITION_HEADERBAR
|
63
|
-
* - hovering: 'center' | 'next' | 'edge'
|
64
|
-
*/
|
65
|
-
var popupSequence = 0
|
66
|
-
|
67
|
-
/**
|
68
|
-
* default openPopup implementation for operato application environment
|
69
|
-
*
|
70
|
-
* @param {*} template html template to be rendered inside the popup
|
71
|
-
* @param {PopupOptions} options
|
72
|
-
* @returns popup handle object. This object is used to close the popup.
|
73
|
-
*/
|
74
|
-
function defaultOpenPopup(template: TemplateResult, options: PopupOptions = {}): PopupHandle {
|
75
|
-
const {
|
76
|
-
title,
|
77
|
-
size = 'large',
|
78
|
-
closable = false,
|
79
|
-
escapable = false,
|
80
|
-
help,
|
81
|
-
hovering,
|
82
|
-
backdrop,
|
83
|
-
movable = false,
|
84
|
-
search,
|
85
|
-
filter
|
86
|
-
} = options
|
87
|
-
const name = `$popup-${popupSequence++}`
|
88
|
-
|
89
|
-
render(
|
90
|
-
html`
|
91
|
-
<ox-floating-overlay
|
92
|
-
id=${name}
|
93
|
-
name=${name}
|
94
|
-
.backdrop=${backdrop}
|
95
|
-
direction="down"
|
96
|
-
.hovering=${hovering}
|
97
|
-
.title=${title || ''}
|
98
|
-
.help=${help}
|
99
|
-
.size=${size}
|
100
|
-
.closable=${closable}
|
101
|
-
.historical=${false}
|
102
|
-
.movable=${movable}
|
103
|
-
.search=${search}
|
104
|
-
.filter=${filter}
|
105
|
-
>${template}</ox-floating-overlay
|
106
|
-
>
|
107
|
-
`,
|
108
|
-
document.body
|
109
|
-
)
|
110
|
-
|
111
|
-
requestAnimationFrame(() => {
|
112
|
-
dispatchEvent(new Event('resize'))
|
113
|
-
})
|
114
|
-
|
115
|
-
const popupHandle = {
|
116
|
-
name,
|
117
|
-
close: () => {
|
118
|
-
const popup = document.body.querySelector(`#${name}`) as OxFloatingOverlay
|
119
|
-
popup?.close()
|
120
|
-
popupHandle.onclosed && popupHandle.onclosed()
|
121
|
-
},
|
122
|
-
closed: false
|
123
|
-
} as PopupHandle
|
124
|
-
|
125
|
-
return popupHandle
|
126
|
-
}
|
127
|
-
|
128
|
-
var openPopupImpl: (template: TemplateResult, options: PopupOptions) => PopupHandle = defaultOpenPopup
|
129
|
-
|
130
|
-
/**
|
131
|
-
* replace default openPopup implementation
|
132
|
-
*
|
133
|
-
* @param {(template: TemplateResult, options: PopupOptions) => PopupHandle} implementation
|
134
|
-
*/
|
135
|
-
export function setOpenPopupImplementation(
|
136
|
-
implementation: (template: TemplateResult, options: PopupOptions) => PopupHandle
|
137
|
-
) {
|
138
|
-
openPopupImpl = implementation
|
139
|
-
}
|
140
|
-
|
141
|
-
/**
|
142
|
-
* open popup out of operato application environment
|
143
|
-
*
|
144
|
-
* @param {*} template html template to be rendered inside the popup
|
145
|
-
* @param {PopupOptions} options
|
146
|
-
* @returns popup handle object. This object is used to close the popup.
|
147
|
-
*/
|
148
|
-
export const openPopup = (template: TemplateResult, options: PopupOptions = {}): PopupHandle => {
|
149
|
-
return openPopupImpl(template, options)
|
150
|
-
}
|
151
|
-
|
152
|
-
/**
|
153
|
-
* open popup out of operato application environment
|
154
|
-
*
|
155
|
-
* @param {*} template html template to be rendered inside the popup
|
156
|
-
* @param {PopupOptions} options
|
157
|
-
* @returns popup handle object. This object is used to close the popup.
|
158
|
-
*/
|
159
|
-
export const closePopup = (element: HTMLElement): void => {
|
160
|
-
element.dispatchEvent(
|
161
|
-
new CustomEvent('close-overlay', {
|
162
|
-
bubbles: true,
|
163
|
-
composed: true
|
164
|
-
})
|
165
|
-
)
|
166
|
-
}
|