@thinkpixellab-public/px-vue 3.0.42 → 4.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 (115) hide show
  1. package/README.md +22 -64
  2. package/{components → bases}/PxBase.vue +4 -0
  3. package/bases/PxBaseDate.vue +49 -0
  4. package/bases/PxBaseIcon.vue +32 -0
  5. package/bases/PxBaseItems.vue +105 -0
  6. package/bases/PxBaseItemsSelect.vue +415 -0
  7. package/{components → bases}/PxBaseMobileAware.vue +4 -2
  8. package/{components → bases}/PxBaseResize.vue +11 -4
  9. package/bases/PxBaseScroll.vue +46 -0
  10. package/bases/PxBaseToggle.vue +67 -0
  11. package/bases/PxBaseUniqueId.vue +18 -0
  12. package/{components → bases}/PxBaseVariants.vue +10 -0
  13. package/{components → bases}/PxBaseVariantsOverride.vue +4 -2
  14. package/{components → bases}/PxBaseVisible.vue +2 -0
  15. package/components/PxArrowScroller.vue +9 -7
  16. package/components/PxAspect.vue +28 -10
  17. package/components/PxAutoClamp.vue +3 -1
  18. package/components/PxBalancedText.vue +22 -9
  19. package/components/PxButton.vue +42 -0
  20. package/components/PxCalendar.vue +3 -2
  21. package/components/PxCard.vue +2 -3
  22. package/components/PxCardGrid.vue +3 -1
  23. package/components/PxClock.vue +5 -2
  24. package/components/PxContain.vue +3 -1
  25. package/components/PxCopyText.vue +6 -2
  26. package/components/PxDatePicker.vue +6 -4
  27. package/components/PxDropdown.vue +77 -61
  28. package/components/PxExpander.vue +36 -20
  29. package/components/PxFit.vue +4 -1
  30. package/components/PxFlex.vue +27 -17
  31. package/components/PxFloat.vue +151 -77
  32. package/components/PxIcon.vue +88 -15
  33. package/components/PxIconButton.vue +43 -29
  34. package/components/PxIdUniquer.vue +5 -1
  35. package/components/PxModal.vue +1 -0
  36. package/components/PxNineGrid.vue +4 -0
  37. package/components/PxPivot.vue +20 -8
  38. package/components/PxPopup.vue +8 -6
  39. package/components/PxProgressCircle.vue +3 -3
  40. package/components/PxQrCode.vue +6 -2
  41. package/components/PxRadioButton.vue +30 -10
  42. package/components/PxResizer.vue +207 -0
  43. package/components/PxSideDrawer.vue +16 -10
  44. package/components/PxSlideTransition.vue +3 -1
  45. package/components/PxSlides.vue +4 -3
  46. package/components/PxSpinner.vue +4 -2
  47. package/components/PxSvg.vue +97 -45
  48. package/components/PxSwiperSlide.vue +3 -7
  49. package/components/PxSyncHeight.vue +3 -0
  50. package/components/PxTable.vue +8 -2
  51. package/components/PxToggle.vue +9 -7
  52. package/components/PxToggleButton.vue +94 -60
  53. package/components/PxToggleButtonList.vue +61 -38
  54. package/components/PxTransitionExpand.vue +8 -1
  55. package/components/PxValidator.vue +5 -2
  56. package/package.json +37 -29
  57. package/plugins/common-client.js +19 -8
  58. package/plugins/common.js +35 -53
  59. package/plugins/filters/kebab.js +1 -1
  60. package/plugins/filters/unkebab.js +11 -0
  61. package/stories/PxAspect.stories.js +62 -0
  62. package/stories/PxBalancedText.stories.js +57 -0
  63. package/stories/PxButton.stories.js +44 -0
  64. package/stories/PxDropdown.stories.js +49 -0
  65. package/stories/PxExpander.stories.js +31 -0
  66. package/stories/PxFloat.stories.js +69 -0
  67. package/stories/PxIcon.mdx +62 -0
  68. package/stories/PxIcon.stories.js +70 -0
  69. package/stories/PxPivot.stories.js +38 -0
  70. package/stories/PxRadioButton.stories.js +33 -0
  71. package/stories/PxSvg.stories.js +37 -0
  72. package/stories/PxToggleButton.stories.js +86 -0
  73. package/stories/PxToggleButtonList.stories.js +97 -0
  74. package/stories/assets/alpha.svg +6 -0
  75. package/stories/helpers/extractArgTypes.js +31 -0
  76. package/stories/helpers/sampleData.js +28 -0
  77. package/stories/helpers/scratch.vue +30 -0
  78. package/styles/px.scss +1 -1
  79. package/test/PxBaseItems.test.js +92 -0
  80. package/test/PxBaseItemsSelect.test.js +430 -0
  81. package/utils/getFeatherIcons.js +25 -0
  82. package/utils/hasSlot.js +9 -0
  83. package/utils/uniqueId.js +30 -0
  84. package/vite.config.js +34 -0
  85. package/assets/icons/calendar.svg +0 -6
  86. package/assets/icons/check.svg +0 -1
  87. package/assets/icons/close-sm.svg +0 -1
  88. package/assets/icons/close.svg +0 -1
  89. package/assets/icons/copy.svg +0 -1
  90. package/assets/icons/dropdown.svg +0 -1
  91. package/assets/icons/invalid.svg +0 -1
  92. package/assets/icons/menu.svg +0 -1
  93. package/assets/icons/nav-next.svg +0 -1
  94. package/assets/icons/nav-prev.svg +0 -1
  95. package/assets/icons/sort-asc.svg +0 -1
  96. package/assets/icons/sort-desc.svg +0 -1
  97. package/assets/test/README.md +0 -1
  98. package/assets/test/trash.svg +0 -8
  99. package/components/PxBaseDate.vue +0 -27
  100. package/components/PxBaseItems.vue +0 -72
  101. package/components/PxBaseItemsSelect.vue +0 -230
  102. package/components/PxBaseToggle.vue +0 -56
  103. package/components/PxFeatherIcon.vue +0 -29
  104. package/components/PxFeatherIconButton.vue +0 -19
  105. package/components/PxPortal.vue +0 -138
  106. package/components/PxPortalTarget.vue +0 -27
  107. package/components/PxStylesPreview.vue +0 -159
  108. package/components/PxSwiper.vue +0 -271
  109. package/components/PxTabs.vue +0 -1
  110. package/components/PxTextbox.vue +0 -90
  111. package/components/README.md +0 -0
  112. package/plugins/common-lib.js +0 -4
  113. package/plugins/common-vue3.js +0 -60
  114. package/plugins/mixins/eventBus.js +0 -30
  115. package/styles/helpers.scss +0 -14
package/README.md CHANGED
@@ -1,83 +1,41 @@
1
1
  # px-vue
2
2
 
3
- General purpose vue components that can be used across projects.
3
+ This template should help get you started developing with Vue 3 in Vite.
4
4
 
5
- ## Instructions
5
+ ## Recommended IDE Setup
6
6
 
7
- There is a basic dev environment in this project that use the VueCLI to serve the contents of
8
- dev.vue. This file can be thought of as a scratch file and shouldn't contain anything that needs to
9
- be preserved.
7
+ [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
10
8
 
11
- ## Structure
9
+ ## Customize configuration
12
10
 
13
- There is no primary entry point into this package so individual components or other files need to be imported directly. The package uses the same project structure as most of our other Vue projects (e.g. components in the /components folder, etc.).
11
+ See [Vite Configuration Reference](https://vitejs.dev/config/).
14
12
 
15
- ```javascript
16
- import PxToggle from '@thinkpixellab-public/px-vue/components/PxToggle.vue';
17
- ```
18
-
19
- ## Dependency on px-styles
20
-
21
- #### TLDR;
22
-
23
- When you import a component in your Vue project you may also need to include a file at the root of your project called `/px-styles.config.scss` that configures px-styles. If that file isn't present, many of the components in this package won't build.
24
-
25
- The most basic version of this file looks like this:
26
-
27
- ```scss
28
- /*
29
- px-styles.config.scss
30
- */
31
-
32
- // import the library (so we can configure it)
33
- @use '@thinkpixellab-public/px-styles' as px;
34
-
35
- // add configuration as needed (this is optional)
36
- @include px.config('colors:accent', purple);
13
+ ## Project Setup
37
14
 
38
- // initialize
39
- @include px.init();
15
+ ```sh
16
+ npm install
40
17
  ```
41
18
 
42
- #### Longer Explanation
19
+ ### Compile and Hot-Reload for Development
43
20
 
44
- Many of the components require px-styles. To ensure that px-styles has been initialized in the context of the project where the components are being used (e.g. has the correct configuration settings from the project, not arbitrary defaults or configuration set here), the components need to be able to reference a config file from that project.
45
-
46
- Here's the werid problem in a nutshell:
47
-
48
- 1. **SomeProject** imports **PxToggle.vue** from **@thinkpixellab\px-vue**
49
- 2. **PxToggle** style section imports **px-styles** from **@thinkpixellab/px-styles**
50
- 3. **px-styles** needs to be configured somehow but that configuration should come from **SomeProject** and sass is really bad at figuring that out dynamically.
51
-
52
- So, the solution becomes:
53
-
54
- 1. **PxToggle** looks for a file called **px-styles.scss** at the root of **SomeProject** which it expects to do the job of configuring px-styles.
55
-
56
- Because we use a hard coded path to px-styles.scss, that file will get resolved within the project that is importing the component instead the root of this package.
21
+ ```sh
22
+ npm run dev
23
+ ```
57
24
 
58
- ## Aliasing a Local Version During Development
25
+ ### Compile and Minify for Production
59
26
 
60
- To resolve `@thinkpixellab-public/px-vue` from a local folder during development, you can extend webpack as follows
27
+ ```sh
28
+ npm run build
29
+ ```
61
30
 
62
- ```js
63
- const path = require('path');
31
+ ### Run Unit Tests with [Vitest](https://vitest.dev/)
64
32
 
65
- // add to webpack config
66
- {
67
- resolve: {
68
- alias: {
69
- '@thinkpixellab-public/px-vue': path.resolve(__dirname, '../px-vue'),
70
- },
71
- }
72
- }
33
+ ```sh
34
+ npm run test:unit
73
35
  ```
74
36
 
75
- Note that if using vue-cli you need to add the above to a file called `vue.config.js` in the project root that looks like this:
37
+ ### Lint with [ESLint](https://eslint.org/)
76
38
 
77
- ```js
78
- module.exports = {
79
- configureWebpack: {
80
- // add the config from above
81
- },
82
- };
39
+ ```sh
40
+ npm run lint
83
41
  ```
@@ -1,3 +1,7 @@
1
+ <!--
2
+ #VUE3 Deprecate
3
+ -->
4
+
1
5
  <script>
2
6
  export default {
3
7
  methods: {
@@ -0,0 +1,49 @@
1
+ <!--
2
+ #VUE3 Todo
3
+ -->
4
+
5
+ <script>
6
+ /**
7
+ * Base class for managing a date-focused component. Exposes a v-model prop called date and a
8
+ * synced data value called dateValue. Both the v-model and :sync should work for two-way binding.
9
+ */
10
+
11
+ export default {
12
+ model: {
13
+ prop: 'date',
14
+ event: 'changed',
15
+ },
16
+
17
+ props: {
18
+ /**
19
+ * Publicly exposed date property (use .dateValue if modifying internally).
20
+ */
21
+ date: { type: Date, default: null },
22
+ },
23
+ data() {
24
+ return {
25
+ dateValue: this.date,
26
+ };
27
+ },
28
+ watch: {
29
+ date: {
30
+ handler(nv) {
31
+ this.dateValue = nv;
32
+ },
33
+ },
34
+ dateValue(nv) {
35
+ /**
36
+ * Fired when the date changes. Expected to primarily be used for :sync scenarios.
37
+ * @property {Date} nv The new date value.
38
+ */
39
+ this.$emit('update:date', nv);
40
+
41
+ /**
42
+ * Fired when the date changes.
43
+ * @property {Date} nv The new date value.
44
+ */
45
+ this.$emit('changed', nv);
46
+ },
47
+ },
48
+ };
49
+ </script>
@@ -0,0 +1,32 @@
1
+ <!--
2
+ #VUE3 Todo
3
+ -->
4
+
5
+ <!--
6
+ Adds properties that describe an icon that will ultimately be used with PxIcon. This can be used
7
+ as a mixin or just a guide for the correct pattern for expose PxIcon properties on a parent
8
+ component.
9
+
10
+ Usage:
11
+
12
+ <my-component>
13
+ <px-icon :icon="icon" v-bind="iconProps" />
14
+ </my-component>
15
+
16
+ -->
17
+
18
+ <script>
19
+ export default {
20
+ props: {
21
+ /**
22
+ * The icon for the component, either the name of an app-level icon or else the svg src for an icon.
23
+ */
24
+ icon: { type: String, default: null },
25
+
26
+ /**
27
+ * Additional customization for the icon (an object containing attributes that will be bound on the PxIcon instance). (see PxIcon for details).
28
+ */
29
+ iconProps: { type: Object, default: null },
30
+ },
31
+ };
32
+ </script>
@@ -0,0 +1,105 @@
1
+ <!--
2
+ #VUE3 Done (has breaking changes)
3
+
4
+ Provides basic items services for controls that maintain lists of items.
5
+
6
+ -->
7
+
8
+ <script>
9
+ function getFromItem(item, propOrFunc) {
10
+ if (!item) {
11
+ return undefined;
12
+ }
13
+
14
+ if (typeof propOrFunc == 'string' && propOrFunc in item) {
15
+ return item[propOrFunc];
16
+ }
17
+
18
+ if (typeof propOrFunc == 'function') {
19
+ return propOrFunc(item);
20
+ }
21
+
22
+ return undefined;
23
+ }
24
+
25
+ export default {
26
+ props: {
27
+ items: { type: Array },
28
+
29
+ /**
30
+ * Value needed to get a unique id from a given item. Can either be a string representing
31
+ * the property name or a function that takes the item and returns the id.
32
+ */
33
+ itemsKey: { type: [String, Function], default: 'id' },
34
+
35
+ /**
36
+ * Value needed to get a string representation (label) for a given item. Can either be a
37
+ * string representing the property name or a function that takes the item and returns the id.
38
+ */
39
+ itemsLabel: { type: [String, Function], default: 'label' },
40
+
41
+ /**
42
+ * Value needed to determine whether an item has been disabled. Can either be a string
43
+ * representing the property name or a function that takes the item and returns the id.
44
+ */
45
+ itemsDisabled: { type: [String, Function], default: 'disabled' },
46
+ },
47
+ computed: {
48
+ itemKeys() {
49
+ if (this.items && Array.isArray(this.items)) {
50
+ return this.items.map(item => this.getItemKey(item));
51
+ }
52
+ return [];
53
+ },
54
+ },
55
+ methods: {
56
+ getItem(key) {
57
+ if (typeof key !== 'undefined') {
58
+ return this.items.find(item => this.getItemKey(item) === key);
59
+ }
60
+ return undefined;
61
+ },
62
+
63
+ getItemKey(item) {
64
+ if (!this.isValidItem(item)) {
65
+ return undefined;
66
+ }
67
+ return getFromItem(item, this.itemsKey);
68
+ },
69
+
70
+ getItemLabel(item) {
71
+ if (!this.isValidItem(item)) {
72
+ return undefined;
73
+ }
74
+ return getFromItem(item, this.itemsLabel);
75
+ },
76
+
77
+ getItemDisabled(item) {
78
+ if (!this.isValidItem(item)) {
79
+ return undefined;
80
+ }
81
+ return getFromItem(item, this.itemsDisabled);
82
+ },
83
+
84
+ getItemKeyLabel(key) {
85
+ const item = this.getItem(key);
86
+ if (item) {
87
+ return this.getItemLabel(item);
88
+ }
89
+ return undefined;
90
+ },
91
+
92
+ getItemKeyIndex(key) {
93
+ return (this.items || []).indexOf(this.getItem(key));
94
+ },
95
+
96
+ isValidItem(item) {
97
+ return !!this.items.includes(item);
98
+ },
99
+
100
+ isValidItemKey(key) {
101
+ return !!this.itemKeys.includes(key);
102
+ },
103
+ },
104
+ };
105
+ </script>