march-ui 0.0.2 → 0.0.4
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/Button/index.jsx +1 -0
- package/ContextMenu/index.css +6 -5
- package/Form/index.jsx +23 -2
- package/MenuItem/colors.css +4 -4
- package/Tab/index.jsx +10 -5
- package/Tabs/colors.css +8 -8
- package/Tabs/index.css +14 -5
- package/Tabs/index.jsx +15 -6
- package/TextField/index.jsx +12 -0
- package/UI/colors.css +3 -3
- package/package.json +1 -1
package/Button/index.jsx
CHANGED
package/ContextMenu/index.css
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
.contextmenu {
|
|
2
2
|
width: 12em;
|
|
3
|
-
padding-top: 0.
|
|
4
|
-
padding-bottom: 0.
|
|
5
|
-
border-radius: 0.
|
|
3
|
+
padding-top: 0.5em;
|
|
4
|
+
padding-bottom: 0.5em;
|
|
5
|
+
border-radius: 0.5em;
|
|
6
6
|
user-select: none;
|
|
7
7
|
box-sizing: border-box;
|
|
8
8
|
background-color: var(--contextmenu-background-color);
|
|
9
9
|
border: 1px solid var(--contextmenu-border-color);
|
|
10
10
|
box-shadow: 0 0 2em var(--contextmenu-shadow-color);
|
|
11
|
+
overflow: hidden;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
.contextmenu--shown {
|
|
@@ -19,6 +20,6 @@
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
.contextmenu .splitter.splitter--horizontal {
|
|
22
|
-
margin-top: 0.
|
|
23
|
-
margin-bottom: 0.
|
|
23
|
+
margin-top: 0.5em;
|
|
24
|
+
margin-bottom: 0.5em;
|
|
24
25
|
}
|
package/Form/index.jsx
CHANGED
|
@@ -11,13 +11,30 @@ const defaultAttributes = {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const Form = ({ attrs }) => {
|
|
14
|
-
let { submit, beforeSubmit, afterSubmit, onerror
|
|
14
|
+
let { submit, beforeSubmit, afterSubmit, onerror/*, reportValidity*/ } = { ...defaultAttributes, ...attrs }
|
|
15
15
|
let isPending
|
|
16
|
+
const eventListeners = new Map()
|
|
17
|
+
const dispatch = (eventName) => {
|
|
18
|
+
const listeners = eventListeners.get(eventName)
|
|
19
|
+
if (listeners)
|
|
20
|
+
for (let listener of listeners.values())
|
|
21
|
+
listener()
|
|
22
|
+
}
|
|
23
|
+
const formRef = {
|
|
24
|
+
subscribe: (eventName, listener) => {
|
|
25
|
+
if (!eventListeners.has(eventName))
|
|
26
|
+
eventListeners.set(eventName, new Set())
|
|
27
|
+
const listeners = eventListeners.get(eventName)
|
|
28
|
+
listeners.add(listener)
|
|
29
|
+
return () => listeners.delete(listener)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
16
32
|
let onsubmit = evt => {
|
|
17
33
|
const formElement = evt.target
|
|
18
34
|
if (!formElement.checkValidity()) {
|
|
19
35
|
formElement.reportValidity()
|
|
20
36
|
} else {
|
|
37
|
+
dispatch('formValid')
|
|
21
38
|
isPending = false
|
|
22
39
|
beforeSubmit(evt)
|
|
23
40
|
Promise
|
|
@@ -49,7 +66,11 @@ const Form = ({ attrs }) => {
|
|
|
49
66
|
<div class="form__title">{title}</div>
|
|
50
67
|
</div>
|
|
51
68
|
<div class="form__body">
|
|
52
|
-
{children
|
|
69
|
+
{children.map(vnode => {
|
|
70
|
+
if (vnode && vnode.attrs)
|
|
71
|
+
vnode.attrs.formRef = formRef
|
|
72
|
+
return vnode
|
|
73
|
+
})}
|
|
53
74
|
</div>
|
|
54
75
|
</form>
|
|
55
76
|
)
|
package/MenuItem/colors.css
CHANGED
|
@@ -4,11 +4,11 @@ html {
|
|
|
4
4
|
|
|
5
5
|
--theme-light-menuitem-foreground-color: hsl(0,0%,10%);
|
|
6
6
|
--theme-light-menuitem-background-color: inherit;
|
|
7
|
-
--theme-light-menuitem-foreground-color-selected:
|
|
7
|
+
--theme-light-menuitem-foreground-color-selected: var(--theme-light-accent-color-focused);
|
|
8
8
|
--theme-light-menuitem-background-color-selected: hsla(266,100%,58%,0.2);
|
|
9
9
|
--theme-light-menuitem-foreground-color-hover: hsl(0,0%,0%);
|
|
10
10
|
--theme-light-menuitem-background-color-hover: hsl(0,0%,95%);
|
|
11
|
-
--theme-light-menuitem-foreground-color-selected-hover:
|
|
11
|
+
--theme-light-menuitem-foreground-color-selected-hover: var(--theme-light-accent-color);
|
|
12
12
|
--theme-light-menuitem-background-color-selected-hover: hsla(266,100%,58%,0.25);
|
|
13
13
|
--theme-light-menuitem-foreground-color-disabled: hsl(0,0%,60%);
|
|
14
14
|
--theme-light-menuitem-background-color-disabled: inherit;
|
|
@@ -17,11 +17,11 @@ html {
|
|
|
17
17
|
|
|
18
18
|
--theme-dark-menuitem-foreground-color: hsl(0,0%,90%);
|
|
19
19
|
--theme-dark-menuitem-background-color: inherit;
|
|
20
|
-
--theme-dark-menuitem-foreground-color-selected:
|
|
20
|
+
--theme-dark-menuitem-foreground-color-selected: var(--theme-dark-accent-color);
|
|
21
21
|
--theme-dark-menuitem-background-color-selected: hsla(266,100%,58%,0.2);
|
|
22
22
|
--theme-dark-menuitem-foreground-color-hover: hsl(0,0%,100%);
|
|
23
23
|
--theme-dark-menuitem-background-color-hover: hsl(0,0%,22%);
|
|
24
|
-
--theme-dark-menuitem-foreground-color-selected-hover:
|
|
24
|
+
--theme-dark-menuitem-foreground-color-selected-hover: var(--theme-dark-accent-color-focused);
|
|
25
25
|
--theme-dark-menuitem-background-color-selected-hover: hsla(266,100%,58%,0.25);
|
|
26
26
|
--theme-dark-menuitem-foreground-color-disabled: hsl(0,0%,50%);
|
|
27
27
|
--theme-dark-menuitem-background-color-disabled: inherit;
|
package/Tab/index.jsx
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
const Tab = () => {
|
|
1
|
+
const Tab = ({ attrs }) => {
|
|
2
2
|
return {
|
|
3
|
-
view({ children }) {
|
|
3
|
+
view({ attrs, children }) {
|
|
4
|
+
const { key, title, ...attributes } = attrs
|
|
4
5
|
return (
|
|
5
|
-
|
|
6
|
-
{children
|
|
7
|
-
|
|
6
|
+
<>
|
|
7
|
+
{children.map(vnode => {
|
|
8
|
+
if (vnode && vnode.attrs)
|
|
9
|
+
vnode.attrs = { ...vnode.attrs, ...attributes }
|
|
10
|
+
return vnode
|
|
11
|
+
})}
|
|
12
|
+
</>
|
|
8
13
|
)
|
|
9
14
|
}
|
|
10
15
|
}
|
package/Tabs/colors.css
CHANGED
|
@@ -3,18 +3,18 @@ html {
|
|
|
3
3
|
/* light theme */
|
|
4
4
|
|
|
5
5
|
--theme-light-tabs-background-color: hsl(0,0%,98%);
|
|
6
|
-
--theme-light-tabs-border-color: hsl(0,0%,
|
|
6
|
+
--theme-light-tabs-border-color: hsl(0,0%,85%);
|
|
7
7
|
--theme-light-tabs-active-background-color: hsl(0,0%,100%);
|
|
8
|
-
--theme-light-tabs-active-shadow-color: hsla(0,0%,0%,0.
|
|
9
|
-
--theme-light-tabs-active-text-color: var(--theme-light-accent-color);
|
|
8
|
+
--theme-light-tabs-active-shadow-color: hsla(0,0%,0%,0.3);
|
|
9
|
+
--theme-light-tabs-active-text-color: var(--theme-light-accent-color-focused);
|
|
10
10
|
|
|
11
11
|
/* dark theme */
|
|
12
12
|
|
|
13
|
-
--theme-dark-tabs-background-color: hsl(0,0%,
|
|
14
|
-
--theme-dark-tabs-border-color: hsl(0,0%,
|
|
15
|
-
--theme-dark-tabs-active-background-color: hsl(0,0%,
|
|
16
|
-
--theme-dark-tabs-active-shadow-color: hsla(0,0%,0%,0.
|
|
17
|
-
--theme-dark-tabs-active-text-color: var(--theme-dark-accent-color);
|
|
13
|
+
--theme-dark-tabs-background-color: hsl(0,0%,22%);
|
|
14
|
+
--theme-dark-tabs-border-color: hsl(0,0%,16%);
|
|
15
|
+
--theme-dark-tabs-active-background-color: hsl(0,0%,32%);
|
|
16
|
+
--theme-dark-tabs-active-shadow-color: hsla(0,0%,0%,0.4);
|
|
17
|
+
--theme-dark-tabs-active-text-color: var(--theme-dark-accent-color-focused);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
.theme--light {
|
package/Tabs/index.css
CHANGED
|
@@ -1,29 +1,38 @@
|
|
|
1
|
+
.tabs {
|
|
2
|
+
width: max-content;
|
|
3
|
+
}
|
|
4
|
+
|
|
1
5
|
.tabs__list {
|
|
6
|
+
box-sizing: border-box;
|
|
2
7
|
display: flex;
|
|
3
|
-
width:
|
|
8
|
+
width: 100%;
|
|
4
9
|
flex-direction: row;
|
|
5
10
|
justify-content: center;
|
|
6
11
|
padding: 0.25em;
|
|
7
|
-
border-radius: 0.
|
|
12
|
+
border-radius: 0.5em;
|
|
8
13
|
background-color: var(--tabs-border-color);
|
|
9
14
|
}
|
|
10
15
|
|
|
11
16
|
.tabs__switch {
|
|
17
|
+
box-sizing: border-box;
|
|
12
18
|
display: flex;
|
|
13
|
-
width:
|
|
19
|
+
width: 100%;
|
|
14
20
|
flex-direction: row;
|
|
15
21
|
justify-content: center;
|
|
16
|
-
border-radius: 0.
|
|
22
|
+
border-radius: 0.4em;
|
|
17
23
|
user-select: none;
|
|
18
24
|
background-color: var(--tabs-background-color);
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
.tab__title {
|
|
28
|
+
box-sizing: border-box;
|
|
22
29
|
display: flex;
|
|
23
|
-
flex-grow:
|
|
30
|
+
flex-grow: 1;
|
|
24
31
|
flex-shrink: 0;
|
|
25
32
|
padding: 0.25em 1em;
|
|
26
33
|
cursor: pointer;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
align-items: center;
|
|
27
36
|
}
|
|
28
37
|
|
|
29
38
|
.tab__title.tab__title--active {
|
package/Tabs/index.jsx
CHANGED
|
@@ -4,14 +4,23 @@ import classNames from 'classnames'
|
|
|
4
4
|
|
|
5
5
|
const Tabs = ({ attrs }) => {
|
|
6
6
|
let { active } = attrs
|
|
7
|
+
const switchTab = (key, onchange) => () => {
|
|
8
|
+
active = key
|
|
9
|
+
if (onchange)
|
|
10
|
+
onchange()
|
|
11
|
+
}
|
|
7
12
|
return {
|
|
8
|
-
view({ children }) {
|
|
13
|
+
view({ attrs: { active: activeNext, onchange, ...attributes }, children }) {
|
|
9
14
|
const tabs = children.filter(({ tag: { name } }) => name === 'Tab')
|
|
10
|
-
.map(tab => {
|
|
11
|
-
const { key, attrs: { title }
|
|
12
|
-
|
|
15
|
+
.map((tab, i) => {
|
|
16
|
+
const { key, attrs: { title } } = tab
|
|
17
|
+
tab.attrs = { ...tab.attrs, ...attributes }
|
|
18
|
+
return { key: key === undefined ? i : key, title, tab }
|
|
13
19
|
})
|
|
14
20
|
const activeIndex = tabs.findIndex(({ key }) => key === active || active === undefined)
|
|
21
|
+
if (activeIndex >= 0) {
|
|
22
|
+
active = tabs[activeIndex].key
|
|
23
|
+
}
|
|
15
24
|
const classes = 'tabs'
|
|
16
25
|
return (
|
|
17
26
|
<div class={classes}>
|
|
@@ -20,12 +29,12 @@ const Tabs = ({ attrs }) => {
|
|
|
20
29
|
{tabs.map(({ key, title }, i) => {
|
|
21
30
|
return <div class={classNames('tab__title', {
|
|
22
31
|
'tab__title--active': i === activeIndex
|
|
23
|
-
})} onclick={(
|
|
32
|
+
})} onclick={switchTab(key, onchange)}>{title}</div>
|
|
24
33
|
})}
|
|
25
34
|
</div>
|
|
26
35
|
</div>
|
|
27
36
|
{activeIndex >= 0 &&
|
|
28
|
-
<div class="tabs__content">{tabs[activeIndex].
|
|
37
|
+
<div class="tabs__content">{tabs[activeIndex].tab}</div>}
|
|
29
38
|
</div>
|
|
30
39
|
)
|
|
31
40
|
}
|
package/TextField/index.jsx
CHANGED
|
@@ -101,7 +101,15 @@ const TextField = ({ attrs }) => {
|
|
|
101
101
|
validateInput(evt.target)
|
|
102
102
|
return result
|
|
103
103
|
}
|
|
104
|
+
const subscriptions = {}
|
|
105
|
+
const onFormValid = () => {
|
|
106
|
+
state = 'valid'
|
|
107
|
+
}
|
|
104
108
|
return {
|
|
109
|
+
onremove() {
|
|
110
|
+
Object.values(subscriptions)
|
|
111
|
+
.forEach(unsubscribe => unsubscribe())
|
|
112
|
+
},
|
|
105
113
|
onupdate({ dom }) {
|
|
106
114
|
const inputElement = dom.querySelector('input')
|
|
107
115
|
if (state === 'valid') {
|
|
@@ -119,6 +127,7 @@ const TextField = ({ attrs }) => {
|
|
|
119
127
|
validate: validateNext, pattern,
|
|
120
128
|
placeholder: placeholderDropped,
|
|
121
129
|
state: stateNext,
|
|
130
|
+
formRef,
|
|
122
131
|
...rest
|
|
123
132
|
} = {
|
|
124
133
|
...defaultAttributes,
|
|
@@ -151,6 +160,9 @@ const TextField = ({ attrs }) => {
|
|
|
151
160
|
...(disabled ? { disabled } : {}),
|
|
152
161
|
...rest
|
|
153
162
|
}
|
|
163
|
+
if (formRef) {
|
|
164
|
+
subscriptions.formValid = formRef.subscribe('formValid', onFormValid)
|
|
165
|
+
}
|
|
154
166
|
return (
|
|
155
167
|
<label class={classes}>
|
|
156
168
|
{title && <div class="textfield__title">{title}</div>}
|
package/UI/colors.css
CHANGED
|
@@ -11,7 +11,7 @@ html {
|
|
|
11
11
|
/* light theme */
|
|
12
12
|
|
|
13
13
|
--theme-light-accent-color: hsl(266,100%,58%);
|
|
14
|
-
--theme-light-accent-color-focused: hsl(266,100%,
|
|
14
|
+
--theme-light-accent-color-focused: hsl(266,100%,66%);
|
|
15
15
|
--theme-light-accent-darken-color: hsl(266,65%,45%);
|
|
16
16
|
--theme-light-accent-darken-color-focused: hsl(266,70%,50%);
|
|
17
17
|
|
|
@@ -22,8 +22,8 @@ html {
|
|
|
22
22
|
|
|
23
23
|
/* dark theme */
|
|
24
24
|
|
|
25
|
-
--theme-dark-accent-color: hsl(266,75
|
|
26
|
-
--theme-dark-accent-color-focused: hsl(266,100%,
|
|
25
|
+
--theme-dark-accent-color: hsl(266,100%,75%);
|
|
26
|
+
--theme-dark-accent-color-focused: hsl(266,100%,82%);
|
|
27
27
|
--theme-dark-accent-darken-color: hsl(266,65%,45%);
|
|
28
28
|
--theme-dark-accent-darken-color-focused: hsl(266,70%,50%);
|
|
29
29
|
|