@citizenplane/pimp 17.0.5 → 17.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citizenplane/pimp",
3
- "version": "17.0.5",
3
+ "version": "17.0.7",
4
4
  "scripts": {
5
5
  "dev": "storybook dev -p 8081",
6
6
  "build-storybook": "storybook build --output-dir ./docs",
@@ -5,6 +5,7 @@
5
5
  class="cpButton"
6
6
  :class="dynamicClasses"
7
7
  :disabled="isButtonDisabled"
8
+ :href="hrefValue"
8
9
  role="button"
9
10
  tabindex="0"
10
11
  :type="type"
@@ -44,6 +45,7 @@ export interface Props {
44
45
  color?: 'neutral' | 'accent' | 'error' | 'warning' | 'success'
45
46
  disabled?: boolean
46
47
  enableHaptics?: boolean
48
+ href?: string
47
49
  isLoading?: boolean
48
50
  isSquare?: boolean
49
51
  size?: '2xs' | 'xs' | 'sm' | 'md' | 'lg'
@@ -54,6 +56,7 @@ export interface Props {
54
56
  const props = withDefaults(defineProps<Props>(), {
55
57
  appearance: 'primary',
56
58
  color: 'neutral',
59
+ href: undefined,
57
60
  tag: 'button',
58
61
  type: 'button',
59
62
  size: 'md',
@@ -78,6 +81,8 @@ const hasIconAfter = computed(() => !!slots['trailing-icon'])
78
81
 
79
82
  const isButtonDisabled = computed(() => props.disabled || props.isLoading)
80
83
 
84
+ const hrefValue = computed(() => (props.tag === 'a' ? props.href : undefined))
85
+
81
86
  const dynamicClasses = computed(() => {
82
87
  return [
83
88
  `cpButton--is${capitalizedAppearance.value}`,
@@ -135,7 +135,8 @@ import CpTableEmptyState from '@/components/CpTableEmptyState.vue'
135
135
 
136
136
  import { camelize, decamelize } from '@/helpers/string'
137
137
 
138
- import { PAGINATION_FORMATS, RESERVED_KEYS, VISIBLE_ROWS_MAX } from '@/constants'
138
+ import { RESERVED_KEYS, VISIBLE_ROWS_MAX } from '@/constants'
139
+ import type { PAGINATION_FORMATS } from '@/constants'
139
140
  import { capitalizeFirstLetter } from '@/helpers'
140
141
 
141
142
  interface Emits {
@@ -151,7 +152,7 @@ interface PaginationServer {
151
152
 
152
153
  interface Pagination {
153
154
  enabled?: boolean
154
- format?: (typeof PAGINATION_FORMATS)[keyof typeof PAGINATION_FORMATS]
155
+ format?: PAGINATION_FORMATS
155
156
  limit?: number
156
157
  server?: PaginationServer
157
158
  }
@@ -397,7 +398,7 @@ const paginationState = computed(() => {
397
398
  const hasPagination = computed(() => paginationState.value || numberOfResults.value > VISIBLE_ROWS_MAX)
398
399
  const paginationFormat = computed(() => {
399
400
  if (typeof props.pagination === 'object' && props.pagination.format) return props.pagination.format
400
- return PAGINATION_FORMATS.PAGES
401
+ return 'pages'
401
402
  })
402
403
  const hasRemainingPages = computed(() => numberOfPages.value > activePage.value)
403
404
  const isNextEnabled = computed(() => hasRemainingPages.value && !props.isLoading)
@@ -433,7 +434,7 @@ const pageLastResultIndex = computed(() => {
433
434
  })
434
435
 
435
436
  const paginationLabel = computed(() => {
436
- if (paginationFormat.value === PAGINATION_FORMATS.PAGES) {
437
+ if (paginationFormat.value === 'pages') {
437
438
  const pluralizedCount = numberOfPages.value > 1 ? 'pages' : 'page'
438
439
  return `${activePage.value}/${numberOfPages.value} ${pluralizedCount}`
439
440
  }
@@ -6,7 +6,4 @@ export enum RESERVED_KEYS {
6
6
  IS_SELECTED = 'isSelected',
7
7
  }
8
8
 
9
- export enum PAGINATION_FORMATS {
10
- RESULTS = 'results',
11
- PAGES = 'pages',
12
- }
9
+ export type PAGINATION_FORMATS = 'results' | 'pages'
@@ -1,7 +1,8 @@
1
1
  export type { Colors } from './colors/Colors'
2
2
  export { Position } from './Position'
3
3
  export type { ToggleColors } from './colors/ToggleColors'
4
- export { PAGINATION_FORMATS, RESERVED_KEYS, VISIBLE_ROWS_MAX } from './CpTableConfig'
4
+ export type { PAGINATION_FORMATS } from './CpTableConfig'
5
+ export { RESERVED_KEYS, VISIBLE_ROWS_MAX } from './CpTableConfig'
5
6
  export type { Sizes } from './Sizes'
6
7
 
7
8
  export { CustomCpIcons } from './CpCustomIcons'
@@ -34,7 +34,7 @@ const meta = {
34
34
  },
35
35
  tag: {
36
36
  control: 'select',
37
- options: ['button', 'a'],
37
+ options: ['a', 'button', 'label'],
38
38
  description: 'The HTML element to render',
39
39
  },
40
40
  type: {
@@ -5,8 +5,6 @@ import type { Meta, StoryObj } from '@storybook/vue3-vite'
5
5
 
6
6
  import CpTable from '@/components/CpTable.vue'
7
7
 
8
- import { PAGINATION_FORMATS } from '@/constants'
9
-
10
8
  const meta = {
11
9
  title: 'Organisms/CpTable',
12
10
  component: CpTable,
@@ -133,7 +131,7 @@ export const WithPagination: Story = {
133
131
  pagination: {
134
132
  enabled: true,
135
133
  limit: 3,
136
- format: PAGINATION_FORMATS.PAGES,
134
+ format: 'pages',
137
135
  },
138
136
  },
139
137
  }