@nocopypaste/vue-grid-renderer-template 0.2.0 → 0.3.1

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/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_openBlock","_createElementBlock","_Fragment","_renderList","_normalizeClass","RatingCell","_hoisted_1","_hoisted_2","_hoisted_3","RatingCell_default","defineComponent","__emit","props","__props","emit","ctx","useGridContext","max","computed","rating","n","label","rate","value","openBlock","createElementBlock","Fragment","renderList","normalizeClass","ratingRenderer","defineCellRenderer","options"],"sources":["../src/RatingCell.vue","../src/index.ts"],"sourcesContent":["<!--\n Boilerplate cell renderer.\n\n Contract (from @nocopypaste/vue-grid):\n - props: CellRendererProps<Row, Value, Options> → value, row, rowKey, rowIndex, depth, column, options\n - emits: `action(name, payload)` — the grid re-emits it as `cell-action` with row + column attached\n - styling: only --vg-* tokens (plus this addon's own --vg-rating-* tokens), inside a cascade layer\n-->\n<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport { useGridContext, type CellRendererEmits, type CellRendererProps } from '@nocopypaste/vue-grid'\nimport type { RatingOptions } from './types'\n\nconst props = defineProps<CellRendererProps<unknown, number | null | undefined, RatingOptions>>()\nconst emit = defineEmits<CellRendererEmits>()\n\n// Locale, currency and time zone of the surrounding grid (props → plugin config → browser).\nconst ctx = useGridContext()\n\nconst max = computed(() => Math.max(1, Math.round(props.options.max ?? 5)))\nconst rating = computed(() => {\n const n = Number(props.value)\n return Number.isFinite(n) ? Math.min(Math.max(n, 0), max.value) : 0\n})\nconst label = computed(\n () => `${new Intl.NumberFormat(ctx.value.locale).format(rating.value)} of ${max.value}`,\n)\n\nfunction rate(value: number) {\n if (props.options.readonly) return\n emit('action', 'rate', value)\n}\n</script>\n\n<template>\n <span v-if=\"options.readonly\" class=\"vg-rating\" role=\"img\" :aria-label=\"label\" :title=\"label\">\n <span\n v-for=\"n in max\"\n :key=\"n\"\n class=\"vg-rating-star\"\n :class=\"{ 'vg-rating-star-on': n <= Math.round(rating) }\"\n aria-hidden=\"true\"\n >★</span\n >\n </span>\n <span v-else class=\"vg-rating\" role=\"radiogroup\" :aria-label=\"`Rating, ${label}`\">\n <button\n v-for=\"n in max\"\n :key=\"n\"\n type=\"button\"\n role=\"radio\"\n class=\"vg-rating-star\"\n :class=\"{ 'vg-rating-star-on': n <= Math.round(rating) }\"\n :aria-checked=\"n === Math.round(rating)\"\n :aria-label=\"`${n} of ${max}`\"\n @click=\"rate(n)\"\n >\n ★\n </button>\n </span>\n</template>\n","import { defineCellRenderer } from '@nocopypaste/vue-grid'\nimport RatingCell from './RatingCell.vue'\nimport type { RatingOptions } from './types'\n\n// 1. Register the renderer name and its options with the grid's type registry, so\n// `renderer: 'rating'` autocompletes and `rendererOptions` is type-checked.\ndeclare module '@nocopypaste/vue-grid' {\n interface CellRendererRegistry {\n rating: RatingOptions\n }\n}\n\n// 2. Describe the renderer. Everything except `name` and `component` is optional.\nexport const ratingRenderer = defineCellRenderer<RatingOptions>({\n name: 'rating',\n component: RatingCell,\n defaults: { max: 5, readonly: false },\n align: 'start',\n // Used by `sortMode=\"client\"` so ratings sort numerically.\n sortValue: (value) => (value === null || value === undefined ? null : Number(value)),\n // Plain-text form (tooltips, exports, accessibility).\n format: (value, options) => `${Number(value ?? 0)} of ${options.max ?? 5}`,\n})\n\nexport { RatingCell }\nexport type { RatingOptions }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EAaA,IAAMY,IAAQC,GACRC,IAAOH,GAGPI,IAAMC,EAAe,GAErBC,IAAMC,QAAe,KAAK,IAAI,GAAG,KAAK,MAAMN,EAAM,QAAQ,OAAO,CAAC,CAAC,CAAC,GACpEO,IAASD,QAAe;GAC5B,IAAME,IAAI,OAAOR,EAAM,KAAK;GAC5B,OAAO,OAAO,SAASQ,CAAC,IAAI,KAAK,IAAI,KAAK,IAAIA,GAAG,CAAC,GAAGH,EAAI,KAAK,IAAI;EACpE,CAA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AAY,GAAG,OAAOA,KAAS,CAAC,EAAE,MAAMQ,EAAQ,OAAO;AACzE,CAAC"}
1
+ {"version":3,"file":"index.js","names":["_openBlock","_createElementBlock","_Fragment","_renderList","_normalizeClass","RatingCell","_hoisted_1","_hoisted_2","_hoisted_3","RatingCell_default","defineComponent","__emit","props","__props","emit","ctx","useGridContext","max","computed","rating","n","label","rate","value","openBlock","createElementBlock","Fragment","renderList","normalizeClass","ratingRenderer","defineCellRenderer","options"],"sources":["../src/RatingCell.vue","../src/index.ts"],"sourcesContent":["<!--\n Boilerplate cell renderer.\n\n Contract (from @nocopypaste/vue-grid):\n - props: CellRendererProps<Row, Value, Options> → value, row, rowKey, rowIndex, depth, column, options\n - emits: `action(name, payload)` — the grid re-emits it as `cell-action` with row + column attached\n - styling: only --vg-* tokens (plus this addon's own --vg-rating-* tokens), inside a cascade layer\n-->\n<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport { useGridContext, type CellRendererEmits, type CellRendererProps } from '@nocopypaste/vue-grid'\nimport type { RatingOptions } from './types'\n\nconst props = defineProps<CellRendererProps<unknown, number | null | undefined, RatingOptions>>()\nconst emit = defineEmits<CellRendererEmits>()\n\n// Locale, currency and time zone of the surrounding grid (props → plugin config → browser).\nconst ctx = useGridContext()\n\nconst max = computed(() => Math.max(1, Math.round(props.options.max ?? 5)))\nconst rating = computed(() => {\n const n = Number(props.value)\n return Number.isFinite(n) ? Math.min(Math.max(n, 0), max.value) : 0\n})\nconst label = computed(\n () => `${new Intl.NumberFormat(ctx.value.locale).format(rating.value)} of ${max.value}`,\n)\n\nfunction rate(value: number) {\n if (props.options.readonly) return\n emit('action', 'rate', value)\n}\n</script>\n\n<template>\n <span v-if=\"options.readonly\" class=\"vg-rating\" role=\"img\" :aria-label=\"label\" :title=\"label\">\n <span\n v-for=\"n in max\"\n :key=\"n\"\n class=\"vg-rating-star\"\n :class=\"{ 'vg-rating-star-on': n <= Math.round(rating) }\"\n aria-hidden=\"true\"\n >★</span\n >\n </span>\n <span v-else class=\"vg-rating\" role=\"radiogroup\" :aria-label=\"`Rating, ${label}`\">\n <button\n v-for=\"n in max\"\n :key=\"n\"\n type=\"button\"\n role=\"radio\"\n class=\"vg-rating-star\"\n :class=\"{ 'vg-rating-star-on': n <= Math.round(rating) }\"\n :aria-checked=\"n === Math.round(rating)\"\n :aria-label=\"`${n} of ${max}`\"\n @click=\"rate(n)\"\n >\n ★\n </button>\n </span>\n</template>\n","import { defineCellRenderer } from '@nocopypaste/vue-grid'\nimport RatingCell from './RatingCell.vue'\nimport type { RatingOptions } from './types'\n\n// 1. Register the renderer name and its options with the grid's type registry, so\n// `renderer: 'rating'` autocompletes and `rendererOptions` is type-checked.\ndeclare module '@nocopypaste/vue-grid' {\n interface CellRendererRegistry {\n rating: RatingOptions\n }\n}\n\n// 2. Describe the renderer. Everything except `name` and `component` is optional.\nexport const ratingRenderer = defineCellRenderer<RatingOptions>({\n name: 'rating',\n component: RatingCell,\n defaults: { max: 5, readonly: false },\n align: 'start',\n // Used by `sortMode=\"client\"` so ratings sort numerically.\n sortValue: (value) => (value === null || value === undefined ? null : Number(value)),\n // Plain-text form: what Ctrl+C and formatted CSV exports copy (export feature).\n format: (value, options) => `${Number(value ?? 0)} of ${options.max ?? 5}`,\n})\n\nexport { RatingCell }\nexport type { RatingOptions }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EAaA,IAAMY,IAAQC,GACRC,IAAOH,GAGPI,IAAMC,EAAe,GAErBC,IAAMC,QAAe,KAAK,IAAI,GAAG,KAAK,MAAMN,EAAM,QAAQ,OAAO,CAAC,CAAC,CAAC,GACpEO,IAASD,QAAe;GAC5B,IAAME,IAAI,OAAOR,EAAM,KAAK;GAC5B,OAAO,OAAO,SAASQ,CAAC,IAAI,KAAK,IAAI,KAAK,IAAIA,GAAG,CAAC,GAAGH,EAAI,KAAK,IAAI;EACpE,CAAC,GACKI,IAAQH,QACN,GAAG,IAAI,KAAK,aAAaH,EAAI,MAAM,MAAM,CAAC,C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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocopypaste/vue-grid-renderer-template",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Boilerplate cell-renderer addon for @nocopypaste/vue-grid: a star rating renderer. Copy this package to start your own.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,7 +26,7 @@
26
26
  "typecheck": "vue-tsc -p tsconfig.json --noEmit"
27
27
  },
28
28
  "peerDependencies": {
29
- "@nocopypaste/vue-grid": "^0.2.0",
29
+ "@nocopypaste/vue-grid": "^0.3.1",
30
30
  "vue": "^3.5.0"
31
31
  },
32
32
  "devDependencies": {