@operato/popup 7.0.0-rc.8 β†’ 7.0.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.
Files changed (69) hide show
  1. package/.storybook/preview.js +52 -0
  2. package/CHANGELOG.md +46 -0
  3. package/dist/src/open-popup.js +1 -1
  4. package/dist/src/open-popup.js.map +1 -1
  5. package/dist/src/ox-floating-overlay.js +210 -213
  6. package/dist/src/ox-floating-overlay.js.map +1 -1
  7. package/dist/src/ox-popup-list.js +120 -122
  8. package/dist/src/ox-popup-list.js.map +1 -1
  9. package/dist/src/ox-popup-menu.js +68 -69
  10. package/dist/src/ox-popup-menu.js.map +1 -1
  11. package/dist/src/ox-popup-menuitem.js +44 -45
  12. package/dist/src/ox-popup-menuitem.js.map +1 -1
  13. package/dist/src/ox-popup.js +27 -27
  14. package/dist/src/ox-popup.js.map +1 -1
  15. package/dist/src/ox-prompt.js +99 -100
  16. package/dist/src/ox-prompt.js.map +1 -1
  17. package/dist/stories/open-popup.stories.d.ts +0 -5
  18. package/dist/stories/open-popup.stories.js +2 -7
  19. package/dist/stories/open-popup.stories.js.map +1 -1
  20. package/dist/stories/ox-popup-list-sortable.stories.d.ts +0 -5
  21. package/dist/stories/ox-popup-list-sortable.stories.js +3 -8
  22. package/dist/stories/ox-popup-list-sortable.stories.js.map +1 -1
  23. package/dist/stories/ox-popup-list.stories.d.ts +2 -3
  24. package/dist/stories/ox-popup-list.stories.js +14 -11
  25. package/dist/stories/ox-popup-list.stories.js.map +1 -1
  26. package/dist/stories/ox-popup-menu.stories.d.ts +1 -7
  27. package/dist/stories/ox-popup-menu.stories.js +2 -8
  28. package/dist/stories/ox-popup-menu.stories.js.map +1 -1
  29. package/dist/stories/ox-popup.stories.d.ts +1 -7
  30. package/dist/stories/ox-popup.stories.js +2 -8
  31. package/dist/stories/ox-popup.stories.js.map +1 -1
  32. package/dist/stories/ox-prompt-icon.stories.d.ts +0 -5
  33. package/dist/stories/ox-prompt-icon.stories.js +5 -15
  34. package/dist/stories/ox-prompt-icon.stories.js.map +1 -1
  35. package/dist/stories/ox-prompt-normal.stories.d.ts +2 -3
  36. package/dist/stories/ox-prompt-normal.stories.js +9 -10
  37. package/dist/stories/ox-prompt-normal.stories.js.map +1 -1
  38. package/dist/stories/ox-prompt.stories.d.ts +2 -3
  39. package/dist/stories/ox-prompt.stories.js +6 -9
  40. package/dist/stories/ox-prompt.stories.js.map +1 -1
  41. package/dist/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +5 -4
  43. package/src/ox-popup-menu.ts +1 -0
  44. package/src/ox-prompt.ts +1 -1
  45. package/stories/open-popup.stories.ts +2 -9
  46. package/stories/ox-popup-list-sortable.stories.ts +2 -8
  47. package/stories/ox-popup-list.stories.ts +14 -11
  48. package/stories/ox-popup-menu.stories.ts +3 -11
  49. package/stories/ox-popup.stories.ts +3 -11
  50. package/stories/ox-prompt-icon.stories.ts +4 -17
  51. package/stories/ox-prompt-normal.stories.ts +10 -11
  52. package/stories/ox-prompt.stories.ts +7 -11
  53. package/themes/app-theme.css +138 -0
  54. package/themes/calendar-theme.css +59 -0
  55. package/themes/dark.css +0 -100
  56. package/themes/grist-theme.css +45 -41
  57. package/themes/layout-theme.css +94 -0
  58. package/themes/light.css +3 -103
  59. package/themes/material-theme.css +23 -0
  60. package/themes/oops-theme.css +22 -0
  61. package/themes/report-theme.css +47 -0
  62. package/themes/spacing.css +7 -27
  63. package/themes/state-color.css +1 -1
  64. package/themes/tooltip-theme.css +11 -0
  65. package/tsconfig.json +2 -1
  66. package/themes/dark-hc.css +0 -151
  67. package/themes/dark-mc.css +0 -151
  68. package/themes/light-hc.css +0 -151
  69. package/themes/light-mc.css +0 -151
@@ -0,0 +1,52 @@
1
+ import { i18next } from '@operato/i18n'
2
+
3
+ export const globalTypes = {
4
+ locale: {
5
+ name: 'Locale',
6
+ description: 'Internationalization locale',
7
+ toolbar: {
8
+ icon: 'globe',
9
+ items: [
10
+ { value: 'en', right: 'πŸ‡ΊπŸ‡Έ', title: 'English' },
11
+ { value: 'ko', right: 'πŸ‡°πŸ‡·', title: 'ν•œκ΅­μ–΄' },
12
+ { value: 'zh', right: 'πŸ‡¨πŸ‡³', title: 'δΈ­ζ–‡' },
13
+ { value: 'ja', right: 'πŸ‡―πŸ‡΅', title: 'ζ—₯本θͺž' },
14
+ { value: 'ms', right: 'πŸ‡²πŸ‡Ύ', title: 'Bahasa Melayu' }
15
+ ],
16
+ showName: true
17
+ }
18
+ },
19
+ theme: {
20
+ name: 'Theme',
21
+ description: 'Global theme for components',
22
+ toolbar: {
23
+ icon: 'paintbrush',
24
+ items: [
25
+ { value: 'light', title: 'Light' },
26
+ { value: 'dark', title: 'Dark' }
27
+ ],
28
+ showName: true
29
+ }
30
+ }
31
+ }
32
+
33
+ export const decorators = [
34
+ (Story, context) => {
35
+ const { locale, theme } = context.globals
36
+
37
+ if (locale) {
38
+ i18next.changeLanguage(locale)
39
+ }
40
+
41
+ // Set the theme class for the document
42
+ if (theme === 'dark') {
43
+ document.documentElement.classList.add('dark')
44
+ document.documentElement.classList.remove('light')
45
+ } else {
46
+ document.documentElement.classList.add('light')
47
+ document.documentElement.classList.remove('dark')
48
+ }
49
+
50
+ return Story()
51
+ }
52
+ ]
package/CHANGELOG.md CHANGED
@@ -3,6 +3,52 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [7.0.0](https://github.com/hatiolab/operato/compare/v7.0.0-rc.13...v7.0.0) (2024-06-30)
7
+
8
+ **Note:** Version bump only for package @operato/popup
9
+
10
+
11
+
12
+
13
+
14
+ ## [7.0.0-rc.13](https://github.com/hatiolab/operato/compare/v7.0.0-rc.12...v7.0.0-rc.13) (2024-06-30)
15
+
16
+
17
+ ### :bug: Bug Fix
18
+
19
+ * storybook preview.js ([84d7682](https://github.com/hatiolab/operato/commit/84d7682af452554e8b0e83aa683bdc3726e264bb))
20
+ * storybook preview.js ([c2e4f7b](https://github.com/hatiolab/operato/commit/c2e4f7babc46067fef8c0d47481ee2351fe77917))
21
+ * storybook preview.js ([4c4b117](https://github.com/hatiolab/operato/commit/4c4b117b2a06ad9cc47c3f09badd3ee2cf57087a))
22
+ * storybook preview.js ([8ed7305](https://github.com/hatiolab/operato/commit/8ed73059fd5b03718dc44e7b984cd47f4316c7da))
23
+
24
+
25
+
26
+ ## [7.0.0-rc.11](https://github.com/hatiolab/operato/compare/v7.0.0-rc.10...v7.0.0-rc.11) (2024-06-29)
27
+
28
+
29
+ ### :bug: Bug Fix
30
+
31
+ * material design token ([bf70a97](https://github.com/hatiolab/operato/commit/bf70a9783aacfd6f58e945515d25120ace1ad1f3))
32
+
33
+
34
+
35
+ ## [7.0.0-rc.10](https://github.com/hatiolab/operato/compare/v7.0.0-rc.9...v7.0.0-rc.10) (2024-06-29)
36
+
37
+ **Note:** Version bump only for package @operato/popup
38
+
39
+
40
+
41
+
42
+
43
+ ## [7.0.0-rc.9](https://github.com/hatiolab/operato/compare/v7.0.0-rc.8...v7.0.0-rc.9) (2024-06-29)
44
+
45
+
46
+ ### :bug: Bug Fix
47
+
48
+ * ox-input-barcode style ([5f803bb](https://github.com/hatiolab/operato/commit/5f803bba90167c3a214998df3f860934b116d770))
49
+
50
+
51
+
6
52
  ## [7.0.0-rc.8](https://github.com/hatiolab/operato/compare/v7.0.0-rc.7...v7.0.0-rc.8) (2024-06-28)
7
53
 
8
54
  **Note:** Version bump only for package @operato/popup
@@ -45,7 +45,7 @@ function defaultOpenPopup(template, options = {}) {
45
45
  name,
46
46
  close: () => {
47
47
  const popup = document.body.querySelector(`#${name}`);
48
- popup === null || popup === void 0 ? void 0 : popup.close();
48
+ popup?.close();
49
49
  popupHandle.onclosed && popupHandle.onclosed();
50
50
  },
51
51
  closed: false
@@ -1 +1 @@
1
- {"version":3,"file":"open-popup.js","sourceRoot":"","sources":["../../src/open-popup.ts"],"names":[],"mappings":"AAAA,OAAO,0BAA0B,CAAA;AAEjC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAkB,MAAM,KAAK,CAAA;AAqDlD;;;;;;;;GAQG;AACH,IAAI,aAAa,GAAG,CAAC,CAAA;AAErB;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,QAAwB,EAAE,UAAwB,EAAE;IAC5E,MAAM,EACJ,KAAK,EACL,IAAI,GAAG,OAAO,EACd,QAAQ,GAAG,KAAK,EAChB,SAAS,GAAG,KAAK,EACjB,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,GAAG,KAAK,EACf,MAAM,EACN,MAAM,EACP,GAAG,OAAO,CAAA;IACX,MAAM,IAAI,GAAG,UAAU,aAAa,EAAE,EAAE,CAAA;IAExC,MAAM,CACJ,IAAI,CAAA;;aAEK,IAAI;eACF,IAAI;oBACC,QAAQ;;oBAER,QAAQ;iBACX,KAAK,IAAI,EAAE;gBACZ,IAAI;gBACJ,IAAI;oBACA,QAAQ;sBACN,KAAK;mBACR,OAAO;kBACR,MAAM;kBACN,MAAM;WACb,QAAQ;;KAEd,EACD,QAAQ,CAAC,IAAI,CACd,CAAA;IAED,qBAAqB,CAAC,GAAG,EAAE;QACzB,aAAa,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;IAEF,MAAM,WAAW,GAAG;QAClB,IAAI;QACJ,KAAK,EAAE,GAAG,EAAE;YACV,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,EAAE,CAAsB,CAAA;YAC1E,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,EAAE,CAAA;YACd,WAAW,CAAC,QAAQ,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAA;QAChD,CAAC;QACD,MAAM,EAAE,KAAK;KACC,CAAA;IAEhB,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,IAAI,aAAa,GAAqE,gBAAgB,CAAA;AAEtG;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,cAAgF;IAEhF,aAAa,GAAG,cAAc,CAAA;AAChC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,QAAwB,EAAE,UAAwB,EAAE,EAAe,EAAE;IAC7F,OAAO,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;AACzC,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAoB,EAAQ,EAAE;IACvD,OAAO,CAAC,aAAa,CACnB,IAAI,WAAW,CAAC,eAAe,EAAE;QAC/B,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf,CAAC,CACH,CAAA;AACH,CAAC,CAAA","sourcesContent":["import './ox-floating-overlay.js'\n\nimport { html, render, TemplateResult } from 'lit'\n\nimport { OxFloatingOverlay } from './ox-floating-overlay.js'\n\n/**\n * Options for popup\n *\n * @typedef {Object} PopupOptions\n * @property {String} [title] - popup title\n * @property {'center' | 'next' | 'edge'} [hovering] - hovering position (default: 'center'). 'edge' : edge of the HEADERBAR, 'next' : next of the clicked position.\n * @property {'large' | 'medium' | small'} [size] - popup size\n * @property {Boolean} [closable] - set whether the close 'X' button is shown on top-right most position (default true)\n * @property {Boolean} [escapable] - set whether the close popup with 'ESC' key (default true)\n * @property {Boolean} [backdrop] - set whether to do background masking around the pop-up. If true, it becomes modal (default true)\n * @property {Boolean} [movable] - set whether to be able to movable by the gesture dragging on header once the hovering option is 'center'\n * @property {String} [help] - inline help link\n */\nexport type PopupOptions = {\n title?: string\n hovering?: 'center' | 'next' | 'edge'\n size?: 'large' | 'medium' | 'small'\n closable?: boolean\n escapable?: boolean\n backdrop?: boolean\n movable?: boolean\n help?: string\n search?: {\n value?: string\n handler?: (closure: any, value: string) => void\n placeholder?: string\n autofocus?: boolean\n }\n filter?: {\n handler?: (closure: any) => void\n }\n}\n\n/**\n * Popup handle object that will be returned openPopup\n *\n * @typedef {Object} PopupHandle\n * @property {String} [name] - popup instance name\n * @property {Function} [close] - call this function to close the popup.\n * @property {Boolean} [closed] - state telling whether the popup is closed or not.\n * @property {Function} [onclosed] - set callback function on close. It will be called when the popup about to close.\n */\nexport type PopupHandle = {\n name: string\n close: () => void\n closed: boolean\n onclosed?: () => void\n}\n\n/*\n * popup handling\n *\n * popup은 overlay의 νŠΉλ³„ν•œ ν˜•νƒœμ΄λ‹€.\n * popup은 open될 λ•Œ, viewpartλ₯Ό append ν•˜λ©°, close 될 λ•Œ viewpartλ₯Ό remove ν•œλ‹€.\n * - name: '$popup-${popupSequence}'\n * - position: VIEWPART_POSITION_HEADERBAR\n * - hovering: 'center' | 'next' | 'edge'\n */\nvar popupSequence = 0\n\n/**\n * default openPopup implementation for operato application environment\n *\n * @param {*} template html template to be rendered inside the popup\n * @param {PopupOptions} options\n * @returns popup handle object. This object is used to close the popup.\n */\nfunction defaultOpenPopup(template: TemplateResult, options: PopupOptions = {}): PopupHandle {\n const {\n title,\n size = 'large',\n closable = false,\n escapable = false,\n help,\n hovering,\n backdrop,\n movable = false,\n search,\n filter\n } = options\n const name = `$popup-${popupSequence++}`\n\n render(\n html`\n <ox-floating-overlay\n id=${name}\n name=${name}\n .backdrop=${backdrop}\n direction=\"down\"\n .hovering=${hovering}\n .title=${title || ''}\n .help=${help}\n .size=${size}\n .closable=${closable}\n .historical=${false}\n .movable=${movable}\n .search=${search}\n .filter=${filter}\n >${template}</ox-floating-overlay\n >\n `,\n document.body\n )\n\n requestAnimationFrame(() => {\n dispatchEvent(new Event('resize'))\n })\n\n const popupHandle = {\n name,\n close: () => {\n const popup = document.body.querySelector(`#${name}`) as OxFloatingOverlay\n popup?.close()\n popupHandle.onclosed && popupHandle.onclosed()\n },\n closed: false\n } as PopupHandle\n\n return popupHandle\n}\n\nvar openPopupImpl: (template: TemplateResult, options: PopupOptions) => PopupHandle = defaultOpenPopup\n\n/**\n * replace default openPopup implementation\n *\n * @param {(template: TemplateResult, options: PopupOptions) => PopupHandle} implementation\n */\nexport function setOpenPopupImplementation(\n implementation: (template: TemplateResult, options: PopupOptions) => PopupHandle\n) {\n openPopupImpl = implementation\n}\n\n/**\n * open popup out of operato application environment\n *\n * @param {*} template html template to be rendered inside the popup\n * @param {PopupOptions} options\n * @returns popup handle object. This object is used to close the popup.\n */\nexport const openPopup = (template: TemplateResult, options: PopupOptions = {}): PopupHandle => {\n return openPopupImpl(template, options)\n}\n\n/**\n * open popup out of operato application environment\n *\n * @param {*} template html template to be rendered inside the popup\n * @param {PopupOptions} options\n * @returns popup handle object. This object is used to close the popup.\n */\nexport const closePopup = (element: HTMLElement): void => {\n element.dispatchEvent(\n new CustomEvent('close-overlay', {\n bubbles: true,\n composed: true\n })\n )\n}\n"]}
1
+ {"version":3,"file":"open-popup.js","sourceRoot":"","sources":["../../src/open-popup.ts"],"names":[],"mappings":"AAAA,OAAO,0BAA0B,CAAA;AAEjC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAkB,MAAM,KAAK,CAAA;AAqDlD;;;;;;;;GAQG;AACH,IAAI,aAAa,GAAG,CAAC,CAAA;AAErB;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,QAAwB,EAAE,UAAwB,EAAE;IAC5E,MAAM,EACJ,KAAK,EACL,IAAI,GAAG,OAAO,EACd,QAAQ,GAAG,KAAK,EAChB,SAAS,GAAG,KAAK,EACjB,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,OAAO,GAAG,KAAK,EACf,MAAM,EACN,MAAM,EACP,GAAG,OAAO,CAAA;IACX,MAAM,IAAI,GAAG,UAAU,aAAa,EAAE,EAAE,CAAA;IAExC,MAAM,CACJ,IAAI,CAAA;;aAEK,IAAI;eACF,IAAI;oBACC,QAAQ;;oBAER,QAAQ;iBACX,KAAK,IAAI,EAAE;gBACZ,IAAI;gBACJ,IAAI;oBACA,QAAQ;sBACN,KAAK;mBACR,OAAO;kBACR,MAAM;kBACN,MAAM;WACb,QAAQ;;KAEd,EACD,QAAQ,CAAC,IAAI,CACd,CAAA;IAED,qBAAqB,CAAC,GAAG,EAAE;QACzB,aAAa,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;IAEF,MAAM,WAAW,GAAG;QAClB,IAAI;QACJ,KAAK,EAAE,GAAG,EAAE;YACV,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,EAAE,CAAsB,CAAA;YAC1E,KAAK,EAAE,KAAK,EAAE,CAAA;YACd,WAAW,CAAC,QAAQ,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAA;QAChD,CAAC;QACD,MAAM,EAAE,KAAK;KACC,CAAA;IAEhB,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,IAAI,aAAa,GAAqE,gBAAgB,CAAA;AAEtG;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,cAAgF;IAEhF,aAAa,GAAG,cAAc,CAAA;AAChC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,QAAwB,EAAE,UAAwB,EAAE,EAAe,EAAE;IAC7F,OAAO,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;AACzC,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAoB,EAAQ,EAAE;IACvD,OAAO,CAAC,aAAa,CACnB,IAAI,WAAW,CAAC,eAAe,EAAE;QAC/B,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf,CAAC,CACH,CAAA;AACH,CAAC,CAAA","sourcesContent":["import './ox-floating-overlay.js'\n\nimport { html, render, TemplateResult } from 'lit'\n\nimport { OxFloatingOverlay } from './ox-floating-overlay.js'\n\n/**\n * Options for popup\n *\n * @typedef {Object} PopupOptions\n * @property {String} [title] - popup title\n * @property {'center' | 'next' | 'edge'} [hovering] - hovering position (default: 'center'). 'edge' : edge of the HEADERBAR, 'next' : next of the clicked position.\n * @property {'large' | 'medium' | small'} [size] - popup size\n * @property {Boolean} [closable] - set whether the close 'X' button is shown on top-right most position (default true)\n * @property {Boolean} [escapable] - set whether the close popup with 'ESC' key (default true)\n * @property {Boolean} [backdrop] - set whether to do background masking around the pop-up. If true, it becomes modal (default true)\n * @property {Boolean} [movable] - set whether to be able to movable by the gesture dragging on header once the hovering option is 'center'\n * @property {String} [help] - inline help link\n */\nexport type PopupOptions = {\n title?: string\n hovering?: 'center' | 'next' | 'edge'\n size?: 'large' | 'medium' | 'small'\n closable?: boolean\n escapable?: boolean\n backdrop?: boolean\n movable?: boolean\n help?: string\n search?: {\n value?: string\n handler?: (closure: any, value: string) => void\n placeholder?: string\n autofocus?: boolean\n }\n filter?: {\n handler?: (closure: any) => void\n }\n}\n\n/**\n * Popup handle object that will be returned openPopup\n *\n * @typedef {Object} PopupHandle\n * @property {String} [name] - popup instance name\n * @property {Function} [close] - call this function to close the popup.\n * @property {Boolean} [closed] - state telling whether the popup is closed or not.\n * @property {Function} [onclosed] - set callback function on close. It will be called when the popup about to close.\n */\nexport type PopupHandle = {\n name: string\n close: () => void\n closed: boolean\n onclosed?: () => void\n}\n\n/*\n * popup handling\n *\n * popup은 overlay의 νŠΉλ³„ν•œ ν˜•νƒœμ΄λ‹€.\n * popup은 open될 λ•Œ, viewpartλ₯Ό append ν•˜λ©°, close 될 λ•Œ viewpartλ₯Ό remove ν•œλ‹€.\n * - name: '$popup-${popupSequence}'\n * - position: VIEWPART_POSITION_HEADERBAR\n * - hovering: 'center' | 'next' | 'edge'\n */\nvar popupSequence = 0\n\n/**\n * default openPopup implementation for operato application environment\n *\n * @param {*} template html template to be rendered inside the popup\n * @param {PopupOptions} options\n * @returns popup handle object. This object is used to close the popup.\n */\nfunction defaultOpenPopup(template: TemplateResult, options: PopupOptions = {}): PopupHandle {\n const {\n title,\n size = 'large',\n closable = false,\n escapable = false,\n help,\n hovering,\n backdrop,\n movable = false,\n search,\n filter\n } = options\n const name = `$popup-${popupSequence++}`\n\n render(\n html`\n <ox-floating-overlay\n id=${name}\n name=${name}\n .backdrop=${backdrop}\n direction=\"down\"\n .hovering=${hovering}\n .title=${title || ''}\n .help=${help}\n .size=${size}\n .closable=${closable}\n .historical=${false}\n .movable=${movable}\n .search=${search}\n .filter=${filter}\n >${template}</ox-floating-overlay\n >\n `,\n document.body\n )\n\n requestAnimationFrame(() => {\n dispatchEvent(new Event('resize'))\n })\n\n const popupHandle = {\n name,\n close: () => {\n const popup = document.body.querySelector(`#${name}`) as OxFloatingOverlay\n popup?.close()\n popupHandle.onclosed && popupHandle.onclosed()\n },\n closed: false\n } as PopupHandle\n\n return popupHandle\n}\n\nvar openPopupImpl: (template: TemplateResult, options: PopupOptions) => PopupHandle = defaultOpenPopup\n\n/**\n * replace default openPopup implementation\n *\n * @param {(template: TemplateResult, options: PopupOptions) => PopupHandle} implementation\n */\nexport function setOpenPopupImplementation(\n implementation: (template: TemplateResult, options: PopupOptions) => PopupHandle\n) {\n openPopupImpl = implementation\n}\n\n/**\n * open popup out of operato application environment\n *\n * @param {*} template html template to be rendered inside the popup\n * @param {PopupOptions} options\n * @returns popup handle object. This object is used to close the popup.\n */\nexport const openPopup = (template: TemplateResult, options: PopupOptions = {}): PopupHandle => {\n return openPopupImpl(template, options)\n}\n\n/**\n * open popup out of operato application environment\n *\n * @param {*} template html template to be rendered inside the popup\n * @param {PopupOptions} options\n * @returns popup handle object. This object is used to close the popup.\n */\nexport const closePopup = (element: HTMLElement): void => {\n element.dispatchEvent(\n new CustomEvent('close-overlay', {\n bubbles: true,\n composed: true\n })\n )\n}\n"]}
@@ -7,14 +7,13 @@ import { ifDefined } from 'lit/directives/if-defined.js';
7
7
  import { ScrollbarStyles } from '@operato/styles';
8
8
  import { isHandheldDevice } from '@operato/utils';
9
9
  function getPoint(e) {
10
- var _a;
11
10
  if (e.button == 0) {
12
11
  return {
13
12
  x: e.clientX,
14
13
  y: e.clientY
15
14
  };
16
15
  }
17
- else if (((_a = e.touches) === null || _a === void 0 ? void 0 : _a.length) == 1) {
16
+ else if (e.touches?.length == 1) {
18
17
  const touch = e.touches[0];
19
18
  return {
20
19
  x: touch.clientX,
@@ -61,215 +60,9 @@ let OxFloatingOverlay = class OxFloatingOverlay extends LitElement {
61
60
  this.dragEndHandler = this.onDragEnd.bind(this);
62
61
  this.dragMoveHandler = this.onDragMove.bind(this);
63
62
  }
64
- render() {
65
- const direction = this.hovering == 'center' ? undefined : this.direction;
66
- const { value = '', handler: searchHandler, placeholder = '', autofocus = true } = this.search || {};
67
- const { handler: filterHandler } = this.filter || {};
68
- const searchable = typeof searchHandler == 'function';
69
- const filterable = typeof filterHandler == 'function';
70
- return html `
71
- ${Boolean(this.backdrop)
72
- ? html `
73
- <div
74
- id="backdrop"
75
- ?hidden=${!this.backdrop}
76
- @click=${(e) => this.onClose(e, true /* escape */)}
77
- ></div>
78
- `
79
- : html ``}
80
-
81
- <div
82
- overlayed
83
- hovering=${this.hovering || 'center'}
84
- direction=${ifDefined(direction)}
85
- size=${this.size || 'medium'}
86
- @close-overlay=${(e) => {
87
- e.stopPropagation();
88
- this.onClose(e);
89
- }}
90
- @transitionstart=${(e) => {
91
- /* to hide scrollbar during transition */
92
- ;
93
- e.target.removeAttribute('settled');
94
- }}
95
- @transitionend=${(e) => {
96
- ;
97
- e.target.setAttribute('settled', '');
98
- }}
99
- @click=${(e) => {
100
- if (this.backdrop && e.target === this.content) {
101
- this.onClose(e, true /* escape */);
102
- }
103
- }}
104
- >
105
- <div
106
- header
107
- @mousedown=${this.onDragStart.bind(this)}
108
- @touchstart=${this.onDragStart.bind(this)}
109
- draggable="false"
110
- >
111
- <md-icon @click=${(e) => this.onClose(e)} ?closable=${this.closable} historyback>arrow_back</md-icon>
112
- ${this.movable ? html `<md-icon>drag_indicator</md-icon>` : html ``}
113
- <slot name="header">
114
- ${this.title || this.closable
115
- ? html `
116
- <h1>
117
- ${this.title || ''}&nbsp;${this.help
118
- ? html `<ox-help-icon .topic=${this.help}></ox-help-icon>`
119
- : html ``}
120
- </h1>
121
- `
122
- : html ``}
123
- ${searchable || filterable
124
- ? html `
125
- <div search>
126
- ${searchable
127
- ? html ` <ox-input-search
128
- .placeholder=${placeholder}
129
- .value=${value || ''}
130
- ?autofocus=${autofocus}
131
- @change=${(e) => {
132
- searchHandler(this.firstElementChild, e.target.value);
133
- }}
134
- ></ox-input-search>`
135
- : html ``}
136
- ${this.help && searchable ? html `<ox-help-icon .topic=${this.help}></ox-help-icon>` : html ``}
137
- ${filterable
138
- ? html `<md-icon @click=${(e) => filterHandler(this.firstElementChild)}>tune</md-icon>`
139
- : html ``}
140
- </div>
141
- `
142
- : html ``}
143
- ${this.help && !searchable && !this.title /* help only */
144
- ? html `<ox-help-icon .topic=${this.help}></ox-help-icon>`
145
- : html ``}
146
- </slot>
147
- <md-icon @click=${(e) => this.onClose(e)} ?closable=${this.closable} close>close</md-icon>
148
- </div>
149
-
150
- <div content>
151
- <slot> </slot>
152
- </div>
153
- </div>
154
- `;
155
- }
156
- updated(changes) {
157
- if (changes.has('templateProperties') && this.templateProperties) {
158
- var template = this.firstElementChild;
159
- if (template) {
160
- for (let prop in this.templateProperties) {
161
- //@ts-ignore
162
- template[prop] = this.templateProperties[prop];
163
- }
164
- }
165
- }
166
- }
167
- firstUpdated() {
168
- if (this.zIndex) {
169
- this.style.setProperty('--z-index', String(this.zIndex));
170
- }
171
- requestAnimationFrame(() => {
172
- var _a;
173
- /* transition(animation) 효과λ₯Ό μœ„ν•΄ 'opened' 속성을 λ³€ν™”μ‹œν‚¨λ‹€. */
174
- (_a = this.overlayed) === null || _a === void 0 ? void 0 : _a.setAttribute('opened', 'true');
175
- });
176
- }
177
- connectedCallback() {
178
- super.connectedCallback();
179
- this.movable = this.movable && !isHandheldDevice();
180
- if (this.movable) {
181
- document.addEventListener('mouseup', this.dragEndHandler);
182
- document.addEventListener('touchend', this.dragEndHandler);
183
- document.addEventListener('touchcancel', this.dragEndHandler);
184
- document.addEventListener('mousemove', this.dragMoveHandler);
185
- document.addEventListener('touchmove', this.dragMoveHandler);
186
- }
187
- }
188
- disconnectedCallback() {
189
- document.dispatchEvent(new CustomEvent('overlay-closed', {
190
- detail: this.name
191
- }));
192
- if (this.movable) {
193
- document.removeEventListener('mouseup', this.dragEndHandler);
194
- document.removeEventListener('touchend', this.dragEndHandler);
195
- document.removeEventListener('touchcancel', this.dragEndHandler);
196
- document.removeEventListener('mousemove', this.dragMoveHandler);
197
- document.removeEventListener('touchmove', this.dragMoveHandler);
198
- }
199
- super.disconnectedCallback();
200
- }
201
- onDragStart(e) {
202
- if (!this.movable) {
203
- return;
204
- }
205
- const point = getPoint(e);
206
- if (point) {
207
- this.dragStart = point;
208
- e.stopPropagation();
209
- return false;
210
- }
211
- }
212
- onDragMove(e) {
213
- if (!this.movable || !this.dragStart) {
214
- return false;
215
- }
216
- const point = getPoint(e);
217
- if (!point) {
218
- return false;
219
- }
220
- e.stopPropagation();
221
- e.preventDefault();
222
- const dragStart = point;
223
- var { x, y } = point;
224
- x -= this.dragStart.x;
225
- y -= this.dragStart.y;
226
- this.dragStart = dragStart;
227
- const overlayed = this.overlayed;
228
- var boundingRect = overlayed.getBoundingClientRect();
229
- overlayed.style.left =
230
- Math.min(document.body.offsetWidth - 40, Math.max(40 - overlayed.offsetWidth, boundingRect.left + x)) + 'px';
231
- overlayed.style.top = Math.min(document.body.offsetHeight - 40, Math.max(0, boundingRect.top + y)) + 'px';
232
- overlayed.style.transform = 'initial';
233
- return false;
234
- }
235
- onDragEnd(e) {
236
- if (this.movable && this.dragStart) {
237
- e.stopPropagation();
238
- e.preventDefault();
239
- delete this.dragStart;
240
- }
241
- }
242
- /**
243
- * A method that closes the overlay by removing it from its parent node in the DOM.
244
- * When called, this method removes the overlay element, effectively hiding it from the user interface.
245
- */
246
- close() {
247
- var _a;
248
- (_a = this.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this);
249
- }
250
- onClose(e, escape) {
251
- e.stopPropagation();
252
- /* ν˜„μž¬ overlay stateλ₯Ό ν™•μΈν•΄μ„œ, μžμ‹ μ΄ ν¬ν•¨ν•˜κ³  μžˆλŠ” ν…œν”Œλ¦ΏμΈ κ²½μš°μ— history.back() ν•œλ‹€. */
253
- if (this.historical) {
254
- var state = history.state;
255
- var overlay = (state || {}).overlay;
256
- if (!overlay || overlay.name !== this.name) {
257
- return;
258
- }
259
- /* Backdrop click κ²½μš°λŠ” escape μ‹œλ„λΌκ³  μ •μ˜ν•œλ‹€. overlay 속성이 escapable이 μ•„λ‹Œ κ²½μš°μ—λŠ” λ™μž‘ν•˜μ§€ μ•ŠλŠ”λ‹€. */
260
- if (escape && !overlay.escapable) {
261
- return true;
262
- }
263
- history.back();
264
- }
265
- else {
266
- this.close();
267
- }
268
- }
269
- };
270
- OxFloatingOverlay.styles = [
271
- ScrollbarStyles,
272
- css `
63
+ static { this.styles = [
64
+ ScrollbarStyles,
65
+ css `
273
66
  /* for layout style */
274
67
  :host {
275
68
  position: relative;
@@ -418,7 +211,7 @@ OxFloatingOverlay.styles = [
418
211
  }
419
212
  }
420
213
  `,
421
- css `
214
+ css `
422
215
  /* for header style */
423
216
  [header] {
424
217
  display: flex;
@@ -515,7 +308,211 @@ OxFloatingOverlay.styles = [
515
308
  }
516
309
  }
517
310
  `
518
- ];
311
+ ]; }
312
+ render() {
313
+ const direction = this.hovering == 'center' ? undefined : this.direction;
314
+ const { value = '', handler: searchHandler, placeholder = '', autofocus = true } = this.search || {};
315
+ const { handler: filterHandler } = this.filter || {};
316
+ const searchable = typeof searchHandler == 'function';
317
+ const filterable = typeof filterHandler == 'function';
318
+ return html `
319
+ ${Boolean(this.backdrop)
320
+ ? html `
321
+ <div
322
+ id="backdrop"
323
+ ?hidden=${!this.backdrop}
324
+ @click=${(e) => this.onClose(e, true /* escape */)}
325
+ ></div>
326
+ `
327
+ : html ``}
328
+
329
+ <div
330
+ overlayed
331
+ hovering=${this.hovering || 'center'}
332
+ direction=${ifDefined(direction)}
333
+ size=${this.size || 'medium'}
334
+ @close-overlay=${(e) => {
335
+ e.stopPropagation();
336
+ this.onClose(e);
337
+ }}
338
+ @transitionstart=${(e) => {
339
+ /* to hide scrollbar during transition */
340
+ ;
341
+ e.target.removeAttribute('settled');
342
+ }}
343
+ @transitionend=${(e) => {
344
+ ;
345
+ e.target.setAttribute('settled', '');
346
+ }}
347
+ @click=${(e) => {
348
+ if (this.backdrop && e.target === this.content) {
349
+ this.onClose(e, true /* escape */);
350
+ }
351
+ }}
352
+ >
353
+ <div
354
+ header
355
+ @mousedown=${this.onDragStart.bind(this)}
356
+ @touchstart=${this.onDragStart.bind(this)}
357
+ draggable="false"
358
+ >
359
+ <md-icon @click=${(e) => this.onClose(e)} ?closable=${this.closable} historyback>arrow_back</md-icon>
360
+ ${this.movable ? html `<md-icon>drag_indicator</md-icon>` : html ``}
361
+ <slot name="header">
362
+ ${this.title || this.closable
363
+ ? html `
364
+ <h1>
365
+ ${this.title || ''}&nbsp;${this.help
366
+ ? html `<ox-help-icon .topic=${this.help}></ox-help-icon>`
367
+ : html ``}
368
+ </h1>
369
+ `
370
+ : html ``}
371
+ ${searchable || filterable
372
+ ? html `
373
+ <div search>
374
+ ${searchable
375
+ ? html ` <ox-input-search
376
+ .placeholder=${placeholder}
377
+ .value=${value || ''}
378
+ ?autofocus=${autofocus}
379
+ @change=${(e) => {
380
+ searchHandler(this.firstElementChild, e.target.value);
381
+ }}
382
+ ></ox-input-search>`
383
+ : html ``}
384
+ ${this.help && searchable ? html `<ox-help-icon .topic=${this.help}></ox-help-icon>` : html ``}
385
+ ${filterable
386
+ ? html `<md-icon @click=${(e) => filterHandler(this.firstElementChild)}>tune</md-icon>`
387
+ : html ``}
388
+ </div>
389
+ `
390
+ : html ``}
391
+ ${this.help && !searchable && !this.title /* help only */
392
+ ? html `<ox-help-icon .topic=${this.help}></ox-help-icon>`
393
+ : html ``}
394
+ </slot>
395
+ <md-icon @click=${(e) => this.onClose(e)} ?closable=${this.closable} close>close</md-icon>
396
+ </div>
397
+
398
+ <div content>
399
+ <slot> </slot>
400
+ </div>
401
+ </div>
402
+ `;
403
+ }
404
+ updated(changes) {
405
+ if (changes.has('templateProperties') && this.templateProperties) {
406
+ var template = this.firstElementChild;
407
+ if (template) {
408
+ for (let prop in this.templateProperties) {
409
+ //@ts-ignore
410
+ template[prop] = this.templateProperties[prop];
411
+ }
412
+ }
413
+ }
414
+ }
415
+ firstUpdated() {
416
+ if (this.zIndex) {
417
+ this.style.setProperty('--z-index', String(this.zIndex));
418
+ }
419
+ requestAnimationFrame(() => {
420
+ /* transition(animation) 효과λ₯Ό μœ„ν•΄ 'opened' 속성을 λ³€ν™”μ‹œν‚¨λ‹€. */
421
+ this.overlayed?.setAttribute('opened', 'true');
422
+ });
423
+ }
424
+ connectedCallback() {
425
+ super.connectedCallback();
426
+ this.movable = this.movable && !isHandheldDevice();
427
+ if (this.movable) {
428
+ document.addEventListener('mouseup', this.dragEndHandler);
429
+ document.addEventListener('touchend', this.dragEndHandler);
430
+ document.addEventListener('touchcancel', this.dragEndHandler);
431
+ document.addEventListener('mousemove', this.dragMoveHandler);
432
+ document.addEventListener('touchmove', this.dragMoveHandler);
433
+ }
434
+ }
435
+ disconnectedCallback() {
436
+ document.dispatchEvent(new CustomEvent('overlay-closed', {
437
+ detail: this.name
438
+ }));
439
+ if (this.movable) {
440
+ document.removeEventListener('mouseup', this.dragEndHandler);
441
+ document.removeEventListener('touchend', this.dragEndHandler);
442
+ document.removeEventListener('touchcancel', this.dragEndHandler);
443
+ document.removeEventListener('mousemove', this.dragMoveHandler);
444
+ document.removeEventListener('touchmove', this.dragMoveHandler);
445
+ }
446
+ super.disconnectedCallback();
447
+ }
448
+ onDragStart(e) {
449
+ if (!this.movable) {
450
+ return;
451
+ }
452
+ const point = getPoint(e);
453
+ if (point) {
454
+ this.dragStart = point;
455
+ e.stopPropagation();
456
+ return false;
457
+ }
458
+ }
459
+ onDragMove(e) {
460
+ if (!this.movable || !this.dragStart) {
461
+ return false;
462
+ }
463
+ const point = getPoint(e);
464
+ if (!point) {
465
+ return false;
466
+ }
467
+ e.stopPropagation();
468
+ e.preventDefault();
469
+ const dragStart = point;
470
+ var { x, y } = point;
471
+ x -= this.dragStart.x;
472
+ y -= this.dragStart.y;
473
+ this.dragStart = dragStart;
474
+ const overlayed = this.overlayed;
475
+ var boundingRect = overlayed.getBoundingClientRect();
476
+ overlayed.style.left =
477
+ Math.min(document.body.offsetWidth - 40, Math.max(40 - overlayed.offsetWidth, boundingRect.left + x)) + 'px';
478
+ overlayed.style.top = Math.min(document.body.offsetHeight - 40, Math.max(0, boundingRect.top + y)) + 'px';
479
+ overlayed.style.transform = 'initial';
480
+ return false;
481
+ }
482
+ onDragEnd(e) {
483
+ if (this.movable && this.dragStart) {
484
+ e.stopPropagation();
485
+ e.preventDefault();
486
+ delete this.dragStart;
487
+ }
488
+ }
489
+ /**
490
+ * A method that closes the overlay by removing it from its parent node in the DOM.
491
+ * When called, this method removes the overlay element, effectively hiding it from the user interface.
492
+ */
493
+ close() {
494
+ this.parentNode?.removeChild(this);
495
+ }
496
+ onClose(e, escape) {
497
+ e.stopPropagation();
498
+ /* ν˜„μž¬ overlay stateλ₯Ό ν™•μΈν•΄μ„œ, μžμ‹ μ΄ ν¬ν•¨ν•˜κ³  μžˆλŠ” ν…œν”Œλ¦ΏμΈ κ²½μš°μ— history.back() ν•œλ‹€. */
499
+ if (this.historical) {
500
+ var state = history.state;
501
+ var overlay = (state || {}).overlay;
502
+ if (!overlay || overlay.name !== this.name) {
503
+ return;
504
+ }
505
+ /* Backdrop click κ²½μš°λŠ” escape μ‹œλ„λΌκ³  μ •μ˜ν•œλ‹€. overlay 속성이 escapable이 μ•„λ‹Œ κ²½μš°μ—λŠ” λ™μž‘ν•˜μ§€ μ•ŠλŠ”λ‹€. */
506
+ if (escape && !overlay.escapable) {
507
+ return true;
508
+ }
509
+ history.back();
510
+ }
511
+ else {
512
+ this.close();
513
+ }
514
+ }
515
+ };
519
516
  __decorate([
520
517
  property({ type: Boolean })
521
518
  ], OxFloatingOverlay.prototype, "backdrop", void 0);