@operato/context 7.1.31 โ†’ 7.1.32

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.
@@ -1,52 +0,0 @@
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
- ]
@@ -1,8 +0,0 @@
1
- import { storybookPlugin } from '@web/dev-server-storybook';
2
- import baseConfig from '../web-dev-server.config.mjs';
3
-
4
- export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
5
- ...baseConfig,
6
- open: '/',
7
- plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins],
8
- });
package/demo/index.html DELETED
@@ -1,43 +0,0 @@
1
- <!doctype html>
2
- <html lang="en-GB">
3
- <head>
4
- <meta charset="utf-8" />
5
- <style>
6
- body {
7
- background: #fafafa;
8
- --ox-checkbox-size: 12px;
9
- }
10
-
11
- #demo {
12
- position: relative;
13
- height: 300px;
14
- background-color: lightgray;
15
- vertical-align: middle;
16
- }
17
- </style>
18
- <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet" />
19
- <link
20
- href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
21
- rel="stylesheet"
22
- />
23
- <link
24
- href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
25
- rel="stylesheet"
26
- />
27
- <link
28
- href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
29
- rel="stylesheet"
30
- />
31
- </head>
32
- <body>
33
- <div id="demo"></div>
34
-
35
- <script type="module">
36
- import { html, render } from 'lit'
37
-
38
- const parent = document.querySelector('#demo')
39
-
40
- render(html`clike anywhere in this box to utils mini.`, parent)
41
- </script>
42
- </body>
43
- </html>
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './styles/ox-context-toolbar-overlay-style.js'
@@ -1,121 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
-
3
- import { css, html, LitElement, TemplateResult, nothing } from 'lit'
4
- import { customElement, property, query, state } from 'lit/decorators.js'
5
- import { connect } from 'pwa-helpers/connect-mixin.js'
6
-
7
- import { TOOL_POSITION } from '@operato/layout'
8
- import { store } from '@operato/shell'
9
-
10
- @customElement('ox-context-page-toolbar')
11
- export class ContextPageToolbar extends connect(store)(LitElement) {
12
- static get styles() {
13
- return [
14
- css`
15
- :host {
16
- display: flex;
17
- flex-direction: row-reverse;
18
- gap: var(--spacing-medium);
19
-
20
- position: relative;
21
-
22
- justify-content: end;
23
- align-items: center;
24
-
25
- text-transform: capitalize;
26
-
27
- --context-action-bar-button-margin: var(--spacing-none);
28
- --context-action-bar-more-button-border-radius: 2px;
29
-
30
- --md-icon-size: 20px;
31
- }
32
-
33
- :host > div {
34
- display: flex;
35
- flex-direction: row;
36
-
37
- align-items: center;
38
- gap: var(--spacing-small);
39
- }
40
-
41
- md-icon {
42
- width: 32px;
43
- height: 32px;
44
- box-sizing: border-box;
45
-
46
- color: var(--md-sys-color-on-primary-container);
47
- background-color: var(--md-sys-color-primary-container);
48
- border: 1px solid var(--md-sys-color-primary-container);
49
- border-radius: var(--md-sys-shape-corner-small);
50
- padding: var(--spacing-small);
51
-
52
- &:hover {
53
- color: var(--md-sys-color-on-primary);
54
- background-color: var(--md-sys-color-primary);
55
- border-color: var(--md-sys-color-primary);
56
- }
57
- }
58
-
59
- @media screen and (max-width: 460px) {
60
- :host {
61
- gap: 0;
62
- }
63
-
64
- :host > div {
65
- gap: 0;
66
- }
67
-
68
- md-icon {
69
- border-radius: 0;
70
- }
71
- }
72
- `
73
- ]
74
- }
75
-
76
- @property({ type: Object }) context: any
77
- @property({ type: Array }) tools?: {
78
- position: TOOL_POSITION
79
- template: TemplateResult
80
- context?: string
81
- }[]
82
-
83
- render() {
84
- let contextKeys = Object.keys(this.context).filter(key => !!this.context[key])
85
- let tools = (this.tools || []).filter(tool => {
86
- if (!tool.context || contextKeys.includes(tool.context)) {
87
- return tool
88
- }
89
- })
90
-
91
- let frontEndTools = tools.filter(tool => tool.position == TOOL_POSITION.FRONT_END)
92
- let frontTools = tools.filter(tool => tool.position == TOOL_POSITION.FRONT)
93
- let centerTools = tools.filter(tool => tool.position == TOOL_POSITION.CENTER)
94
- let rearTools = tools.filter(tool => tool.position == TOOL_POSITION.REAR)
95
- let rearEndTools = tools.filter(tool => tool.position == TOOL_POSITION.REAR_END)
96
-
97
- return html`
98
- <slot name="front"></slot>
99
- ${frontEndTools.length > 0
100
- ? html`<div id="front-end">${frontEndTools.map(tool => html` ${tool.template} `)}</div>`
101
- : nothing}
102
- ${frontTools.length > 0
103
- ? html`<div id="front">${frontTools.map(tool => html` ${tool.template} `)}</div>`
104
- : nothing}
105
- ${centerTools.length > 0
106
- ? html`<div id="center">${centerTools.map(tool => html` ${tool.template} `)}</div>`
107
- : nothing}
108
- ${rearTools.length > 0 ? html`<div id="rear">${rearTools.map(tool => html` ${tool.template} `)}</div>` : nothing}
109
- ${rearEndTools.length > 0
110
- ? html`<div id="rear-end">${rearEndTools.map(tool => html` ${tool.template} `)}</div>`
111
- : nothing}
112
- <slot name="rear"></slot>
113
- `
114
- }
115
-
116
- stateChanged(state: any) {
117
- if (state.context) {
118
- this.tools = state.context?.tools
119
- }
120
- }
121
- }
@@ -1,208 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
-
3
- import { css, html, LitElement, nothing, PropertyValues } from 'lit'
4
- import { customElement, property, query, state } from 'lit/decorators.js'
5
- import { connect } from 'pwa-helpers/connect-mixin.js'
6
-
7
- import { TOOL_POSITION } from '@operato/layout'
8
- import { store } from '@operato/shell'
9
-
10
- @customElement('ox-context-toolbar')
11
- export class ContextToolbar extends connect(store)(LitElement) {
12
- static get styles() {
13
- return [
14
- css`
15
- :host {
16
- display: flex;
17
-
18
- color: var(--context-toolbar-background-color, var(--md-sys-color-on-secondary-container));
19
- background-color: var(--context-toolbar-background-color, var(--md-sys-color-secondary-container));
20
- box-shadow: var(--context-toolbar-shadow-line);
21
-
22
- padding: 0;
23
-
24
- --md-icon-size: 20px;
25
- }
26
-
27
- div[container] {
28
- flex: 1;
29
-
30
- display: flex;
31
- position: relative;
32
- overflow: hidden;
33
-
34
- justify-content: space-between;
35
-
36
- gap: var(--spacing-medium);
37
- padding: var(--spacing-small) var(--spacing-medium);
38
-
39
- &:not(:has(> *)) {
40
- padding: 0;
41
- }
42
-
43
- div {
44
- display: flex;
45
- flex-direction: row;
46
- flex-wrap: nowrap;
47
-
48
- align-items: center;
49
- overflow: hidden;
50
- padding: 0;
51
- }
52
-
53
- #front-end md-icon,
54
- #front md-icon {
55
- border: var(--context-toolbar-function-button-border, none);
56
- }
57
-
58
- #front-end md-icon {
59
- color: var(--md-sys-color-on-primary-container);
60
- background-color: var(--md-sys-color-on-primary-container);
61
- }
62
-
63
- #front-end md-icon:hover {
64
- color: var(--md-sys-color-on-primary);
65
- background-color: var(--md-sys-color-primary);
66
- }
67
-
68
- #front md-icon {
69
- color: var(--md-sys-color-on-secondary-container);
70
- background-color: var(--md-sys-color-secondary-container);
71
- }
72
-
73
- #front md-icon:hover {
74
- color: var(--md-sys-on-color-secondary);
75
- background-color: var(--md-sys-color-secondary);
76
- }
77
-
78
- md-icon {
79
- color: var(--md-sys-color-on-primary-container);
80
- background-color: var(--md-sys-color-primary-container);
81
- border: 1px solid var(--md-sys-color-primary-container);
82
- border-radius: var(--md-sys-shape-corner-small);
83
- padding: var(--spacing-small);
84
-
85
- &:hover {
86
- color: var(--md-sys-color-on-primary);
87
- background-color: var(--md-sys-color-primary);
88
- }
89
- }
90
-
91
- div md-icon {
92
- border-radius: 0;
93
- }
94
-
95
- div md-icon:first-child {
96
- border-top-left-radius: var(--md-sys-shape-corner-small);
97
- border-bottom-left-radius: var(--md-sys-shape-corner-small);
98
- }
99
-
100
- div md-icon:last-child {
101
- border-top-right-radius: var(--md-sys-shape-corner-small);
102
- border-bottom-right-radius: var(--md-sys-shape-corner-small);
103
- }
104
-
105
- #center {
106
- flex: 1;
107
- justify-content: end;
108
- }
109
- }
110
-
111
- @media only screen and (max-width: 460px) {
112
- div[container] {
113
- padding: 0;
114
- gap: 0;
115
- --md-assist-chip-container-shape: 0;
116
- }
117
-
118
- div[container] div md-icon {
119
- border-radius: 0 !important;
120
- }
121
-
122
- div[container] div md-icon:not(:last-child) {
123
- border-right-width: 0;
124
- }
125
- }
126
- `
127
- ]
128
- }
129
-
130
- @state() private context: any
131
- @state() private tools?: any[]
132
-
133
- @query('[container]') private container!: HTMLDivElement
134
-
135
- render() {
136
- if (this.context.toolbar === false) {
137
- return nothing
138
- }
139
-
140
- let contextKeys = Object.keys(this.context).filter(key => !!this.context[key])
141
- let tools = (this.tools || []).filter(tool => {
142
- if (!tool.context || contextKeys.includes(tool.context)) {
143
- return tool
144
- }
145
- })
146
-
147
- let frontEndTools = tools.filter(tool => tool.position == TOOL_POSITION.FRONT_END)
148
- let frontTools = tools.filter(tool => tool.position == TOOL_POSITION.FRONT)
149
- let centerTools = tools.filter(tool => tool.position == TOOL_POSITION.CENTER)
150
- let rearTools = tools.filter(tool => tool.position == TOOL_POSITION.REAR)
151
- let rearEndTools = tools.filter(tool => tool.position == TOOL_POSITION.REAR_END)
152
-
153
- return html`
154
- <div container>
155
- ${frontEndTools.length > 0
156
- ? html`<div id="front-end">${frontEndTools.map(tool => html` ${tool.template} `)}</div>`
157
- : nothing}
158
- ${frontTools.length > 0
159
- ? html`<div id="front">${frontTools.map(tool => html` ${tool.template} `)}</div>`
160
- : nothing}
161
- ${centerTools.length > 0
162
- ? html`<div id="center">${centerTools.map(tool => html` ${tool.template} `)}</div>`
163
- : nothing}
164
- ${rearTools.length > 0
165
- ? html`<div id="rear">${rearTools.map(tool => html` ${tool.template} `)}</div>`
166
- : nothing}
167
- ${rearEndTools.length > 0
168
- ? html`<div id="rear-end">${rearEndTools.map(tool => html` ${tool.template} `)}</div>`
169
- : nothing}
170
- </div>
171
- `
172
- }
173
-
174
- updated(changes: PropertyValues<this>) {
175
- requestAnimationFrame(() => {
176
- /*
177
- ํ•˜์œ„ ์—˜๋ฆฌ๋จผํŠธ๋“ค์ด ์‹ค์ œ๋กœ ๋ณด์ผ ํ•„์š”๊ฐ€ ์—†์„ ๋•Œ๋Š”, ์ด ์—˜๋ฆฌ๋จผํŠธ๋„ ์ˆจ๊น€ ์ฒ˜๋ฆฌํ•จ.
178
- &:not(:has(> *)) ์ฒ˜๋ฆฌ๋กœ ๋ชจ๋‘ ํ•ด๊ฒฐ๋˜์ง€ ์•Š์œผ๋ฏ€๋กœ, ๋กœ์ง ์ฒ˜๋ฆฌ๋กœ ๋ณด์™„ํ•จ.
179
- &:not(:has(> *)) ๊ฐ€ ํ•„์š”์—†์œผ๋‚˜, ๋‚จ๊ฒจ ๋‘์—ˆ์Œ.
180
- */
181
- if (!this.container) {
182
- return
183
- }
184
-
185
- const children = this.container.querySelectorAll('*')
186
-
187
- let zero = true
188
-
189
- // ๋ชจ๋“  ํ•˜์œ„ ์—˜๋ฆฌ๋จผํŠธ์˜ ๋†’์ด๋ฅผ ํ™•์ธ
190
- for (const child of Array.from(children)) {
191
- if ((child as HTMLElement).offsetHeight !== 0) {
192
- zero = false
193
- break
194
- }
195
- }
196
-
197
- // ๋ชจ๋“  ํ•˜์œ„ ์—˜๋ฆฌ๋จผํŠธ์˜ ๋†’์ด๊ฐ€ 0์ด๋ฉด ๋ถ€๋ชจ ์—˜๋ฆฌ๋จผํŠธ์˜ display๋ฅผ none์œผ๋กœ ๋ณ€๊ฒฝ
198
- this.container.style.padding = zero ? '0' : 'revert-layer'
199
- })
200
- }
201
-
202
- stateChanged(state: any) {
203
- if (state.context) {
204
- this.tools = state.context.tools || []
205
- this.context = state.route.context || {}
206
- }
207
- }
208
- }
@@ -1,58 +0,0 @@
1
- import { css } from 'lit'
2
-
3
- export const ContextToolbarOverlayStyle = css`
4
- :host {
5
- display: block;
6
-
7
- background-color: var(--context-ui-background-color);
8
- box-shadow: var(--context-ui-box-shadow);
9
- padding: var(--context-ui-padding);
10
- }
11
-
12
- ul {
13
- margin: 0;
14
- padding: 0;
15
- list-style: none;
16
- overflow-y: auto;
17
- }
18
-
19
- li {
20
- display: flex;
21
-
22
- border-bottom: var(--context-ui-list-border-bottom);
23
- padding: var(--context-ui-list-padding);
24
- }
25
-
26
- li > md-icon {
27
- font-size: 1em;
28
-
29
- padding: var(--context-ui-padding);
30
- color: var(--context-ui-list-color);
31
- }
32
-
33
- li > span {
34
- margin: auto 0;
35
- flex: 1;
36
-
37
- color: var(--context-ui-list-color);
38
- }
39
-
40
- li:hover md-icon,
41
- li:hover span {
42
- color: #fff;
43
- }
44
-
45
- li:hover {
46
- cursor: pointer;
47
-
48
- border-bottom: var(--context-ui-list-border-hover-bottom);
49
- }
50
-
51
- @media (max-width: 460px) {
52
- :host {
53
- min-width: 100%;
54
- box-shadow: none;
55
- border-radius: 0;
56
- }
57
- }
58
- `