@policystudio/policy-studio-ui-vue 1.0.18 → 1.0.19
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/.eslintrc.js +68 -0
- package/.storybook/main.js +2 -1
- package/dist/css/psui_styles.css +70643 -0
- package/package.json +13 -9
- package/src/assets/images/check-checkbox-button.svg +1 -0
- package/src/assets/images/radio-checked-button.svg +1 -0
- package/src/assets/scss/base.scss +29 -2
- package/src/assets/scss/tailwind.css +2233 -2736
- package/src/components/accordion/PsAccordion.vue +36 -0
- package/src/components/accordion/PsAccordionItem.vue +102 -0
- package/src/components/buttons/PsButton.vue +6 -3
- package/src/components/chips/PsChips.vue +146 -0
- package/src/components/controls/PsCheckbox.vue +3 -3
- package/src/components/controls/PsRadioButton.vue +11 -35
- package/src/components/controls/PsSlider.vue +13 -12
- package/src/components/controls/PsSwitch.vue +20 -19
- package/src/components/datatable/PsDataTable.vue +93 -0
- package/src/components/datatable/PsDataTableItem.vue +57 -0
- package/src/components/forms/PsDropdown.vue +196 -0
- package/src/components/forms/PsInput.vue +4 -1
- package/src/components/tabs/PsTabHeader.vue +20 -21
- package/src/components/ui/PsIcon.vue +65 -0
- package/src/index.js +37 -22
- package/src/stories/Accordion.stories.js +35 -0
- package/src/stories/Checkbox.stories.js +15 -8
- package/src/stories/Chips.stories.js +49 -0
- package/src/stories/Datatable.stories.js +43 -0
- package/src/stories/Dropdown.stories.js +34 -0
- package/src/stories/RadioButton.stories.js +21 -5
- package/src/stories/Swith.stories.js +2 -2
- package/src/util/GeneralFunctions.js +23 -0
- package/tailwind.config.js +18 -4
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="psui-relative psui-inline-block psui-text-left"
|
|
4
|
+
ref="PSDropdown"
|
|
5
|
+
>
|
|
6
|
+
|
|
7
|
+
<div class="psui-bg-red" ref="PSDropdownTrigger" v-if="$slots.dropdownTrigger" @click="show && !toggleWhenActive ? '' : toggle()" >
|
|
8
|
+
<slot name="dropdownTrigger" ></slot>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<button
|
|
12
|
+
v-else
|
|
13
|
+
@click="show && !toggleWhenActive ? '' : toggle()"
|
|
14
|
+
type="button"
|
|
15
|
+
class="psui-inline-flex psui-justify-center psui-items-center psui-w-full psui-font-medium psui-focus:shadow-outline-blue psui-dropdown-button psui-text-sm psui-leading-none"
|
|
16
|
+
:class="[buttonClasses]"
|
|
17
|
+
:id="id"
|
|
18
|
+
aria-haspopup="true"
|
|
19
|
+
aria-expanded="true"
|
|
20
|
+
ref="PSDropdownTrigger"
|
|
21
|
+
>
|
|
22
|
+
<slot v-if="show && $slots.buttonLabelOnShow" name="buttonLabelOnShow"></slot>
|
|
23
|
+
<slot v-else name="buttonLabel"></slot>
|
|
24
|
+
</button>
|
|
25
|
+
|
|
26
|
+
<div
|
|
27
|
+
ref="PSDropdownDialog"
|
|
28
|
+
role="menu"
|
|
29
|
+
class="psui-dropdown-dialog psui-hidden psui-origin-top-right psui-fixed psui-mt-2 psui-w-auto psui-rounded psui-shadow-lg psui-border psui-border-blue05 psui-z-50 psui-opacity-0"
|
|
30
|
+
aria-orientation="vertical"
|
|
31
|
+
:aria-labelledby="id"
|
|
32
|
+
:class="[dialogClasses]"
|
|
33
|
+
:style="{ minWidth: minWidthDropdown, marginLeft: marginLeft }"
|
|
34
|
+
>
|
|
35
|
+
<div class="w-full">
|
|
36
|
+
<h2 class="psui-text-gray02 psui-font-bold psui-whitespace-no-wrap psui-mb-4 ts--accent--1" v-if="title">{{ title }}</h2>
|
|
37
|
+
<slot name="items"></slot>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
import { randomString, getParentScrollableEl } from '../../util/GeneralFunctions'
|
|
46
|
+
|
|
47
|
+
export default {
|
|
48
|
+
name: 'PsDropdown',
|
|
49
|
+
props: {
|
|
50
|
+
buttonClasses: {
|
|
51
|
+
type: String,
|
|
52
|
+
default: 'psui-bg-white psui-border psui-border-blue'
|
|
53
|
+
},
|
|
54
|
+
title: {
|
|
55
|
+
type: String,
|
|
56
|
+
},
|
|
57
|
+
dialogClasses: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: 'psui-p-6 psui-left-0 psui-bg-white'
|
|
60
|
+
},
|
|
61
|
+
minWidthDropdown: {
|
|
62
|
+
type: [String, Number],
|
|
63
|
+
},
|
|
64
|
+
maxWidthDropDown: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: '340px'
|
|
67
|
+
},
|
|
68
|
+
buttonLabelOnShow: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
default: false
|
|
71
|
+
},
|
|
72
|
+
toggleWhenActive: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
default: true
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
data() {
|
|
78
|
+
return {
|
|
79
|
+
show: false,
|
|
80
|
+
id: randomString(8),
|
|
81
|
+
marginLeft: '-0px',
|
|
82
|
+
scrollableParentEl : null
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
computed: {
|
|
86
|
+
getMaxWidth() {
|
|
87
|
+
let bounds = this.$refs.PSDropdown.getBoundingClientRect()
|
|
88
|
+
return (document.documentElement.clientWidth - bounds['left']) -30
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
beforeDestroy() {
|
|
92
|
+
this.unwatchParentScrolling()
|
|
93
|
+
},
|
|
94
|
+
methods: {
|
|
95
|
+
toggle() {
|
|
96
|
+
if (!this.show) {
|
|
97
|
+
this.open()
|
|
98
|
+
} else {
|
|
99
|
+
this.close()
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
watchParentScrolling() {
|
|
103
|
+
this.scrollableParentEl = getParentScrollableEl(this.$refs.PSDropdown)
|
|
104
|
+
if (this.scrollableParentEl) {
|
|
105
|
+
this.scrollableParentEl.addEventListener('scroll', this.updatePosition)
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
unwatchParentScrolling() {
|
|
109
|
+
if (this.scrollableParentEl) {
|
|
110
|
+
this.scrollableParentEl.removeEventListener('scroll', this.updatePosition)
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
updatePosition() {
|
|
114
|
+
|
|
115
|
+
const PSDropdownDialog = this.$refs.PSDropdownDialog
|
|
116
|
+
const PSDropdownTrigger = this.$refs.PSDropdownTrigger
|
|
117
|
+
if (!PSDropdownDialog || !PSDropdownTrigger) return
|
|
118
|
+
|
|
119
|
+
const rectTrigger = PSDropdownTrigger.getBoundingClientRect()
|
|
120
|
+
const rectDialog = PSDropdownDialog.getBoundingClientRect()
|
|
121
|
+
const windowWidth = document.documentElement.clientWidth
|
|
122
|
+
|
|
123
|
+
PSDropdownDialog.style.position = 'fixed'
|
|
124
|
+
PSDropdownDialog.style.top = `${rectTrigger.y + rectTrigger.height }px`
|
|
125
|
+
|
|
126
|
+
if (( rectTrigger.x + rectDialog.width + 20 ) > windowWidth ) {
|
|
127
|
+
PSDropdownDialog.style.left = `${windowWidth - rectDialog.width - 30}px`
|
|
128
|
+
} else {
|
|
129
|
+
PSDropdownDialog.style.left = `${rectTrigger.x}px`
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if(rectTrigger.top < 10) {
|
|
133
|
+
this.close()
|
|
134
|
+
console.warn('The dropdown are too close from the top of the page')
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
setTimeout(() => { PSDropdownDialog.style.opacity = 1 }, 10)
|
|
139
|
+
|
|
140
|
+
},
|
|
141
|
+
open() {
|
|
142
|
+
this.$emit('open')
|
|
143
|
+
this.show = true
|
|
144
|
+
this.$refs.PSDropdownDialog.style.opacity = 0
|
|
145
|
+
this.$refs.PSDropdownDialog.style.display = 'block'
|
|
146
|
+
setTimeout(() => {
|
|
147
|
+
this.updatePosition()
|
|
148
|
+
this.watchParentScrolling()
|
|
149
|
+
document.addEventListener("keyup", this.handleEsc)
|
|
150
|
+
window.addEventListener("resize", this.updatePosition)
|
|
151
|
+
window.addEventListener("click", this.clickOutside)
|
|
152
|
+
}, 10)
|
|
153
|
+
},
|
|
154
|
+
close() {
|
|
155
|
+
if (this.show) {
|
|
156
|
+
this.$emit('close')
|
|
157
|
+
this.$refs.PSDropdownDialog.style.display = 'none'
|
|
158
|
+
this.$refs.PSDropdownDialog.style.opacity = 0
|
|
159
|
+
this.show = false
|
|
160
|
+
this.unwatchParentScrolling()
|
|
161
|
+
}
|
|
162
|
+
document.removeEventListener("keyup", this.handleEsc)
|
|
163
|
+
document.removeEventListener("resize", this.updatePosition)
|
|
164
|
+
document.removeEventListener("click", this.clickOutside)
|
|
165
|
+
},
|
|
166
|
+
handleEsc(evt) {
|
|
167
|
+
if (this.show && evt.keyCode === 27) this.close()
|
|
168
|
+
},
|
|
169
|
+
clickOutside(event) {
|
|
170
|
+
if(!this.show) return
|
|
171
|
+
if (!(this.$refs.PSDropdown == event.target || this.$refs.PSDropdown.contains(event.target))) {
|
|
172
|
+
this.close()
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
</script>
|
|
178
|
+
|
|
179
|
+
<style>
|
|
180
|
+
|
|
181
|
+
.dropdown-button {
|
|
182
|
+
background-color: transparent;
|
|
183
|
+
padding-top: 2.5px;
|
|
184
|
+
padding-bottom: 2.5px;
|
|
185
|
+
min-height: 27px;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.dropdown-button:focus {
|
|
189
|
+
outline: none;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.psui-dropdown-dialog {
|
|
193
|
+
transition: opacity 150ms ease-in-out;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
</style>
|
|
@@ -70,7 +70,7 @@ export default {
|
|
|
70
70
|
},
|
|
71
71
|
computed: {
|
|
72
72
|
getInputClasses() {
|
|
73
|
-
return `${this.getPadding} ${this.getText} psui-text-gray-60 psui-
|
|
73
|
+
return `${this.getPadding} ${this.getText} psui-text-gray-60 psui-w-full psui-border psui-border-gray-30 psui-rounded-md psui-block hover:psui-border-blue-50 focus:psui-border-blue-50 ${this.getState}`
|
|
74
74
|
},
|
|
75
75
|
getText() {
|
|
76
76
|
return this.mini ? 'psui-text-small' : ''
|
|
@@ -78,6 +78,9 @@ export default {
|
|
|
78
78
|
getPadding() {
|
|
79
79
|
return this.mini ? 'psui-px-2 mini-p' : 'psui-py-2 psui-px-4'
|
|
80
80
|
},
|
|
81
|
+
getState() {
|
|
82
|
+
return this.disabled ? 'disabled:psui-bg-gray-20' : 'psui-bg-white'
|
|
83
|
+
},
|
|
81
84
|
getAttrs() {
|
|
82
85
|
const defaultAttrs = {
|
|
83
86
|
autocapitalize: 'sentences',
|
|
@@ -21,6 +21,26 @@
|
|
|
21
21
|
export const themeOptions = ['standard', 'underline', 'folder']
|
|
22
22
|
export default {
|
|
23
23
|
name: 'PsTabHeader',
|
|
24
|
+
props: {
|
|
25
|
+
theme: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: 'standard',
|
|
28
|
+
validator: (value) => themeOptions.indexOf(value) !== -1
|
|
29
|
+
},
|
|
30
|
+
items: {
|
|
31
|
+
type: Array,
|
|
32
|
+
required: true
|
|
33
|
+
},
|
|
34
|
+
selected: {},
|
|
35
|
+
keyLabel: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: 'label'
|
|
38
|
+
},
|
|
39
|
+
keyValue: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: 'value'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
24
44
|
computed: {
|
|
25
45
|
wrapperClasses() {
|
|
26
46
|
if (this.theme === 'underline') {
|
|
@@ -67,27 +87,6 @@ export default {
|
|
|
67
87
|
}
|
|
68
88
|
}
|
|
69
89
|
},
|
|
70
|
-
|
|
71
|
-
props: {
|
|
72
|
-
theme: {
|
|
73
|
-
type: String,
|
|
74
|
-
default: 'standard',
|
|
75
|
-
validator: (value) => themeOptions.indexOf(value) !== -1
|
|
76
|
-
},
|
|
77
|
-
items: {
|
|
78
|
-
type: Array,
|
|
79
|
-
required: true
|
|
80
|
-
},
|
|
81
|
-
selected: {},
|
|
82
|
-
keyLabel: {
|
|
83
|
-
type: String,
|
|
84
|
-
default: 'label'
|
|
85
|
-
},
|
|
86
|
-
keyValue: {
|
|
87
|
-
type: String,
|
|
88
|
-
default: 'value'
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
90
|
methods: {
|
|
92
91
|
selectTab(item) {
|
|
93
92
|
this.$emit('update:selected', this.getIsObject ? item : item[this.keyValue] )
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div style="display: contents">
|
|
3
|
+
<i
|
|
4
|
+
v-if="type === 'material-icons'"
|
|
5
|
+
:class="[getIconClasses]"
|
|
6
|
+
>
|
|
7
|
+
{{ icon }}
|
|
8
|
+
</i>
|
|
9
|
+
<img v-else-if="type == 'url'" src="" :class="[getIconClasses]" />
|
|
10
|
+
<inline-svg
|
|
11
|
+
v-else
|
|
12
|
+
:src="`/icons/type-prototypes-slug/${type_prototype.slug}.svg`"
|
|
13
|
+
width="32"
|
|
14
|
+
height="32"
|
|
15
|
+
stroke="#A9AEB0"
|
|
16
|
+
></inline-svg>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
export default {
|
|
22
|
+
name: 'PSIcon',
|
|
23
|
+
props: {
|
|
24
|
+
icon: {
|
|
25
|
+
type: String,
|
|
26
|
+
required: true
|
|
27
|
+
},
|
|
28
|
+
type: {
|
|
29
|
+
type: String,
|
|
30
|
+
default: 'material-icons'
|
|
31
|
+
},
|
|
32
|
+
iconClasses: {
|
|
33
|
+
type: String
|
|
34
|
+
},
|
|
35
|
+
size: {
|
|
36
|
+
type: [Number, String]
|
|
37
|
+
},
|
|
38
|
+
width: {
|
|
39
|
+
type: Number
|
|
40
|
+
},
|
|
41
|
+
height: {
|
|
42
|
+
type: Number
|
|
43
|
+
},
|
|
44
|
+
stroke: {
|
|
45
|
+
type: String,
|
|
46
|
+
},
|
|
47
|
+
color: {
|
|
48
|
+
type: String
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
},
|
|
52
|
+
computed: {
|
|
53
|
+
getIconClasses() {
|
|
54
|
+
if(this.iconClasses) return this.iconClasses
|
|
55
|
+
const size = this.sizes === 'small' ? 'psui-text-sm' : ''
|
|
56
|
+
const color = this.iconColor.length > 0 ? `psui-text-${this.iconColor}` : ''
|
|
57
|
+
return `psui-mr-2 psui-my-auto material-icons ${size} ${color}`
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<style>
|
|
64
|
+
|
|
65
|
+
</style>
|
package/src/index.js
CHANGED
|
@@ -1,28 +1,38 @@
|
|
|
1
|
-
import PsButton from './components/buttons/PsButton.vue'
|
|
2
|
-
import PsCheckbox from './components/controls/PsCheckbox.vue'
|
|
3
|
-
import PsRadioButton from './components/controls/PsRadioButton.vue'
|
|
4
|
-
import PsSlider from './components/controls/PsSlider.vue'
|
|
5
|
-
import PsSwitch from './components/controls/PsSwitch.vue'
|
|
6
|
-
import PsToggle from './components/controls/PsToggle.vue'
|
|
7
|
-
import PsInput from './components/forms/PsInput.vue'
|
|
8
|
-
import PsDialog from './components/notifications/PsDialog.vue'
|
|
9
|
-
import PsToast from './components/notifications/PsToast.vue'
|
|
10
|
-
import PsTabHeader from './components/tabs/PsTabHeader.vue'
|
|
1
|
+
import PsButton from './components/buttons/PsButton.vue'
|
|
2
|
+
import PsCheckbox from './components/controls/PsCheckbox.vue'
|
|
3
|
+
import PsRadioButton from './components/controls/PsRadioButton.vue'
|
|
4
|
+
import PsSlider from './components/controls/PsSlider.vue'
|
|
5
|
+
import PsSwitch from './components/controls/PsSwitch.vue'
|
|
6
|
+
import PsToggle from './components/controls/PsToggle.vue'
|
|
7
|
+
import PsInput from './components/forms/PsInput.vue'
|
|
8
|
+
import PsDialog from './components/notifications/PsDialog.vue'
|
|
9
|
+
import PsToast from './components/notifications/PsToast.vue'
|
|
10
|
+
import PsTabHeader from './components/tabs/PsTabHeader.vue'
|
|
11
|
+
import PsAccordion from './components/accordion/PsAccordion.vue'
|
|
12
|
+
import PsAccordionItem from './components/accordion/PsAccordionItem.vue'
|
|
13
|
+
import PsChips from './components/chips/PsChips.vue'
|
|
14
|
+
import PsDataTable from './components/datatable/PsDataTable.vue'
|
|
15
|
+
import PsDataTableItem from './components/datatable/PsDataTableItem.vue'
|
|
11
16
|
|
|
12
17
|
export default {
|
|
13
18
|
install(Vue) {
|
|
14
|
-
Vue.component('PsButton', PsButton)
|
|
15
|
-
Vue.component('PsCheckbox', PsCheckbox)
|
|
16
|
-
Vue.component('PsDialog', PsDialog)
|
|
17
|
-
Vue.component('PsToast', PsToast)
|
|
18
|
-
Vue.component('PsTabHeader', PsTabHeader)
|
|
19
|
-
Vue.component('PsRadioButton', PsRadioButton)
|
|
20
|
-
Vue.component('PsSlider', PsSlider)
|
|
21
|
-
Vue.component('PsSwitch', PsSwitch)
|
|
22
|
-
Vue.component('PsInput', PsInput)
|
|
23
|
-
Vue.component('PsToggle', PsToggle)
|
|
19
|
+
Vue.component('PsButton', PsButton)
|
|
20
|
+
Vue.component('PsCheckbox', PsCheckbox)
|
|
21
|
+
Vue.component('PsDialog', PsDialog)
|
|
22
|
+
Vue.component('PsToast', PsToast)
|
|
23
|
+
Vue.component('PsTabHeader', PsTabHeader)
|
|
24
|
+
Vue.component('PsRadioButton', PsRadioButton)
|
|
25
|
+
Vue.component('PsSlider', PsSlider)
|
|
26
|
+
Vue.component('PsSwitch', PsSwitch)
|
|
27
|
+
Vue.component('PsInput', PsInput)
|
|
28
|
+
Vue.component('PsToggle', PsToggle)
|
|
29
|
+
Vue.component('PsAccordion', PsAccordion)
|
|
30
|
+
Vue.component('PsAccordionItem', PsAccordionItem)
|
|
31
|
+
Vue.component('PsChips', PsChips)
|
|
32
|
+
Vue.component('PsDataTable', PsDataTable)
|
|
33
|
+
Vue.component('PsDataTableItem', PsDataTableItem)
|
|
24
34
|
}
|
|
25
|
-
}
|
|
35
|
+
}
|
|
26
36
|
|
|
27
37
|
export {
|
|
28
38
|
PsButton,
|
|
@@ -34,5 +44,10 @@ export {
|
|
|
34
44
|
PsSlider,
|
|
35
45
|
PsSwitch,
|
|
36
46
|
PsInput,
|
|
37
|
-
PsToggle
|
|
47
|
+
PsToggle,
|
|
48
|
+
PsAccordion,
|
|
49
|
+
PsAccordionItem,
|
|
50
|
+
PsChips,
|
|
51
|
+
PsDataTable,
|
|
52
|
+
PsDataTableItem
|
|
38
53
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import PsAccordionItem, {iconTypes, fontCss} from "../components/accordion/PsAccordionItem.vue";
|
|
2
|
+
import PsAccordion, {sizes} from "../components/accordion/PsAccordion.vue";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Components/Accordion',
|
|
6
|
+
component: PsAccordion,
|
|
7
|
+
subcomponents: { PsAccordionItem },
|
|
8
|
+
argTypes:{
|
|
9
|
+
size: { control: { type: 'select', options: sizes } },
|
|
10
|
+
iconType: {control : {type: 'select', options: iconTypes}},
|
|
11
|
+
fontCss: {control : { type: 'select', options: fontCss}}
|
|
12
|
+
},
|
|
13
|
+
args: {
|
|
14
|
+
title: 'Section 1',
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const AccordionItem = (args, { argTypes }) => ({
|
|
19
|
+
props: Object.keys(argTypes, args),
|
|
20
|
+
components: { PsAccordionItem },
|
|
21
|
+
template: '<PsAccordionItem v-bind="$props"><p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptates, illum.</p></PsAccordionItem>',
|
|
22
|
+
})
|
|
23
|
+
AccordionItem.parameters = {
|
|
24
|
+
controls: {
|
|
25
|
+
include: ['title', 'iconType', 'fontCss']
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const Accordion = (args, { argTypes }) => ({
|
|
30
|
+
props: Object.keys(argTypes, args),
|
|
31
|
+
components: { PsAccordion, PsAccordionItem },
|
|
32
|
+
template: '<PsAccordion v-bind="$props"><PsAccordionItem v-bind="$props"><p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptates, illum.</p></PsAccordionItem><PsAccordionItem v-bind="$props"/></PsAccordion>',
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
|
|
@@ -13,19 +13,26 @@ const Template = (args, { argTypes }) => ({
|
|
|
13
13
|
components: { PsCheckbox },
|
|
14
14
|
data: () => {
|
|
15
15
|
return {
|
|
16
|
-
items:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
items: {
|
|
17
|
+
BUILDING_TYPE: {
|
|
18
|
+
label: 'Building Type',
|
|
19
|
+
key: 'BUILDING_TYPE'
|
|
20
|
+
},
|
|
21
|
+
CLIMATE_ZONE: {
|
|
22
|
+
label: 'Climate Zone',
|
|
23
|
+
key: 'CLIMATE_ZONE'
|
|
24
|
+
},
|
|
25
|
+
YEAR: {
|
|
26
|
+
label: "Year",
|
|
27
|
+
key: "YEAR"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
21
30
|
selected: []
|
|
22
31
|
}
|
|
23
32
|
},
|
|
24
33
|
template: `
|
|
25
34
|
<div>
|
|
26
|
-
<PsCheckbox v-bind="$props"
|
|
27
|
-
<PsCheckbox v-bind="$props" label="Label 2" inputValue="2" v-model="selected" />
|
|
28
|
-
<PsCheckbox v-bind="$props" label="Label 3" inputValue="3" v-model="selected" />
|
|
35
|
+
<PsCheckbox v-bind="$props" v-for="(item, key) in items" :label="item.label" :inputValue="item.key" v-model="selected" />
|
|
29
36
|
<p>Checked: {{ selected }}</p>
|
|
30
37
|
</div>
|
|
31
38
|
`
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import PsChips, { type } from "../components/chips/PsChips.vue";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Components/Chips',
|
|
5
|
+
component: PsChips,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const Template = (args, { argTypes }) => ({
|
|
9
|
+
props: Object.keys(argTypes),
|
|
10
|
+
components: { PsChips },
|
|
11
|
+
template: `<div >
|
|
12
|
+
<PsChips v-bind='$props'/>
|
|
13
|
+
</div>
|
|
14
|
+
`
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
export const Simple = Template.bind({});
|
|
18
|
+
Simple.args = {
|
|
19
|
+
title: 'Simple Chip',
|
|
20
|
+
icon:"",
|
|
21
|
+
type: 'text'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const SimpleWithIcon = Template.bind({});
|
|
25
|
+
SimpleWithIcon.args = {
|
|
26
|
+
title: 'Simple With Icon',
|
|
27
|
+
icon: 'home',
|
|
28
|
+
type: 'text'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const Radio = Template.bind({});
|
|
32
|
+
Radio.args = {
|
|
33
|
+
title: 'Radio Chip',
|
|
34
|
+
type:'radio'
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const Checkbox = Template.bind({});
|
|
38
|
+
Checkbox.args = {
|
|
39
|
+
title: 'Checkbox Chip',
|
|
40
|
+
type: 'checkbox'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const Rich = Template.bind({});
|
|
44
|
+
Rich.args = {
|
|
45
|
+
title: 'Rich chips',
|
|
46
|
+
type: 'text',
|
|
47
|
+
icon: 'description',
|
|
48
|
+
rich: 'true'
|
|
49
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import PsDataTable, { alignment } from '../components/datatable/PsDataTable.vue';
|
|
2
|
+
import PsDataTableItem from '../components/datatable/PsDataTableItem.vue';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Components/DataTable',
|
|
6
|
+
component: PsDataTable,
|
|
7
|
+
subcomponents: { PsDataTableItem },
|
|
8
|
+
argTypes: {
|
|
9
|
+
align: { control: { type: 'select', options: alignment } },
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const Template = (args, { argTypes }) => ({
|
|
14
|
+
props: Object.keys(argTypes),
|
|
15
|
+
components: {PsDataTable} ,
|
|
16
|
+
template: `<PsDataTable v-bind="$props" />`
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const RichTemplate = (args, { argTypes } ) => ({
|
|
20
|
+
props: Object.keys(argTypes),
|
|
21
|
+
components: {PsDataTable, PsDataTableItem},
|
|
22
|
+
template: `<PsDataTable v-bind="$props">
|
|
23
|
+
<PsDataTableItem v-bind="$props"/>
|
|
24
|
+
</PsDataTable>
|
|
25
|
+
`
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
export const Simple = Template.bind({});
|
|
30
|
+
Simple.args = {
|
|
31
|
+
header: ['year', 'month', 'sale'],
|
|
32
|
+
data: [{ year: '1992', month: '12', sale: '1000.00' }, { year: '1989', month: '02', sale: '1200.00' }],
|
|
33
|
+
footer: ['Footer 1', 'Footer 2', 'Footer 3'],
|
|
34
|
+
type: 'simple'
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const Rich = RichTemplate.bind({});
|
|
38
|
+
Rich.args = {
|
|
39
|
+
header: ['header 1', 'header 2', 'header 3'],
|
|
40
|
+
data:[[ [ 20, -3], [ 20, 2], [ 20, 2] ], { header4: { value: 20, delta: 2}, header5: { value: 20, delta: 2}, header6: { value: 20, delta: 2} }],
|
|
41
|
+
footer: ['Footer 1', 'Footer 2', 'Footer 3'],
|
|
42
|
+
type: 'rich'
|
|
43
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import PsDropdown from '../components/forms/PsDropdown.vue';
|
|
2
|
+
export default {
|
|
3
|
+
title: 'Components/Dropdown',
|
|
4
|
+
component: PsDropdown,
|
|
5
|
+
argTypes: {
|
|
6
|
+
},
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const Template = (args, { argTypes }) => ({
|
|
10
|
+
props: Object.keys(argTypes),
|
|
11
|
+
components: { PsDropdown },
|
|
12
|
+
template: `
|
|
13
|
+
<div>
|
|
14
|
+
<PsDropdown
|
|
15
|
+
buttonClasses="psui-p-3 "
|
|
16
|
+
>
|
|
17
|
+
<template v-slot:dropdownTrigger>
|
|
18
|
+
<div>Custom Trigger</div>
|
|
19
|
+
</template>
|
|
20
|
+
<template v-slot:items>
|
|
21
|
+
<ul>
|
|
22
|
+
<li>Small list of the drop down</li>
|
|
23
|
+
</ul>
|
|
24
|
+
</template>
|
|
25
|
+
</PsDropdown>
|
|
26
|
+
</div>
|
|
27
|
+
`
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const CustomTrigger = Template.bind({});
|
|
31
|
+
CustomTrigger.args = {
|
|
32
|
+
title: 'Custom trigger'
|
|
33
|
+
};
|
|
34
|
+
|
|
@@ -9,13 +9,29 @@ export default {
|
|
|
9
9
|
const Template = (args, { argTypes }) => ({
|
|
10
10
|
props: Object.keys(argTypes),
|
|
11
11
|
components: { PsRadioButton },
|
|
12
|
+
data: () => {
|
|
13
|
+
return {
|
|
14
|
+
selectedValue: '',
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
methods: {
|
|
18
|
+
changeValue(newValue) {
|
|
19
|
+
this.selectedValue = newValue
|
|
20
|
+
}
|
|
21
|
+
},
|
|
12
22
|
template: `
|
|
13
|
-
<
|
|
23
|
+
<div>
|
|
24
|
+
<div>
|
|
25
|
+
<PsRadioButton v-bind="$props" name="options" label="Label 1" value="1" @change="changeValue" />
|
|
26
|
+
<PsRadioButton v-bind="$props" name="options" label="Label 2" value="2" @change="changeValue" />
|
|
27
|
+
<PsRadioButton v-bind="$props" name="options" label="Label 3" value="3" @change="changeValue" />
|
|
28
|
+
<div class="result">
|
|
29
|
+
Radio button selection: {{selectedValue}}
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
14
33
|
`
|
|
15
34
|
});
|
|
16
35
|
|
|
17
36
|
export const Default = Template.bind({});
|
|
18
|
-
Default.args = {
|
|
19
|
-
label: 'Label'
|
|
20
|
-
};
|
|
21
|
-
|
|
37
|
+
Default.args = {};
|
|
@@ -25,14 +25,14 @@ const Template = (args, { argTypes }) => ({
|
|
|
25
25
|
export const Big = Template.bind({});
|
|
26
26
|
Big.args = {
|
|
27
27
|
size: 'big',
|
|
28
|
-
active:
|
|
28
|
+
active: true,
|
|
29
29
|
label: 'Switch Big',
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export const Small = Template.bind({});
|
|
33
33
|
Small.args = {
|
|
34
34
|
size: 'small',
|
|
35
|
-
active:
|
|
35
|
+
active: true,
|
|
36
36
|
label: 'Switch Small',
|
|
37
37
|
};
|
|
38
38
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const randomString = (length) => {
|
|
2
|
+
var result = '';
|
|
3
|
+
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
4
|
+
var charactersLength = characters.length;
|
|
5
|
+
for ( var i = 0; i < length; i++ ) {
|
|
6
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
7
|
+
}
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const getParentScrollableEl = (node) => {
|
|
12
|
+
|
|
13
|
+
if (node == null) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (node.scrollHeight > node.clientHeight) {
|
|
18
|
+
return node;
|
|
19
|
+
} else {
|
|
20
|
+
return getParentScrollableEl(node.parentNode);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|