@byline/admin 5.1.2 → 5.1.4

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 (93) hide show
  1. package/dist/exports-parity.test.node.js +37 -0
  2. package/dist/fields/array/array-field.jsx +209 -0
  3. package/dist/fields/blocks/blocks-field.jsx +248 -0
  4. package/dist/fields/checkbox/checkbox-field.jsx +24 -0
  5. package/dist/fields/code/code-editor.jsx +211 -0
  6. package/dist/fields/code/code-field.jsx +109 -0
  7. package/dist/fields/column-formatter.jsx +25 -0
  8. package/dist/fields/date-time-formatter.jsx +18 -0
  9. package/dist/fields/datetime/datetime-field.jsx +22 -0
  10. package/dist/fields/draggable-context-menu.jsx +50 -0
  11. package/dist/fields/field-admin.test.node.js +40 -0
  12. package/dist/fields/field-renderer.jsx +136 -0
  13. package/dist/fields/field-services-context.jsx +17 -0
  14. package/dist/fields/file/file-field.jsx +176 -0
  15. package/dist/fields/file/file-upload-field.jsx +89 -0
  16. package/dist/fields/group/group-field.jsx +46 -0
  17. package/dist/fields/image/image-field.jsx +183 -0
  18. package/dist/fields/image/image-upload-field.jsx +157 -0
  19. package/dist/fields/local-date-time.jsx +69 -0
  20. package/dist/fields/locale-badge.jsx +19 -0
  21. package/dist/fields/numerical/numerical-field.jsx +93 -0
  22. package/dist/fields/relation/relation-column-formatter.jsx +74 -0
  23. package/dist/fields/relation/relation-display.jsx +118 -0
  24. package/dist/fields/relation/relation-field.jsx +108 -0
  25. package/dist/fields/relation/relation-many-field.jsx +142 -0
  26. package/dist/fields/relation/relation-picker.jsx +240 -0
  27. package/dist/fields/relation/relation-summary.jsx +45 -0
  28. package/dist/fields/select/select-field.jsx +27 -0
  29. package/dist/fields/sortable-item.jsx +54 -0
  30. package/dist/fields/text/text-field.jsx +79 -0
  31. package/dist/fields/text-area/text-area-field.jsx +79 -0
  32. package/dist/forms/available-locales-reconcile.test.node.js +43 -0
  33. package/dist/forms/available-locales-widget.jsx +63 -0
  34. package/dist/forms/document-actions.jsx +486 -0
  35. package/dist/forms/form-context.jsx +598 -0
  36. package/dist/forms/form-modals.jsx +128 -0
  37. package/dist/forms/form-renderer.jsx +532 -0
  38. package/dist/forms/form-status-display.jsx +69 -0
  39. package/dist/forms/navigation-guard.jsx +68 -0
  40. package/dist/forms/nested-path.test.node.js +115 -0
  41. package/dist/forms/path-widget.jsx +125 -0
  42. package/dist/forms/pending-uploads.test.node.js +19 -0
  43. package/dist/forms/repeating-items.test.node.js +29 -0
  44. package/dist/forms/scheduled-publication-control.jsx +389 -0
  45. package/dist/forms/scheduled-publication-state.test.node.js +121 -0
  46. package/dist/forms/scheduled-publication-time.test.node.js +70 -0
  47. package/dist/forms/status-transitions.test.node.js +76 -0
  48. package/dist/forms/tree-placement-widget.jsx +160 -0
  49. package/dist/forms/upload-executor.test.node.js +368 -0
  50. package/dist/forms/use-form-layout.test.node.js +69 -0
  51. package/dist/modules/admin-account/components/change-password.jsx +169 -0
  52. package/dist/modules/admin-account/components/container.jsx +164 -0
  53. package/dist/modules/admin-account/components/preferences.jsx +148 -0
  54. package/dist/modules/admin-account/components/theme-switch.jsx +52 -0
  55. package/dist/modules/admin-account/components/update.jsx +186 -0
  56. package/dist/modules/admin-permissions/components/inspector.jsx +200 -0
  57. package/dist/modules/admin-preferences/schemas.test.node.js +48 -0
  58. package/dist/modules/admin-roles/components/create.jsx +155 -0
  59. package/dist/modules/admin-roles/components/permissions.jsx +239 -0
  60. package/dist/modules/admin-roles/components/update.jsx +148 -0
  61. package/dist/modules/admin-users/components/create.jsx +206 -0
  62. package/dist/modules/admin-users/components/roles.jsx +126 -0
  63. package/dist/modules/admin-users/components/set-password.jsx +133 -0
  64. package/dist/modules/admin-users/components/update.jsx +215 -0
  65. package/dist/modules/analytics/components/dashboard.d.ts +13 -3
  66. package/dist/modules/analytics/components/dashboard.js +86 -68
  67. package/dist/modules/analytics/components/dashboard.jsx +208 -0
  68. package/dist/modules/analytics/components/dashboard.module.js +10 -1
  69. package/dist/modules/analytics/components/dashboard.test.node.js +162 -0
  70. package/dist/modules/analytics/components/dashboard_module.css +57 -0
  71. package/dist/modules/analytics/components/ranked-list-modal.d.ts +32 -0
  72. package/dist/modules/analytics/components/ranked-list-modal.js +145 -0
  73. package/dist/modules/analytics/components/ranking.d.ts +45 -0
  74. package/dist/modules/analytics/components/ranking.js +71 -0
  75. package/dist/modules/analytics/components/ranking.test.node.d.ts +8 -0
  76. package/dist/modules/analytics/components/timeseries.jsx +193 -0
  77. package/dist/modules/auth/components/sign-in-form.jsx +89 -0
  78. package/dist/modules/auth/safe-redirect.test.node.js +40 -0
  79. package/dist/modules/auth/sign-in-form-props.test.node.js +7 -0
  80. package/dist/presentation/group.jsx +26 -0
  81. package/dist/presentation/row.jsx +23 -0
  82. package/dist/presentation/tabs.jsx +39 -0
  83. package/dist/services/admin-services-context.jsx +17 -0
  84. package/dist/widgets/diff-viewer/diff-modal.jsx +110 -0
  85. package/dist/widgets/source-locale-badge/source-locale-badge.jsx +28 -0
  86. package/dist/widgets/status-badge/status-badge.jsx +46 -0
  87. package/package.json +7 -7
  88. package/src/modules/analytics/components/dashboard.module.css +69 -0
  89. package/src/modules/analytics/components/dashboard.tsx +105 -83
  90. package/src/modules/analytics/components/ranked-list-modal.test.tsx +154 -0
  91. package/src/modules/analytics/components/ranked-list-modal.tsx +159 -0
  92. package/src/modules/analytics/components/ranking.test.node.ts +43 -0
  93. package/src/modules/analytics/components/ranking.tsx +122 -0
@@ -0,0 +1,122 @@
1
+ 'use client'
2
+
3
+ /**
4
+ * This Source Code is subject to the terms of the Mozilla Public
5
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
6
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+ *
8
+ * Copyright (c) Infonomic Company Limited
9
+ */
10
+
11
+ /**
12
+ * Ranked-row rendering shared by the dashboard cards and the full-list
13
+ * modal, plus the small pure helpers both rely on.
14
+ */
15
+
16
+ import type React from 'react'
17
+ import { useMemo } from 'react'
18
+
19
+ import { useTranslation } from '@byline/i18n/react'
20
+ import cx from 'clsx'
21
+
22
+ import styles from './dashboard.module.css'
23
+
24
+ export type AnalyticsTone = 'views' | 'visitors' | 'downloads'
25
+
26
+ export interface RankedRow {
27
+ key: string
28
+ label: string
29
+ value: number
30
+ visitors: number
31
+ overflow: boolean
32
+ }
33
+
34
+ /** A complete ranking plus the size of the set it was drawn from. */
35
+ export interface RankedListSource {
36
+ rows: RankedRow[]
37
+ total: number
38
+ }
39
+
40
+ const TONE_BAR: Record<AnalyticsTone, string | undefined> = {
41
+ views: styles.barViews,
42
+ visitors: styles.barVisitors,
43
+ downloads: styles.barDownloads,
44
+ }
45
+
46
+ /** The ordered list with a share bar behind each row. Renders no card chrome. */
47
+ export function RankingRows({
48
+ rows,
49
+ tone,
50
+ locale,
51
+ }: {
52
+ rows: RankedRow[]
53
+ tone: AnalyticsTone
54
+ locale: string
55
+ }): React.JSX.Element {
56
+ const { t } = useTranslation('byline-admin')
57
+ const numbers = useMemo(() => new Intl.NumberFormat(locale), [locale])
58
+ const ceiling = Math.max(1, ...rows.map((row) => row.value))
59
+ return (
60
+ <ol className={cx('byline-analytics-ranking', styles.ranking)}>
61
+ {rows.map((row) => (
62
+ <li
63
+ key={row.key}
64
+ className={cx(
65
+ 'byline-analytics-ranking-row',
66
+ styles.rankingRow,
67
+ TONE_BAR[tone],
68
+ row.overflow && styles.rankingOverflow
69
+ )}
70
+ // The share bar sits behind the row so the label and its
71
+ // magnitude occupy one line and are read together.
72
+ style={
73
+ {
74
+ '--byline-analytics-share': `${shareWidth(row.value, ceiling)}%`,
75
+ } as React.CSSProperties
76
+ }
77
+ >
78
+ <span className={styles.rankingLabel} title={row.key}>
79
+ {/* `__other__` is a reserved aggregate, not a page anyone
80
+ visited — never render it as though it were a real path. */}
81
+ {row.overflow ? t('analytics.overflow') : row.label}
82
+ </span>
83
+ <span className={styles.rankingValue}>{numbers.format(row.value)}</span>
84
+ <span className={styles.rankingVisitors}>{numbers.format(row.visitors)}</span>
85
+ </li>
86
+ ))}
87
+ </ol>
88
+ )
89
+ }
90
+
91
+ /** Never collapse the bar entirely: a visible sliver still encodes "smallest". */
92
+ export function shareWidth(value: number, ceiling: number): number {
93
+ if (!Number.isFinite(value) || value <= 0 || ceiling <= 0) return 0
94
+ return Math.max(3, Math.min(100, (value / ceiling) * 100))
95
+ }
96
+
97
+ /** Row indices for one page of a list, with the page clamped into range. */
98
+ export function pageWindow(
99
+ total: number,
100
+ pageSize: number,
101
+ page: number
102
+ ): { start: number; end: number; pageCount: number } {
103
+ const pageCount = Math.max(1, Math.ceil(total / pageSize))
104
+ const current = Math.min(Math.max(1, page), pageCount)
105
+ const start = (current - 1) * pageSize
106
+ return { start, end: Math.min(total, start + pageSize), pageCount }
107
+ }
108
+
109
+ /**
110
+ * Localised region name for an ISO 3166-1 alpha-2 code, or the code itself
111
+ * when the value is not a code or the runtime has no name for it. The
112
+ * dashboard stores bare codes, so this is purely a display concern.
113
+ */
114
+ export function regionName(code: string, locale: string): string {
115
+ if (!/^[A-Za-z]{2}$/.test(code)) return code
116
+ try {
117
+ const names = new Intl.DisplayNames([locale], { type: 'region', fallback: 'none' })
118
+ return names.of(code.toUpperCase()) ?? code
119
+ } catch {
120
+ return code
121
+ }
122
+ }