@panneau/fields 5.0.0-alpha.21 → 5.0.0-alpha.22

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.
@@ -1,9 +1,115 @@
1
+ .panneau-relation-field-single,
1
2
  .panneau-relation-field-multiple {
2
3
  display: flex;
3
4
  flex-direction: column;
4
5
  gap: var(--panneau-space-2);
5
6
  }
6
7
 
8
+ /* The picker of the single field, with "Cancel" while it changes the item. */
9
+ .panneau-relation-field-picker {
10
+ display: flex;
11
+ align-items: center;
12
+ gap: var(--panneau-space-2);
13
+ }
14
+
15
+ .panneau-relation-field-picker > :first-child {
16
+ flex: 1;
17
+ min-width: 0;
18
+ }
19
+
20
+ /* The chosen items, as cards (decision 0067). */
21
+ .panneau-relation-field-cards {
22
+ display: flex;
23
+ flex-direction: column;
24
+ gap: var(--panneau-space-2);
25
+ margin: 0;
26
+ padding: 0;
27
+ list-style: none;
28
+ }
29
+
30
+ .panneau-relation-field-card {
31
+ display: flex;
32
+ align-items: center;
33
+ gap: var(--panneau-space-3);
34
+ min-width: 0;
35
+ padding: var(--panneau-space-2);
36
+ background-color: var(--panneau-color-surface);
37
+ border: var(--panneau-border-width) solid var(--panneau-color-border);
38
+ border-radius: var(--panneau-radius-md);
39
+ }
40
+
41
+ /* The item's image, or its resource's icon. */
42
+ .panneau-relation-field-thumbnail {
43
+ display: inline-flex;
44
+ flex: none;
45
+ align-items: center;
46
+ justify-content: center;
47
+ width: 2.5rem;
48
+ height: 2.5rem;
49
+ overflow: hidden;
50
+ color: var(--panneau-color-text-muted);
51
+ background-color: var(--panneau-color-surface-sunken);
52
+ border-radius: var(--panneau-radius-sm);
53
+ }
54
+
55
+ .panneau-relation-field-thumbnail img {
56
+ width: 100%;
57
+ height: 100%;
58
+ object-fit: cover;
59
+ }
60
+
61
+ .panneau-relation-field-option-thumbnail {
62
+ width: 1.75rem;
63
+ height: 1.75rem;
64
+ }
65
+
66
+ .panneau-relation-field-card-text {
67
+ display: flex;
68
+ flex: 1;
69
+ flex-direction: column;
70
+ min-width: 0;
71
+ }
72
+
73
+ .panneau-relation-field-card-label {
74
+ overflow: hidden;
75
+ font-size: var(--panneau-font-size-md);
76
+ font-weight: var(--panneau-font-weight-medium);
77
+ color: var(--panneau-color-text);
78
+ text-overflow: ellipsis;
79
+ white-space: nowrap;
80
+ }
81
+
82
+ .panneau-relation-field-link {
83
+ align-self: flex-start;
84
+ max-width: 100%;
85
+ text-decoration: none;
86
+ border-radius: var(--panneau-radius-sm);
87
+ }
88
+
89
+ .panneau-relation-field-link:hover {
90
+ text-decoration: underline;
91
+ }
92
+
93
+ .panneau-relation-field-link[data-focus-visible] {
94
+ outline: var(--panneau-focus-width) solid var(--panneau-color-focus);
95
+ outline-offset: 2px;
96
+ }
97
+
98
+ .panneau-relation-field-card-description {
99
+ overflow: hidden;
100
+ font-size: var(--panneau-font-size-sm);
101
+ color: var(--panneau-color-text-muted);
102
+ text-overflow: ellipsis;
103
+ white-space: nowrap;
104
+ }
105
+
106
+ .panneau-relation-field-card-actions {
107
+ display: inline-flex;
108
+ flex: none;
109
+ gap: var(--panneau-space-1);
110
+ }
111
+
112
+ /* The items of a compact field, as chips. */
7
113
  .panneau-relation-field-selected {
8
114
  display: flex;
9
115
  flex-wrap: wrap;
@@ -22,6 +22,11 @@ export interface RelationFieldBaseProps extends Omit<FieldProps<never>, 'value'
22
22
  onCreate?: ((text: string) => Promise<RelationReference | null>) | null;
23
23
  placeholder?: string;
24
24
  controlClassName?: string;
25
+ /**
26
+ * Shows the items as chips, and the single item as the text of its picker, rather than as cards
27
+ * (decision 0067): for small places, such as the filters of a list.
28
+ */
29
+ compact?: boolean;
25
30
  }
26
31
  export interface SingleRelationFieldProps extends RelationFieldBaseProps {
27
32
  multiple?: false;
@@ -38,9 +43,11 @@ export type RelationFieldProps = SingleRelationFieldProps | MultipleRelationFiel
38
43
  /**
39
44
  * A reference to an item of another resource, or several with `multiple`, picked by searching a
40
45
  * `RelationSource`. Values are references (`{ id, label }`), as items carry them; plain ids get
41
- * their labels from the source's `resolve()`. When the source can `create()` (or with `onCreate`),
42
- * the picker offers to create an item from the typed text. Without a source, the field shows its
43
- * references and can't change them.
46
+ * their labels from the source's `resolve()`. The chosen items show as cards (decision 0067), with
47
+ * their image and their description when the source gives them, a link to each one
48
+ * (`getItemHref()`), and buttons to change or remove them. When the source can `create()` (or with
49
+ * `onCreate`), the picker offers to create an item from the typed text. Without a source, the field
50
+ * shows its items and can't change them.
44
51
  */
45
52
  export declare function RelationField(props: RelationFieldProps): import("react").JSX.Element;
46
53
  /** The `relation` type: `resource` and `multiple`. Items search the fields context's source. */
@@ -1 +1 @@
1
- {"version":3,"file":"RelationField.d.ts","sourceRoot":"","sources":["../../src/relation/RelationField.tsx"],"names":[],"mappings":"AASA,OAAO,EACH,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAGtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAMnE,6DAA6D;AAC7D,wBAAgB,iBAAiB,CAC7B,MAAM,EAAE,cAAc,GAAG,IAAI,EAC7B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,EAAE,OAAc,EAAE,KAAW,EAAE,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5E;IAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAmCpD;AAED,yDAAyD;AACzD,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IACzF,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,8FAA8F;IAC9F,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CA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