@policystudio/policy-studio-ui-vue 1.0.16 → 1.0.20

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 (51) hide show
  1. package/.eslintrc.js +67 -0
  2. package/.storybook/main.js +2 -1
  3. package/.storybook/preview.js +1 -1
  4. package/README.md +8 -0
  5. package/babel.config.js +3 -0
  6. package/backup-package-lock.json +37194 -0
  7. package/{src/assets/scss/tailwind.css → dist/css/psui_styles.css} +2213 -2735
  8. package/package.json +29 -19
  9. package/src/assets/images/check-checkbox-button.svg +1 -0
  10. package/src/assets/images/radio-checked-button.svg +1 -0
  11. package/src/assets/scss/base.scss +1 -1
  12. package/src/components/accordion/PsAccordion.vue +44 -0
  13. package/src/components/accordion/PsAccordionItem.vue +102 -0
  14. package/src/components/buttons/PsButton.vue +36 -13
  15. package/src/components/chips/PsChips.vue +164 -0
  16. package/src/components/controls/PsCheckbox.vue +3 -3
  17. package/src/components/controls/PsDraggable.vue +27 -2
  18. package/src/components/controls/PsRadioButton.vue +58 -57
  19. package/src/components/controls/PsSlider.vue +13 -12
  20. package/src/components/controls/PsSwitch.vue +76 -76
  21. package/src/components/datatable/PsDataTable.vue +89 -0
  22. package/src/components/datatable/PsDataTableItem.vue +57 -0
  23. package/src/components/forms/PsDropdown.vue +196 -0
  24. package/src/components/forms/PsInput.vue +9 -6
  25. package/src/components/tabs/PsTabHeader.vue +20 -21
  26. package/src/components/tooltip/PsDialogTooltip.vue +79 -0
  27. package/src/components/tooltip/PsRichTooltip.vue +38 -0
  28. package/src/components/tooltip/PsTooltip.vue +120 -0
  29. package/src/components/ui/PsIcon.vue +128 -0
  30. package/src/index.js +51 -22
  31. package/src/stories/Accordion.stories.js +35 -0
  32. package/src/stories/Button.stories.js +11 -11
  33. package/src/stories/Checkbox.stories.js +21 -14
  34. package/src/stories/Chips.stories.js +49 -0
  35. package/src/stories/Colors.stories.mdx +36 -35
  36. package/src/stories/Datatable.stories.js +50 -0
  37. package/src/stories/Dialog.stories.js +9 -9
  38. package/src/stories/Draggable.stories.js +24 -0
  39. package/src/stories/Dropdown.stories.js +34 -0
  40. package/src/stories/Input.stories.js +10 -10
  41. package/src/stories/RadioButton.stories.js +24 -8
  42. package/src/stories/Slider.stories.js +9 -9
  43. package/src/stories/Swith.stories.js +10 -10
  44. package/src/stories/TabHeader.stories.js +9 -9
  45. package/src/stories/Toast.stories.js +13 -13
  46. package/src/stories/Toggle.stories.js +29 -5
  47. package/src/stories/Tooltip.stories.js +113 -0
  48. package/src/util/GeneralFunctions.js +23 -0
  49. package/src/util/imageLoader.js +50 -0
  50. package/tailwind.config.js +19 -4
  51. package/src/assets/scss/tailwind.scss +0 -61088
@@ -1,21 +1,37 @@
1
- import PsRadioButton from '../components/controls/PsRadioButton.vue';
1
+ import PsRadioButton from '../components/controls/PsRadioButton.vue'
2
2
 
3
3
  export default {
4
4
  title: 'Components/Radio Button',
5
5
  component: PsRadioButton,
6
6
  argTypes: {},
7
- };
7
+ }
8
8
 
9
9
  const Template = (args, { argTypes }) => ({
10
10
  props: Object.keys(argTypes),
11
11
  components: { PsRadioButton },
12
+ data: () => {
13
+ return {
14
+ selectedValue: 2,
15
+ }
16
+ },
12
17
  template: `
13
- <PsRadioButton v-bind="$props" />
18
+ <div>
19
+ <div>
20
+ <PsRadioButton v-bind="$props" name="options" label="Label 1" value="1" v-model="selectedValue" />
21
+ <PsRadioButton v-bind="$props" name="options" label="Label 2" value="2" v-model="selectedValue" />
22
+ <PsRadioButton v-bind="$props" name="options" label="Label 3" value="3" v-model="selectedValue" />
23
+ <div class="result">
24
+ Radio button selection: {{selectedValue}}
25
+ </div>
26
+ </div>
27
+ </div>
14
28
  `
15
- });
29
+ })
16
30
 
17
- export const Default = Template.bind({});
18
- Default.args = {
19
- label: 'Label'
20
- };
31
+ export const Default = Template.bind({})
32
+ Default.args = {}
21
33
 
34
+ export const Small = Template.bind({})
35
+ Small.args = {
36
+ small: true
37
+ }
@@ -1,10 +1,10 @@
1
- import PsSlider from '../components/controls/PsSlider.vue';
1
+ import PsSlider from '../components/controls/PsSlider.vue'
2
2
  export default {
3
3
  title: 'Components/Slider',
4
4
  component: PsSlider,
5
5
  argTypes: {
6
6
  },
7
- };
7
+ }
8
8
 
9
9
  const Template = (args, { argTypes }) => ({
10
10
  props: Object.keys(argTypes),
@@ -14,27 +14,27 @@ const Template = (args, { argTypes }) => ({
14
14
  <PsSlider v-bind="$props" :value.sync="value" />
15
15
  </div>
16
16
  `
17
- });
17
+ })
18
18
 
19
- export const Label = Template.bind({});
19
+ export const Label = Template.bind({})
20
20
  Label.args = {
21
21
  min: 1,
22
22
  max: 100,
23
23
  value: 30,
24
24
  label: 'Score Label'
25
- };
25
+ }
26
26
 
27
- export const NoLabel = Template.bind({});
27
+ export const NoLabel = Template.bind({})
28
28
  NoLabel.args = {
29
29
  min: 1,
30
30
  max: 100,
31
31
  value: 15
32
- };
32
+ }
33
33
 
34
- export const Bubble = Template.bind({});
34
+ export const Bubble = Template.bind({})
35
35
  Bubble.args = {
36
36
  min: 1,
37
37
  max: 100,
38
38
  value: 23,
39
39
  bubble: true
40
- };
40
+ }
@@ -1,11 +1,11 @@
1
- import PsSwitch, { sizes } from '../components/controls/PsSwitch.vue';
1
+ import PsSwitch, { sizes } from '../components/controls/PsSwitch.vue'
2
2
  export default {
3
3
  title: 'Components/Switch',
4
4
  component: PsSwitch,
5
5
  argTypes: {
6
6
  size: { control: { type: 'select', options: sizes } }
7
7
  },
8
- };
8
+ }
9
9
 
10
10
  const Template = (args, { argTypes }) => ({
11
11
  props: Object.keys(argTypes),
@@ -17,22 +17,22 @@ const Template = (args, { argTypes }) => ({
17
17
  },
18
18
  template: `
19
19
  <div>
20
- <PsSwitch v-bind="$props" :active.sync="model" />
20
+ <PsSwitch v-bind="$props" v-model="model" />
21
+ <p>{{ model }}</p>
21
22
  </div>
22
23
  `
23
- });
24
+ })
24
25
 
25
- export const Big = Template.bind({});
26
+ export const Big = Template.bind({})
26
27
  Big.args = {
27
28
  size: 'big',
28
- active: false,
29
29
  label: 'Switch Big',
30
- };
30
+ }
31
31
 
32
- export const Small = Template.bind({});
32
+ export const Small = Template.bind({})
33
33
  Small.args = {
34
34
  size: 'small',
35
- active: false,
36
35
  label: 'Switch Small',
37
- };
36
+ small: true
37
+ }
38
38
 
@@ -1,4 +1,4 @@
1
- import PsTabHeader from '../components/tabs/PsTabHeader.vue';
1
+ import PsTabHeader from '../components/tabs/PsTabHeader.vue'
2
2
  const items = ['Existing Buildings', 'New Constructions', 'Other tab']
3
3
  const item = items[0]
4
4
 
@@ -6,7 +6,7 @@ export default {
6
6
  title: 'Components/Tab Header',
7
7
  component: PsTabHeader,
8
8
  argTypes: {}
9
- };
9
+ }
10
10
  const Template = (args, { argTypes }) => ({
11
11
  props: Object.keys(argTypes),
12
12
  components: { PsTabHeader },
@@ -28,25 +28,25 @@ const Template = (args, { argTypes }) => ({
28
28
  </div>
29
29
  </div>
30
30
  `
31
- });
31
+ })
32
32
 
33
- export const Standard = Template.bind({});
33
+ export const Standard = Template.bind({})
34
34
  Standard.args = {
35
35
  theme: 'standard',
36
36
  items: items,
37
37
  selected: item
38
- };
38
+ }
39
39
 
40
- export const Underline = Template.bind({});
40
+ export const Underline = Template.bind({})
41
41
  Underline.args = {
42
42
  theme: 'underline',
43
43
  items: items,
44
44
  selected: item
45
- };
45
+ }
46
46
 
47
- export const Folder = Template.bind({});
47
+ export const Folder = Template.bind({})
48
48
  Folder.args = {
49
49
  theme: 'folder',
50
50
  items: items,
51
51
  selected: item
52
- };
52
+ }
@@ -1,4 +1,4 @@
1
- import PsToast, { typeOptions, fillOptions } from '../components/notifications/PsToast.vue';
1
+ import PsToast, { typeOptions, fillOptions } from '../components/notifications/PsToast.vue'
2
2
  export default {
3
3
  title: 'Components/Toast',
4
4
  component: PsToast,
@@ -6,7 +6,7 @@ export default {
6
6
  type: { control: { type: 'select', options: typeOptions } },
7
7
  fill: { control: { type: 'select', options: fillOptions } }
8
8
  },
9
- };
9
+ }
10
10
 
11
11
  const Template = (args, { argTypes }) => ({
12
12
  props: Object.keys(argTypes),
@@ -21,33 +21,33 @@ const Template = (args, { argTypes }) => ({
21
21
  <template v-if="${'default' in args}" v-slot>${args.default}</template>
22
22
  </PsToast>
23
23
  `
24
- });
24
+ })
25
25
 
26
- export const Info = Template.bind({});
26
+ export const Info = Template.bind({})
27
27
  Info.args = {
28
28
  type: 'info',
29
29
  message: 'This is an info alert',
30
- };
30
+ }
31
31
 
32
- export const Success = Template.bind({});
32
+ export const Success = Template.bind({})
33
33
  Success.args = {
34
34
  type: 'success',
35
35
  message: 'This is a success alert',
36
- };
36
+ }
37
37
 
38
- export const Warning = Template.bind({});
38
+ export const Warning = Template.bind({})
39
39
  Warning.args = {
40
40
  type: 'warning',
41
41
  message: 'This is a warning alert',
42
- };
42
+ }
43
43
 
44
- export const Error = Template.bind({});
44
+ export const Error = Template.bind({})
45
45
  Error.args = {
46
46
  type: 'error',
47
47
  message: 'This is an error alert',
48
- };
48
+ }
49
49
 
50
- export const Actions = Template.bind({});
50
+ export const Actions = Template.bind({})
51
51
  Actions.args = {
52
52
  type: 'info',
53
53
  message: 'This is an info alert with actions',
@@ -55,4 +55,4 @@ Actions.args = {
55
55
  <span class="psui-cursor-pointer" @click="teste('Callback Action 1')">ACTION1</span>
56
56
  <span class="psui-cursor-pointer" @click="teste('Callback Action 2')">ACTION2</span>
57
57
  `
58
- };
58
+ }
@@ -1,9 +1,9 @@
1
- import PsToggle from '../components/controls/PsToggle.vue';
1
+ import PsToggle from '../components/controls/PsToggle.vue'
2
2
  export default {
3
3
  title: 'Components/Toggle',
4
4
  component: PsToggle,
5
5
  argTypes: {},
6
- };
6
+ }
7
7
  const items = ['Option 1', 'Option 2', 'Option 3']
8
8
  const selected = 'Option 2'
9
9
 
@@ -13,10 +13,34 @@ const Template = (args, { argTypes }) => ({
13
13
  template: `
14
14
  <PsToggle v-bind="$props" :selected.sync="selected" />
15
15
  `
16
- });
16
+ })
17
17
 
18
- export const Default = Template.bind({});
18
+ export const Default = Template.bind({})
19
19
  Default.args = {
20
20
  items: items,
21
21
  selected: selected
22
- };
22
+ }
23
+
24
+
25
+ /**
26
+ * Hey Luciano!
27
+ * Adicionei este script aqui pois não entendi como criar uma story com script em MDX ou algo que rode geral, saca?
28
+ * Mas é uma função simples para copiar o HEX das cores...
29
+ * Se quiser dar uma melhorada nessa parte, fique a vontade meu chegado! TMJ
30
+ */
31
+ window.addEventListener('click', (ev) => {
32
+ if(ev.target.classList.contains('click-to-copy')) {
33
+ copyText(ev.target.dataset.toCopy)
34
+ }
35
+ })
36
+
37
+ function copyText(textToCopy) {
38
+ var myTemporaryInputElement = document.createElement("input")
39
+ myTemporaryInputElement.type = "text"
40
+ myTemporaryInputElement.value = textToCopy
41
+ document.body.appendChild(myTemporaryInputElement)
42
+ myTemporaryInputElement.select()
43
+ document.execCommand("Copy")
44
+ document.body.removeChild(myTemporaryInputElement)
45
+ alert('Item copied to clipboard!')
46
+ }
@@ -0,0 +1,113 @@
1
+ import PsTooltip from '../components/tooltip/PsTooltip.vue'
2
+ import PsRichTooltip from '../components/tooltip/PsRichTooltip.vue'
3
+ import PsDialogTooltip,{ CSSCOLORS} from '../components/tooltip/PsDialogTooltip.vue'
4
+
5
+ export default {
6
+ title: 'Components/Tooltip',
7
+ component: PsTooltip,
8
+ subcomponents: {PsRichTooltip, PsDialogTooltip}
9
+ }
10
+
11
+ const TemplateDialog = (args, {argTypes}) => ({
12
+ props: Object.keys(argTypes),
13
+ components: {PsDialogTooltip},
14
+ template: `
15
+ <div style='display: flex; justify-content: flex-end;'>
16
+ <PsDialogTooltip v-bind='$props'>
17
+ <p>Trigger</p>
18
+ </PsDialogTooltip>
19
+ <div>
20
+ `,
21
+ argTypes:{
22
+ type: { control : { type: 'select', options: CSSCOLORS}}
23
+ }
24
+ })
25
+
26
+ const TemplateRich = (args,{argTypes})=>({
27
+ props: Object.keys(argTypes),
28
+ components: {PsRichTooltip},
29
+ template: `
30
+ <div style='display: flex; justify-content: flex-end;'>
31
+ <PsRichTooltip v-bind='$props'>
32
+ <p>Trigger</p>
33
+ </PsRichTooltip>
34
+ </div>
35
+ `
36
+ })
37
+
38
+
39
+ const TemplateRight = (args,{argTypes})=>({
40
+ props: Object.keys(argTypes),
41
+ components: {PsTooltip},
42
+ template: `
43
+ <div style='display: flex; justify-content: flex-end;'>
44
+ <PsTooltip v-bind='$props'>
45
+ <template v-slot:trigger>
46
+ Trigger
47
+ </template>
48
+ </PsTooltip>
49
+ </div>
50
+ `
51
+ })
52
+
53
+ const TemplateMiddle = (args, {argTypes})=> ({
54
+ props: Object.keys(argTypes),
55
+ components: {PsTooltip},
56
+ template: `
57
+ <div style='display: flex; justify-content: center;'>
58
+ <PsTooltip v-bind='$props'>
59
+ <template v-slot:trigger>
60
+ Trigger
61
+ </template>
62
+ </PsTooltip>
63
+ </div>
64
+ `
65
+ })
66
+
67
+ const TemplateLeft = (args, {argTypes}) => ({
68
+ props: Object.keys(argTypes),
69
+ components: {PsTooltip},
70
+ template: `
71
+ <div style='display: flex; justify-content: flex-start;'>
72
+ <PsTooltip v-bind='$props'>
73
+ <template v-slot:trigger>
74
+ Trigger
75
+ </template>
76
+ </PsTooltip>
77
+ </div>
78
+ `
79
+ })
80
+
81
+ export const Dialog = TemplateDialog.bind({})
82
+ Dialog.args = {
83
+ text: 'Air seal all ductwork to a final duct leakage value of 10% of nominal airflow.',
84
+ title: 'Duct Sealing',
85
+ buttonText: 'More info',
86
+ cssClass: 'psui-w-32',
87
+ type: 'color'
88
+ }
89
+
90
+ export const Rich = TemplateRich.bind({})
91
+ Rich.args = {
92
+ type: 'red',
93
+ title: 'This is a test!!',
94
+ cssClass: 'psui-w-32'
95
+ }
96
+
97
+ export const RightSide = TemplateRight.bind({})
98
+ RightSide.args = {
99
+ title: 'This is a test!!!',
100
+ type: 'red',
101
+ }
102
+
103
+ export const Middle = TemplateMiddle.bind({})
104
+ Middle.args = {
105
+ title: 'This is a test!!!',
106
+ type: 'blue',
107
+ }
108
+
109
+ export const Left = TemplateLeft.bind({})
110
+ Left.args = {
111
+ title: 'This is a test!!!',
112
+ type: 'gray',
113
+ }
@@ -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
+ }
@@ -0,0 +1,50 @@
1
+ export default ({ imageUrl, onProgress = null, returnsBase64 = true }) => {
2
+ return new Promise((resolve, reject) => {
3
+ var xhr = new XMLHttpRequest()
4
+ var notifiedNotComputable = false
5
+
6
+ xhr.open('GET', imageUrl, true)
7
+ xhr.responseType = 'arraybuffer'
8
+
9
+ xhr.onprogress = (ev) => {
10
+ if (ev.lengthComputable) {
11
+ let progress = parseInt((ev.loaded / ev.total) * 100)
12
+ if(onProgress) onProgress(progress)
13
+ } else {
14
+ if (!notifiedNotComputable) {
15
+ notifiedNotComputable = true
16
+ if(onProgress) onProgress(-1)
17
+ }
18
+ }
19
+ }
20
+
21
+ xhr.onloadend = () => {
22
+ const contentType = xhr.getResponseHeader("Content-Type")
23
+ if (!contentType.includes('image')) {
24
+ reject(xhr)
25
+ } else {
26
+ if (!notifiedNotComputable) {
27
+ if(onProgress) onProgress(100)
28
+ }
29
+
30
+ if(!returnsBase64) {
31
+ resolve()
32
+ } else {
33
+ var options = {}
34
+ var headers = xhr.getAllResponseHeaders()
35
+ var mime = headers.match(/^Content-Type\\:\s*(.*?)$/mi)
36
+ if (mime && mime[1]) options.type = mime[1]
37
+ var blob = new Blob([this.response], options)
38
+ resolve(window.URL.createObjectURL(blob))
39
+ }
40
+ }
41
+ }
42
+
43
+ xhr.onerror = () => {
44
+ console.log('asd')
45
+ reject()
46
+ }
47
+
48
+ xhr.send()
49
+ })
50
+ }
@@ -49,6 +49,7 @@ module.exports = {
49
49
  'sans': ['Lato'],
50
50
  },
51
51
  fontSize: {
52
+ big:['16px','130%'],
52
53
  small: ['14px', '130%'],
53
54
  xsmall: ['12px', '130%'],
54
55
  accent: ['14px', '130%', { letterSpacing: '0.6px' }],
@@ -75,14 +76,28 @@ module.exports = {
75
76
  xl: '0px 0px 20px rgba(0, 0, 0, 0.05), 0px 30px 60px rgba(0, 0, 0, 0.2)',
76
77
  inner: '0px 1px 0px #FFFFFF, inset 0px 1px 2px rgba(0, 0, 0, 0.1)',
77
78
  none: 'none',
78
- },
79
- extend: {},
79
+ },
80
+ borderColor: theme => ({
81
+ ...theme('colors'),
82
+ DEFAULT: theme('colors.blue-70', 'currentColor'),
83
+ }),
84
+ divideColor: theme => ({
85
+ ...theme('colors'),
86
+ }),
87
+ extend: {
88
+ divideOpacity: {
89
+ '10': '0.1',
90
+ '20': '0.2',
91
+ '95': '0.95',
92
+ }
93
+ },
80
94
  },
81
95
  variants: {
82
96
  boxShadow: ['active'],
83
97
  borderRadius: ['last', 'first'],
84
- backgroundColor: ['responsive', 'hover', 'active', 'focus', 'group-hover', 'even', 'first'],
85
- textColor: ['responsive', 'hover', 'active', 'focus', 'group-hover', 'first'],
98
+ backgroundColor: ['responsive', 'hover', 'active', 'focus', 'group-hover', 'even', 'first', 'disabled'],
99
+ textColor: ['responsive', 'hover', 'active', 'focus', 'group-hover', 'first', 'disabled'],
100
+ borderColor: ['disabled'],
86
101
  extend: {
87
102
  },
88
103
  },