@thinkpixellab-public/px-vue 4.0.23 → 4.0.25

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.
@@ -0,0 +1,10 @@
1
+ {
2
+ "semi": true,
3
+ "arrowParens": "avoid",
4
+ "singleQuote": true,
5
+ "tabWidth": 4,
6
+ "printWidth": 100,
7
+ "bracketSpacing": true,
8
+ "htmlWhitespaceSensitivity": "ignore",
9
+ "endOfLine": "auto"
10
+ }
@@ -25,7 +25,7 @@ export default {
25
25
 
26
26
  props: {
27
27
  // TEMP-MIGRATION
28
- value: { default: null },
28
+ modelValue: { default: null },
29
29
 
30
30
  /**
31
31
  * Set the selection as either a single item key or an array of item keys.
@@ -116,11 +116,11 @@ export default {
116
116
  },
117
117
 
118
118
  watch: {
119
- // TEMP-MIGRATION
120
- value: {
119
+ // VUE3 MIGRATION, can remove once complete
120
+ modelValue: {
121
121
  immediate: true,
122
122
  handler(nv) {
123
- if (nv != null) {
123
+ if (nv) {
124
124
  const name =
125
125
  'bem' in this ? this.bem() : this.$options?.name || 'UnknownComponent';
126
126
  console.error(
@@ -1,6 +1,6 @@
1
1
  <script>
2
2
  import isServer from '../utils/isServer';
3
- import { cssEmFallback } from '../utils/cssStr.js';
3
+ import { cssUnitScale, cssEmFallback } from '../utils/cssStr.js';
4
4
 
5
5
  export default {
6
6
  emits: [
@@ -106,8 +106,24 @@ export default {
106
106
  calcSrc() {
107
107
  return this.src;
108
108
  },
109
+ calcAspectRatio() {
110
+ if (this.svgViewBox) {
111
+ const viewBox = this.svgViewBox.split(' ');
112
+ const width = parseFloat(viewBox[2]);
113
+ const height = parseFloat(viewBox[3]);
114
+ if (width && height) {
115
+ return width / height;
116
+ }
117
+ }
118
+ if (this.svgWidth && this.svgHeight) {
119
+ return this.svgWidth / this.svgHeight;
120
+ }
121
+
122
+ // fallback is 1:1
123
+ return 16 / 9;
124
+ },
109
125
  calcHeight() {
110
- if (!this.size) {
126
+ if (!this.size && this.svgHeight) {
111
127
  return this.svgHeight;
112
128
  }
113
129
 
@@ -115,11 +131,15 @@ export default {
115
131
  return cssEmFallback(this.size);
116
132
  }
117
133
 
118
- // equivalent of 'auto' (but needs to be a number or else the parse shows console errors)
119
- return '100%';
134
+ if (this.size && this.calcAspectRatio) {
135
+ return cssUnitScale(cssEmFallback(this.size), 1 / this.calcAspectRatio);
136
+ }
137
+
138
+ //
139
+ return '100';
120
140
  },
121
141
  calcWidth() {
122
- if (!this.size) {
142
+ if (!this.size && this.svgWidth) {
123
143
  return this.svgWidth;
124
144
  }
125
145
 
@@ -127,8 +147,12 @@ export default {
127
147
  return cssEmFallback(this.size);
128
148
  }
129
149
 
150
+ if (this.size && this.calcAspectRatio) {
151
+ return cssUnitScale(cssEmFallback(this.size), this.calcAspectRatio);
152
+ }
153
+
130
154
  // equivalent of 'auto' (but needs to be a number or else the parse shows console errors)
131
- return '100%';
155
+ return '100';
132
156
  },
133
157
  calcStyle() {
134
158
  return null;
@@ -172,18 +196,20 @@ export default {
172
196
  let width =
173
197
  svg.width.baseVal.unitType == 1 || svg.width.baseVal.unitType == 5
174
198
  ? parseFloat(svg.width.baseVal.value)
175
- : viewBox.width;
199
+ : svg.viewBox?.width || 0;
176
200
  let height =
177
201
  svg.height.baseVal.unitType == 1 || svg.height.baseVal.unitType == 5
178
202
  ? parseFloat(svg.height.baseVal.value)
179
- : viewBox.height;
203
+ : svg.viewBox?.height || 0;
180
204
 
181
205
  // save as data values
182
- this.svgViewBox = viewBox
183
- ? `${viewBox.x} ${viewBox.y} ${viewBox.width} ${viewBox.height}`
184
- : `0 0 ${width} ${height}`;
185
- this.svgWidth = width;
186
- this.svgHeight = height;
206
+ if (viewBox?.width && viewBox?.height) {
207
+ this.svgViewBox = viewBox
208
+ ? `${viewBox.x} ${viewBox.y} ${viewBox.width} ${viewBox.height}`
209
+ : `0 0 ${width} ${height}`;
210
+ this.svgWidth = width;
211
+ this.svgHeight = height;
212
+ }
187
213
  }
188
214
 
189
215
  // string replace
@@ -44,7 +44,7 @@
44
44
  <div ref="dialog" :class="bem('dialog')">
45
45
  <px-calendar :class="bem('calendar')" v-model:date="dateValue" />
46
46
  <div :class="bem('clock')" v-if="clock">
47
- <px-clock v-model="dateValue" />
47
+ <px-clock v-model:date="dateValue" />
48
48
  </div>
49
49
  </div>
50
50
  </template>
@@ -7,7 +7,7 @@
7
7
  <px-icon-button :class="bem('button')" :src="currentButtonIcon" @click="buttonClick" />
8
8
  <px-scrubber
9
9
  :class="bem('scrubber')"
10
- v-model="progress"
10
+ v-model:progress="progress"
11
11
  @seek="seek"
12
12
  @dragstart="dragStart"
13
13
  @dragend="dragEnd"
@@ -4,7 +4,7 @@
4
4
  Creates a toggle button (a control with the appearance of a normal button that can be toggle
5
5
  between an on/off state).
6
6
 
7
- <px-radio-button v-model="checked" />
7
+ <px-radio-button v-model:checked="checked" />
8
8
  -->
9
9
 
10
10
  <template>
@@ -4,7 +4,7 @@
4
4
  Creates a toggle button (a control with the appearance of a normal button that can be toggle
5
5
  between an on/off state).
6
6
 
7
- <px-toggle :v-model="isChecked" variant="sm" />
7
+ <px-toggle v-model:checked="isChecked" variant="sm" />
8
8
  -->
9
9
 
10
10
  <template>
@@ -109,7 +109,7 @@
109
109
  }"
110
110
  >
111
111
  <px-dropdown
112
- v-model="validateThree"
112
+ v-model:selected="validateThree"
113
113
  tag="button"
114
114
  trigger="click"
115
115
  :items="fruits"
@@ -214,20 +214,20 @@
214
214
  <px-test test-id="px-date-picker" name="px-date-picker">
215
215
  <px-flex vertical align="center" gap="1">
216
216
  <span>Selected Date: {{ currentDateNull }}</span>
217
- <px-date-picker mode="textbox" v-model="currentDateNull" />
218
- <px-date-picker mode="textbox" clock v-model="currentDateNull" />
219
- <px-date-picker v-model="currentDateNull" />
220
- <px-date-picker time v-model="currentDateNull" />
217
+ <px-date-picker mode="textbox" v-model:date="currentDateNull" />
218
+ <px-date-picker mode="textbox" clock v-model:date="currentDateNull" />
219
+ <px-date-picker v-model:date="currentDateNull" />
220
+ <px-date-picker time v-model:date="currentDateNull" />
221
221
  </px-flex>
222
222
  </px-test>
223
223
 
224
224
  <px-test test-id="px-clock" name="px-clock">
225
- <px-clock v-model="currentDate" />
225
+ <px-clock v-model:date="currentDate" />
226
226
  Selected Date: {{ currentDate }}
227
227
  </px-test>
228
228
 
229
229
  <px-test test-id="px-calendar" name="px-calendar">
230
- <px-calendar v-model="currentDate" />
230
+ <px-calendar v-model:date="currentDate" />
231
231
  Selected Date: {{ currentDate }}
232
232
  </px-test>
233
233
 
@@ -241,10 +241,10 @@
241
241
  items-key-property="id"
242
242
  items-value-property="id"
243
243
  items-label-property="name"
244
- v-model="currentFruitOrFruits"
244
+ v-model:selected="currentFruitOrFruits"
245
245
  ></px-toggle-button-list>
246
246
 
247
- <px-toggle v-model="supportsMultiSelect">Multi-select</px-toggle>
247
+ <px-toggle v-model:checked="supportsMultiSelect">Multi-select</px-toggle>
248
248
  <span>{{ currentFruitOrFruits }}</span>
249
249
  </px-flex>
250
250
  </px-test>
@@ -257,7 +257,7 @@
257
257
 
258
258
  <px-textbox
259
259
  multiline
260
- v-model="currentText"
260
+ v-model:text="currentText"
261
261
  rows="5"
262
262
  placeholder="Say it longer..."
263
263
  />
@@ -270,7 +270,7 @@
270
270
  <px-test test-id="px-dropdown" name="px-dropdown">
271
271
  <px-flex gap="1" align="center" justify="center">
272
272
  <px-dropdown
273
- v-model="currentFruit"
273
+ v-model:selected="currentFruit"
274
274
  tag="button"
275
275
  trigger="click"
276
276
  :items="fruits"
@@ -3,8 +3,8 @@
3
3
  -->
4
4
  <template>
5
5
  <div :class="bem()">
6
- <px-pivot :items="tabs" v-model="selectedTab" />
7
- <px-slides :items="tabs" v-model="selectedTab" :drag-enabled="false">
6
+ <px-pivot :items="tabs" v-model:selected="selectedTab" />
7
+ <px-slides :items="tabs" v-model:selected="selectedTab" :drag-enabled="false">
8
8
  <template #slide="{ item }">
9
9
  <div :class="bem('slide')">
10
10
  <h1>{{ item.label }}</h1>
@@ -6,7 +6,7 @@
6
6
  <px-flex justify="center" gap="1">
7
7
  <button @click="clickPrev">Previous</button>
8
8
  <button @click="clickNext">Next</button>
9
- <px-toggle v-model="nested">Nested</px-toggle>
9
+ <px-toggle v-model:checked="nested">Nested</px-toggle>
10
10
  </px-flex>
11
11
  <px-slides :style="{ flex: 1 }" ref="slides" :items="fruits" items-key-property="id">
12
12
  <template #slide="{ item, index }">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkpixellab-public/px-vue",
3
- "version": "4.0.23",
3
+ "version": "4.0.25",
4
4
  "description": "General purpose Vue components and helpers that can be used across projects.",
5
5
  "author": {
6
6
  "name": "Pixel Lab"
@@ -2,6 +2,8 @@ import PxSvg from '@/components/PxSvg.vue';
2
2
  import { extractArgTypes } from '@/storybook/sb-utils.js';
3
3
 
4
4
  import alphaSvg from './assets/alpha.svg';
5
+ import alphaSizeWidthSvg from './assets/alphaSizeWidth.svg';
6
+ import alphaNoSizingSvg from './assets/alphaNoSizing.svg';
5
7
 
6
8
  export default {
7
9
  component: PxSvg,
@@ -29,11 +31,16 @@ export const Basic = {
29
31
  setup() {
30
32
  return { args };
31
33
  },
32
- template: `<PxSvg v-bind="args" />`,
34
+ template: `<PxSvg v-bind="args" size="200px" />`,
33
35
  }),
34
36
  };
35
37
 
36
- export const Advanced = {
38
+ export const WidthAndHeightNoViewBox = {
37
39
  ...Basic,
38
- // args: { size: '2em' },
40
+ args: { src: alphaSizeWidthSvg },
41
+ };
42
+
43
+ export const NoSizing = {
44
+ ...Basic,
45
+ args: { src: alphaNoSizingSvg },
39
46
  };
@@ -28,7 +28,7 @@ export const Basic = {
28
28
  data() {
29
29
  return { sampleText: '' };
30
30
  },
31
- template: `<input v-model="sampleText" /> <br><br> <PxTextbox v-model:value="sampleText" v-bind="args"/> <br> <br> <PxTextbox :multiline="true" v-model:value="sampleText" v-bind="args"/> <br> <br> {{sampleText}}`,
31
+ template: `<input v-model="sampleText" /> <br><br> <PxTextbox v-model:text="sampleText" v-bind="args"/> <br> <br> <PxTextbox :multiline="true" v-model:text="sampleText" v-bind="args"/> <br> <br> {{sampleText}}`,
32
32
  args: {},
33
33
  }),
34
34
  };
@@ -0,0 +1,6 @@
1
+
2
+ <svg id='svg1' xmlns='http://www.w3.org/2000/svg'>
3
+ <circle r="32" cx="35" cy="65" fill="#F00" opacity="0.5"/>
4
+ <circle r="32" cx="65" cy="65" fill="#0F0" opacity="0.5"/>
5
+ <circle r="32" cx="50" cy="35" fill="#00F" opacity="0.5"/>
6
+ </svg>
@@ -0,0 +1,6 @@
1
+
2
+ <svg id='svg1' width="100" height="100" xmlns='http://www.w3.org/2000/svg'>
3
+ <circle r="32" cx="35" cy="65" fill="#F00" opacity="0.5"/>
4
+ <circle r="32" cx="65" cy="65" fill="#0F0" opacity="0.5"/>
5
+ <circle r="32" cx="50" cy="35" fill="#00F" opacity="0.5"/>
6
+ </svg>
package/vite.config.js CHANGED
@@ -16,14 +16,8 @@ export default defineConfig({
16
16
 
17
17
  ...(USE_PX_LOCAL
18
18
  ? {
19
- '@thinkpixellab-public/px-styles': path.resolve(
20
- __dirname,
21
- '../px-styles-vue3',
22
- ),
23
- '@thinkpixellab/px-edge-shared': path.resolve(
24
- __dirname,
25
- '../px-edge-shared-nuxt3',
26
- ),
19
+ '@thinkpixellab-public/px-styles': path.resolve(__dirname, '../px-styles'),
20
+ '@thinkpixellab/px-edge-shared': path.resolve(__dirname, '../px-edge-shared'),
27
21
  }
28
22
  : {}),
29
23
  },
package/.prettierrc.js DELETED
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- semi: true,
3
- arrowParens: 'avoid',
4
- singleQuote: true,
5
- tabWidth: 4,
6
- printWidth: 100,
7
- bracketSpacing: true,
8
- htmlWhitespaceSensitivity: 'ignore',
9
- endOfLine: 'auto',
10
- };