@cratis/scene.blueprint.default 4.35.0 → 4.36.0
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/ComponentName.ts +12 -0
- package/defaultBlueprintComponents.ts +5 -1
- package/dist/cjs/ComponentName.js +4 -0
- package/dist/cjs/ComponentName.js.map +1 -1
- package/dist/cjs/defaultBlueprint.js +1 -0
- package/dist/cjs/defaultBlueprint.js.map +1 -1
- package/dist/cjs/defaultBlueprintComponentMetadata.js +1 -0
- package/dist/cjs/defaultBlueprintComponentMetadata.js.map +1 -1
- package/dist/cjs/defaultBlueprintComponents.js +9 -1
- package/dist/cjs/defaultBlueprintComponents.js.map +1 -1
- package/dist/cjs/foundation/ActivityFeed.js +122 -0
- package/dist/cjs/foundation/ActivityFeed.js.map +1 -0
- package/dist/cjs/foundation/AvatarStack.js +73 -0
- package/dist/cjs/foundation/AvatarStack.js.map +1 -0
- package/dist/cjs/foundation/ChecklistSection.js +174 -0
- package/dist/cjs/foundation/ChecklistSection.js.map +1 -0
- package/dist/cjs/foundation/FileUploader.js +218 -0
- package/dist/cjs/foundation/FileUploader.js.map +1 -0
- package/dist/cjs/foundation/FileUploaderHandler.js +17 -0
- package/dist/cjs/foundation/FileUploaderHandler.js.map +1 -0
- package/dist/cjs/foundation/activityModel.js +63 -0
- package/dist/cjs/foundation/activityModel.js.map +1 -0
- package/dist/cjs/foundation/avatarModel.js +42 -0
- package/dist/cjs/foundation/avatarModel.js.map +1 -0
- package/dist/cjs/foundation/checklistModel.js +59 -0
- package/dist/cjs/foundation/checklistModel.js.map +1 -0
- package/dist/cjs/foundation/formatting.js +11 -0
- package/dist/cjs/foundation/formatting.js.map +1 -1
- package/dist/cjs/foundation/foundationComponentMetadata.js +26 -0
- package/dist/cjs/foundation/foundationComponentMetadata.js.map +1 -1
- package/dist/cjs/foundation/foundationDescriptors.js +128 -0
- package/dist/cjs/foundation/foundationDescriptors.js.map +1 -1
- package/dist/cjs/foundation/foundationSamples.js +114 -0
- package/dist/cjs/foundation/foundationSamples.js.map +1 -1
- package/dist/cjs/foundation/foundationStrings.js +15 -0
- package/dist/cjs/foundation/foundationStrings.js.map +1 -1
- package/dist/cjs/foundation/uploadModel.js +71 -0
- package/dist/cjs/foundation/uploadModel.js.map +1 -0
- package/dist/cjs/index.js +33 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/ComponentName.d.ts +5 -1
- package/dist/esm/ComponentName.d.ts.map +1 -1
- package/dist/esm/ComponentName.js +4 -0
- package/dist/esm/ComponentName.js.map +1 -1
- package/dist/esm/defaultBlueprint.js +1 -0
- package/dist/esm/defaultBlueprint.js.map +1 -1
- package/dist/esm/defaultBlueprintComponentMetadata.js +1 -0
- package/dist/esm/defaultBlueprintComponentMetadata.js.map +1 -1
- package/dist/esm/defaultBlueprintComponents.d.ts.map +1 -1
- package/dist/esm/defaultBlueprintComponents.js +9 -1
- package/dist/esm/defaultBlueprintComponents.js.map +1 -1
- package/dist/esm/foundation/ActivityFeed.d.ts +3 -0
- package/dist/esm/foundation/ActivityFeed.d.ts.map +1 -0
- package/dist/esm/foundation/ActivityFeed.js +120 -0
- package/dist/esm/foundation/ActivityFeed.js.map +1 -0
- package/dist/esm/foundation/AvatarStack.d.ts +3 -0
- package/dist/esm/foundation/AvatarStack.d.ts.map +1 -0
- package/dist/esm/foundation/AvatarStack.js +71 -0
- package/dist/esm/foundation/AvatarStack.js.map +1 -0
- package/dist/esm/foundation/ChecklistSection.d.ts +3 -0
- package/dist/esm/foundation/ChecklistSection.d.ts.map +1 -0
- package/dist/esm/foundation/ChecklistSection.js +172 -0
- package/dist/esm/foundation/ChecklistSection.js.map +1 -0
- package/dist/esm/foundation/FileUploader.d.ts +3 -0
- package/dist/esm/foundation/FileUploader.d.ts.map +1 -0
- package/dist/esm/foundation/FileUploader.js +216 -0
- package/dist/esm/foundation/FileUploader.js.map +1 -0
- package/dist/esm/foundation/FileUploaderHandler.d.ts +8 -0
- package/dist/esm/foundation/FileUploaderHandler.d.ts.map +1 -0
- package/dist/esm/foundation/FileUploaderHandler.js +14 -0
- package/dist/esm/foundation/FileUploaderHandler.js.map +1 -0
- package/dist/esm/foundation/Foundation.stories.d.ts +8 -0
- package/dist/esm/foundation/Foundation.stories.d.ts.map +1 -1
- package/dist/esm/foundation/Foundation.stories.js +8 -0
- package/dist/esm/foundation/Foundation.stories.js.map +1 -1
- package/dist/esm/foundation/activityModel.d.ts +22 -0
- package/dist/esm/foundation/activityModel.d.ts.map +1 -0
- package/dist/esm/foundation/activityModel.js +58 -0
- package/dist/esm/foundation/activityModel.js.map +1 -0
- package/dist/esm/foundation/avatarModel.d.ts +11 -0
- package/dist/esm/foundation/avatarModel.d.ts.map +1 -0
- package/dist/esm/foundation/avatarModel.js +38 -0
- package/dist/esm/foundation/avatarModel.js.map +1 -0
- package/dist/esm/foundation/checklistModel.d.ts +17 -0
- package/dist/esm/foundation/checklistModel.d.ts.map +1 -0
- package/dist/esm/foundation/checklistModel.js +53 -0
- package/dist/esm/foundation/checklistModel.js.map +1 -0
- package/dist/esm/foundation/formatting.d.ts +1 -0
- package/dist/esm/foundation/formatting.d.ts.map +1 -1
- package/dist/esm/foundation/formatting.js +11 -1
- package/dist/esm/foundation/formatting.js.map +1 -1
- package/dist/esm/foundation/foundationComponentMetadata.d.ts.map +1 -1
- package/dist/esm/foundation/foundationComponentMetadata.js +26 -0
- package/dist/esm/foundation/foundationComponentMetadata.js.map +1 -1
- package/dist/esm/foundation/foundationDescriptors.d.ts.map +1 -1
- package/dist/esm/foundation/foundationDescriptors.js +128 -0
- package/dist/esm/foundation/foundationDescriptors.js.map +1 -1
- package/dist/esm/foundation/foundationSamples.d.ts.map +1 -1
- package/dist/esm/foundation/foundationSamples.js +114 -0
- package/dist/esm/foundation/foundationSamples.js.map +1 -1
- package/dist/esm/foundation/foundationStrings.d.ts +15 -0
- package/dist/esm/foundation/foundationStrings.d.ts.map +1 -1
- package/dist/esm/foundation/foundationStrings.js +15 -0
- package/dist/esm/foundation/foundationStrings.js.map +1 -1
- package/dist/esm/foundation/index.d.ts +9 -0
- package/dist/esm/foundation/index.d.ts.map +1 -1
- package/dist/esm/foundation/index.js +9 -0
- package/dist/esm/foundation/index.js.map +1 -1
- package/dist/esm/foundation/uploadModel.d.ts +31 -0
- package/dist/esm/foundation/uploadModel.d.ts.map +1 -0
- package/dist/esm/foundation/uploadModel.js +65 -0
- package/dist/esm/foundation/uploadModel.js.map +1 -0
- package/dist/esm/index.js +10 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/foundation/ActivityFeed.tsx +61 -0
- package/foundation/AvatarStack.tsx +43 -0
- package/foundation/ChecklistSection.tsx +80 -0
- package/foundation/FileUploader.tsx +122 -0
- package/foundation/FileUploaderHandler.tsx +22 -0
- package/foundation/Foundation.stories.tsx +8 -0
- package/foundation/activityModel.ts +65 -0
- package/foundation/avatarModel.ts +36 -0
- package/foundation/checklistModel.ts +62 -0
- package/foundation/formatting.ts +9 -0
- package/foundation/foundationComponentMetadata.ts +4 -0
- package/foundation/foundationDescriptors.ts +79 -0
- package/foundation/foundationSamples.ts +29 -0
- package/foundation/foundationStrings.ts +15 -0
- package/foundation/index.ts +9 -0
- package/foundation/uploadModel.ts +66 -0
- package/package.json +8 -8
- package/shell/layout.css +234 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/** What kind of thing happened, which decides the icon and the word that tells it apart without color. */ var ActivityKind = /*#__PURE__*/ function(ActivityKind) {
|
|
4
|
+
ActivityKind["Comment"] = "comment";
|
|
5
|
+
ActivityKind["Change"] = "change";
|
|
6
|
+
ActivityKind["Status"] = "status";
|
|
7
|
+
ActivityKind["System"] = "system";
|
|
8
|
+
return ActivityKind;
|
|
9
|
+
}({});
|
|
10
|
+
/** Reads entries out of a property value, dropping those without an id or a time that parses. */ function readActivity(value) {
|
|
11
|
+
if (!Array.isArray(value)) return [];
|
|
12
|
+
return value.flatMap((entry)=>{
|
|
13
|
+
if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) return [];
|
|
14
|
+
const { id, actor, action, kind, at, body } = entry;
|
|
15
|
+
if (typeof id !== 'string' || typeof at !== 'string' || Number.isNaN(new Date(at).getTime())) return [];
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
id,
|
|
19
|
+
at,
|
|
20
|
+
actor: typeof actor === 'string' ? actor : '',
|
|
21
|
+
action: typeof action === 'string' ? action : '',
|
|
22
|
+
kind: Object.values(ActivityKind).includes(kind) ? kind : "system",
|
|
23
|
+
...typeof body === 'string' && body.length > 0 ? {
|
|
24
|
+
body
|
|
25
|
+
} : {}
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/** The calendar day of an instant in a time zone, as `YYYY-MM-DD`. */ function dayOf(at, timeZone) {
|
|
31
|
+
return new Intl.DateTimeFormat('en-CA', {
|
|
32
|
+
timeZone,
|
|
33
|
+
year: 'numeric',
|
|
34
|
+
month: '2-digit',
|
|
35
|
+
day: '2-digit'
|
|
36
|
+
}).format(new Date(at));
|
|
37
|
+
}
|
|
38
|
+
/** Sorts the entries by time (newest first unless `ascending`) and groups them by calendar day, so a long feed has headings to scan by. */ function groupByDay(entries, ascending = false, timeZone) {
|
|
39
|
+
const sorted = [
|
|
40
|
+
...entries
|
|
41
|
+
].sort((first, second)=>(new Date(first.at).getTime() - new Date(second.at).getTime()) * (ascending ? 1 : -1));
|
|
42
|
+
const days = [];
|
|
43
|
+
for (const entry of sorted){
|
|
44
|
+
const day = dayOf(entry.at, timeZone);
|
|
45
|
+
const last = days[days.length - 1];
|
|
46
|
+
if (last?.day === day) last.entries.push(entry);
|
|
47
|
+
else days.push({
|
|
48
|
+
day,
|
|
49
|
+
entries: [
|
|
50
|
+
entry
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return days;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { ActivityKind, dayOf, groupByDay, readActivity };
|
|
58
|
+
//# sourceMappingURL=activityModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activityModel.js","sources":["../../../foundation/activityModel.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/** What kind of thing happened, which decides the icon and the word that tells it apart without color. */\nexport enum ActivityKind {\n Comment = 'comment',\n Change = 'change',\n Status = 'status',\n System = 'system',\n}\n\n/** One thing that happened to a record. */\nexport interface ActivityEntry {\n id: string;\n actor: string;\n action: string;\n kind: ActivityKind;\n at: string;\n body?: string;\n}\n\n/** The entries of one day, in the order the feed shows them. */\nexport interface ActivityDay {\n day: string;\n entries: ActivityEntry[];\n}\n\n/** Reads entries out of a property value, dropping those without an id or a time that parses. */\nexport function readActivity(value: unknown): ActivityEntry[] {\n if (!Array.isArray(value)) return [];\n\n return value.flatMap((entry): ActivityEntry[] => {\n if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) return [];\n const { id, actor, action, kind, at, body } = entry as Record<string, unknown>;\n if (typeof id !== 'string' || typeof at !== 'string' || Number.isNaN(new Date(at).getTime())) return [];\n\n return [{\n id, at,\n actor: typeof actor === 'string' ? actor : '',\n action: typeof action === 'string' ? action : '',\n kind: (Object.values(ActivityKind) as string[]).includes(kind as string) ? (kind as ActivityKind) : ActivityKind.System,\n ...(typeof body === 'string' && body.length > 0 ? { body } : {}),\n }];\n });\n}\n\n/** The calendar day of an instant in a time zone, as `YYYY-MM-DD`. */\nexport function dayOf(at: string, timeZone?: string): string {\n return new Intl.DateTimeFormat('en-CA', { timeZone, year: 'numeric', month: '2-digit', day: '2-digit' }).format(new Date(at));\n}\n\n/** Sorts the entries by time (newest first unless `ascending`) and groups them by calendar day, so a long feed has headings to scan by. */\nexport function groupByDay(entries: ActivityEntry[], ascending = false, timeZone?: string): ActivityDay[] {\n const sorted = [...entries].sort((first, second) => (new Date(first.at).getTime() - new Date(second.at).getTime()) * (ascending ? 1 : -1));\n const days: ActivityDay[] = [];\n\n for (const entry of sorted) {\n const day = dayOf(entry.at, timeZone);\n const last = days[days.length - 1];\n if (last?.day === day) last.entries.push(entry);\n else days.push({ day, entries: [entry] });\n }\n\n return days;\n}\n"],"names":["ActivityKind","readActivity","value","Array","isArray","flatMap","entry","id","actor","action","kind","at","body","Number","isNaN","Date","getTime","Object","values","includes","length","dayOf","timeZone","Intl","DateTimeFormat","year","month","day","format","groupByDay","entries","ascending","sorted","sort","first","second","days","last","push"],"mappings":"AAAA;AACA;AAEA,2GACO,IAAKA,YAAAA,iBAAAA,SAAAA,YAAAA,EAAAA;;;;;AAAAA,IAAAA,OAAAA,YAAAA;AAKX,CAAA,CAAA,EAAA;AAkBD,kGACO,SAASC,YAAAA,CAAaC,KAAc,EAAA;AACvC,IAAA,IAAI,CAACC,KAAAA,CAAMC,OAAO,CAACF,KAAAA,CAAAA,EAAQ,OAAO,EAAE;IAEpC,OAAOA,KAAAA,CAAMG,OAAO,CAAC,CAACC,KAAAA,GAAAA;QAClB,IAAI,OAAOA,KAAAA,KAAU,QAAA,IAAYA,KAAAA,KAAU,IAAA,IAAQH,MAAMC,OAAO,CAACE,KAAAA,CAAAA,EAAQ,OAAO,EAAE;AAClF,QAAA,MAAM,EAAEC,EAAE,EAAEC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,EAAE,EAAEC,IAAI,EAAE,GAAGN,KAAAA;AAC9C,QAAA,IAAI,OAAOC,EAAAA,KAAO,QAAA,IAAY,OAAOI,OAAO,QAAA,IAAYE,MAAAA,CAAOC,KAAK,CAAC,IAAIC,IAAAA,CAAKJ,EAAAA,CAAAA,CAAIK,OAAO,EAAA,CAAA,EAAK,OAAO,EAAE;QAEvG,OAAO;AAAC,YAAA;AACJT,gBAAAA,EAAAA;AAAII,gBAAA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B,MAAAA,CAAQ;AACxB,QAAA,MAAML,GAAAA,GAAMN,KAAAA,CAAMf,KAAAA,CAAMK,EAAE,EAAEW,QAAAA,CAAAA;AAC5B,QAAA,MAAMe,OAAOD,IAAI,CAACA,IAAAA,CAAKhB,MAAM,GAAG,CAAA,CAAE;AAClC,QAAA,IAAIiB,MAAMV,GAAAA,KAAQA,GAAAA,EAAKU,KAAKP,OAAO,CAACQ,IAAI,CAAChC,KAAAA,CAAAA;AACpC8B,aAAAA,IAAAA,CAAKE,IAAI,CAAC;AAAEX,YAAAA,GAAAA;YAAKG,OAAAA,EAAS;AAACxB,gBAAAA;AAAM;AAAC,SAAA,CAAA;AAC3C,IAAA;IAEA,OAAO8B,IAAAA;AACX;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface AvatarPerson {
|
|
2
|
+
name: string;
|
|
3
|
+
imageUrl?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function readPeople(value: unknown): AvatarPerson[];
|
|
6
|
+
export declare function initialsOf(name: string): string;
|
|
7
|
+
export declare function visiblePeople(people: AvatarPerson[], maximum: number): {
|
|
8
|
+
shown: AvatarPerson[];
|
|
9
|
+
hidden: number;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=avatarModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatarModel.d.ts","sourceRoot":"","sources":["../../../foundation/avatarModel.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,EAAE,CASzD;AAGD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO/C;AAGD,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,YAAY,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAGhH"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/** A person shown as an avatar. */ /** Reads people out of a property value, dropping entries without a name. */ function readPeople(value) {
|
|
4
|
+
if (!Array.isArray(value)) return [];
|
|
5
|
+
return value.flatMap((entry)=>{
|
|
6
|
+
if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) return [];
|
|
7
|
+
const { name, imageUrl } = entry;
|
|
8
|
+
if (typeof name !== 'string' || name.trim().length === 0) return [];
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
name: name.trim(),
|
|
12
|
+
...typeof imageUrl === 'string' && imageUrl.length > 0 ? {
|
|
13
|
+
imageUrl
|
|
14
|
+
} : {}
|
|
15
|
+
}
|
|
16
|
+
];
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/** The initials of a name: the first letter of the first and last words, so "Ada King Lovelace" is AL and "Ada" is A. */ function initialsOf(name) {
|
|
20
|
+
const words = name.split(/\s+/).filter((word)=>word.length > 0);
|
|
21
|
+
if (words.length === 0) return '';
|
|
22
|
+
const first = Array.from(words[0])[0] ?? '';
|
|
23
|
+
const last = words.length > 1 ? Array.from(words[words.length - 1])[0] ?? '' : '';
|
|
24
|
+
return `${first}${last}`.toLocaleUpperCase();
|
|
25
|
+
}
|
|
26
|
+
/** Splits people into those shown and how many are folded into the "+N" chip; at least one is always shown when there are any. */ function visiblePeople(people, maximum) {
|
|
27
|
+
const limit = Math.max(1, Math.floor(maximum));
|
|
28
|
+
return people.length <= limit ? {
|
|
29
|
+
shown: people,
|
|
30
|
+
hidden: 0
|
|
31
|
+
} : {
|
|
32
|
+
shown: people.slice(0, limit),
|
|
33
|
+
hidden: people.length - limit
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { initialsOf, readPeople, visiblePeople };
|
|
38
|
+
//# sourceMappingURL=avatarModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatarModel.js","sources":["../../../foundation/avatarModel.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/** A person shown as an avatar. */\nexport interface AvatarPerson {\n name: string;\n imageUrl?: string;\n}\n\n/** Reads people out of a property value, dropping entries without a name. */\nexport function readPeople(value: unknown): AvatarPerson[] {\n if (!Array.isArray(value)) return [];\n\n return value.flatMap((entry): AvatarPerson[] => {\n if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) return [];\n const { name, imageUrl } = entry as Record<string, unknown>;\n if (typeof name !== 'string' || name.trim().length === 0) return [];\n return [{ name: name.trim(), ...(typeof imageUrl === 'string' && imageUrl.length > 0 ? { imageUrl } : {}) }];\n });\n}\n\n/** The initials of a name: the first letter of the first and last words, so \"Ada King Lovelace\" is AL and \"Ada\" is A. */\nexport function initialsOf(name: string): string {\n const words = name.split(/\\s+/).filter(word => word.length > 0);\n if (words.length === 0) return '';\n\n const first = Array.from(words[0])[0] ?? '';\n const last = words.length > 1 ? Array.from(words[words.length - 1])[0] ?? '' : '';\n return `${first}${last}`.toLocaleUpperCase();\n}\n\n/** Splits people into those shown and how many are folded into the \"+N\" chip; at least one is always shown when there are any. */\nexport function visiblePeople(people: AvatarPerson[], maximum: number): { shown: AvatarPerson[]; hidden: number } {\n const limit = Math.max(1, Math.floor(maximum));\n return people.length <= limit ? { shown: people, hidden: 0 } : { shown: people.slice(0, limit), hidden: people.length - limit };\n}\n"],"names":["readPeople","value","Array","isArray","flatMap","entry","name","imageUrl","trim","length","initialsOf","words","split","filter","word","first","from","last","toLocaleUpperCase","visiblePeople","people","maximum","limit","Math","max","floor","shown","hidden","slice"],"mappings":"AAAA;AACA;AAEA,kHAOO,SAASA,WAAWC,KAAc,EAAA;AACrC,IAAA,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EAAA,GAAK,EAAA;AAC/E,IAAA,OAAO,CAAA,EAAGM,KAAAA,CAAAA,EAAQE,IAAAA,CAAAA,CAAM,CAACC,iBAAiB,EAAA;AAC9C;AAEA,mIACO,SAASC,aAAAA,CAAcC,MAAsB,EAAEC,OAAe,EAAA;AACjE,IAAA,MAAMC,QAAQC,IAAAA,CAAKC,GAAG,CAAC,CAAA,EAAGD,IAAAA,CAAKE,KAAK,CAACJ,OAAAA,CAAAA,CAAAA;IACrC,OAAOD,MAAAA,CAAOX,MAAM,IAAIa,KAAAA,GAAQ;QAAEI,KAAAA,EAAON,MAAAA;QAAQO,MAAAA,EAAQ;KAAE,GAAI;QAAED,KAAAA,EAAON,MAAAA,CAAOQ,KAAK,CAAC,CAAA,EAAGN,KAAAA,CAAAA;QAAQK,MAAAA,EAAQP,MAAAA,CAAOX,MAAM,GAAGa;AAAM,KAAA;AAClI;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ChecklistItem {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
owner?: string;
|
|
5
|
+
due?: string;
|
|
6
|
+
done: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ChecklistGroup {
|
|
9
|
+
title: string;
|
|
10
|
+
items: ChecklistItem[];
|
|
11
|
+
}
|
|
12
|
+
export declare function readChecklist(value: unknown): ChecklistGroup[];
|
|
13
|
+
export declare const completed: (group: ChecklistGroup) => number;
|
|
14
|
+
export declare function isOverdue(item: ChecklistItem, now: Date): boolean;
|
|
15
|
+
export declare const toggleTask: (groups: ChecklistGroup[], id: string) => ChecklistGroup[];
|
|
16
|
+
export declare const doneTaskIds: (groups: ChecklistGroup[]) => string[];
|
|
17
|
+
//# sourceMappingURL=checklistModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checklistModel.d.ts","sourceRoot":"","sources":["../../../foundation/checklistModel.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;CACjB;AAGD,MAAM,WAAW,cAAc;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,aAAa,EAAE,CAAC;CAC1B;AAGD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,EAAE,CAkB9D;AAGD,eAAO,MAAM,SAAS,UAAW,cAAc,KAAG,MAAsD,CAAC;AAGzG,wBAAgB,SAAS,CAAC,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,IAAI,GAAG,OAAO,CASjE;AAGD,eAAO,MAAM,UAAU,WAAY,cAAc,EAAE,MAAM,MAAM,KAAG,cAAc,EAG/D,CAAC;AAGlB,eAAO,MAAM,WAAW,WAAY,cAAc,EAAE,KAAG,MAAM,EAAyF,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/** One task of a checklist. */ /** Reads checklist groups out of a property value; a task needs an id and a label, and is open unless it says it is done. */ function readChecklist(value) {
|
|
4
|
+
if (!Array.isArray(value)) return [];
|
|
5
|
+
return value.flatMap((entry)=>{
|
|
6
|
+
if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) return [];
|
|
7
|
+
const { title, items } = entry;
|
|
8
|
+
if (typeof title !== 'string' || !Array.isArray(items)) return [];
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
title,
|
|
12
|
+
items: items.flatMap((item)=>{
|
|
13
|
+
if (typeof item !== 'object' || item === null || Array.isArray(item)) return [];
|
|
14
|
+
const { id, label, owner, due, done } = item;
|
|
15
|
+
if (typeof id !== 'string' || typeof label !== 'string') return [];
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
id,
|
|
19
|
+
label,
|
|
20
|
+
done: done === true,
|
|
21
|
+
...typeof owner === 'string' ? {
|
|
22
|
+
owner
|
|
23
|
+
} : {},
|
|
24
|
+
...typeof due === 'string' ? {
|
|
25
|
+
due
|
|
26
|
+
} : {}
|
|
27
|
+
}
|
|
28
|
+
];
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/** How many of a group's tasks are done. */ const completed = (group)=>group.items.filter((item)=>item.done).length;
|
|
35
|
+
/** Whether an open task is past its due date, today counting as not yet late. */ function isOverdue(item, now) {
|
|
36
|
+
if (item.done || item.due === undefined) return false;
|
|
37
|
+
const due = new Date(item.due);
|
|
38
|
+
if (Number.isNaN(due.getTime())) return false;
|
|
39
|
+
const endOfDue = new Date(due);
|
|
40
|
+
endOfDue.setUTCHours(23, 59, 59, 999);
|
|
41
|
+
return endOfDue.getTime() < now.getTime();
|
|
42
|
+
}
|
|
43
|
+
/** Marks one task done or open, leaving every other as it was. */ const toggleTask = (groups, id)=>groups.map((group)=>group.items.some((item)=>item.id === id) ? {
|
|
44
|
+
...group,
|
|
45
|
+
items: group.items.map((item)=>item.id === id ? {
|
|
46
|
+
...item,
|
|
47
|
+
done: !item.done
|
|
48
|
+
} : item)
|
|
49
|
+
} : group);
|
|
50
|
+
/** The ids of every done task: what the checklist publishes. */ const doneTaskIds = (groups)=>groups.flatMap((group)=>group.items.filter((item)=>item.done).map((item)=>item.id));
|
|
51
|
+
|
|
52
|
+
export { completed, doneTaskIds, isOverdue, readChecklist, toggleTask };
|
|
53
|
+
//# sourceMappingURL=checklistModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checklistModel.js","sources":["../../../foundation/checklistModel.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/** One task of a checklist. */\nexport interface ChecklistItem {\n id: string;\n label: string;\n owner?: string;\n due?: string;\n done: boolean;\n}\n\n/** A titled group of tasks. */\nexport interface ChecklistGroup {\n title: string;\n items: ChecklistItem[];\n}\n\n/** Reads checklist groups out of a property value; a task needs an id and a label, and is open unless it says it is done. */\nexport function readChecklist(value: unknown): ChecklistGroup[] {\n if (!Array.isArray(value)) return [];\n\n return value.flatMap((entry): ChecklistGroup[] => {\n if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) return [];\n const { title, items } = entry as Record<string, unknown>;\n if (typeof title !== 'string' || !Array.isArray(items)) return [];\n\n return [{\n title,\n items: items.flatMap((item): ChecklistItem[] => {\n if (typeof item !== 'object' || item === null || Array.isArray(item)) return [];\n const { id, label, owner, due, done } = item as Record<string, unknown>;\n if (typeof id !== 'string' || typeof label !== 'string') return [];\n return [{ id, label, done: done === true, ...(typeof owner === 'string' ? { owner } : {}), ...(typeof due === 'string' ? { due } : {}) }];\n }),\n }];\n });\n}\n\n/** How many of a group's tasks are done. */\nexport const completed = (group: ChecklistGroup): number => group.items.filter(item => item.done).length;\n\n/** Whether an open task is past its due date, today counting as not yet late. */\nexport function isOverdue(item: ChecklistItem, now: Date): boolean {\n if (item.done || item.due === undefined) return false;\n\n const due = new Date(item.due);\n if (Number.isNaN(due.getTime())) return false;\n\n const endOfDue = new Date(due);\n endOfDue.setUTCHours(23, 59, 59, 999);\n return endOfDue.getTime() < now.getTime();\n}\n\n/** Marks one task done or open, leaving every other as it was. */\nexport const toggleTask = (groups: ChecklistGroup[], id: string): ChecklistGroup[] =>\n groups.map(group => (group.items.some(item => item.id === id)\n ? { ...group, items: group.items.map(item => (item.id === id ? { ...item, done: !item.done } : item)) }\n : group));\n\n/** The ids of every done task: what the checklist publishes. */\nexport const doneTaskIds = (groups: ChecklistGroup[]): string[] => groups.flatMap(group => group.items.filter(item => item.done).map(item => item.id));\n"],"names":["readChecklist","value","Array","isArray","flatMap","entry","title","items","item","id","label","owner","due","done","completed","group","filter","length","isOverdue","now","undefined","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L,IAAAA;AAAO,SAAA,GACpGO,KAAAA;AAEV,iEACO,MAAMgB,WAAAA,GAAc,CAACH,MAAAA,GAAuCA,MAAAA,CAAOxB,OAAO,CAACW,CAAAA,KAAAA,GAASA,KAAAA,CAAMR,KAAK,CAACS,MAAM,CAACR,CAAAA,IAAAA,GAAQA,IAAAA,CAAKK,IAAI,CAAA,CAAEgB,GAAG,CAACrB,CAAAA,IAAAA,GAAQA,IAAAA,CAAKC,EAAE,CAAA;;"}
|
|
@@ -10,4 +10,5 @@ export declare function isRightToLeft(locale: string): boolean;
|
|
|
10
10
|
export declare function formatNumber(value: number, locale: string, format?: NumberFormat, currency?: string, maximumFractionDigits?: number): string;
|
|
11
11
|
export declare function readNumberFormat(element: ExternalComponent, property?: string): NumberFormat;
|
|
12
12
|
export declare function formatDate(value: unknown, locale: string, withTime?: boolean): string;
|
|
13
|
+
export declare function formatDay(day: string, locale: string): string;
|
|
13
14
|
//# sourceMappingURL=formatting.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../../foundation/formatting.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,oBAAY,YAAY;IACpB,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,OAAO,YAAY;CACtB;AAMD,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAK7D;AAGD,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAQrD;AAGD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,YAAkC,EAAE,QAAQ,SAAQ,EAAE,qBAAqB,CAAC,EAAE,MAAM,GAAG,MAAM,CAehK;AAGD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,SAAW,GAAG,YAAY,CAG9F;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,UAAQ,GAAG,MAAM,CAQnF"}
|
|
1
|
+
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../../foundation/formatting.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,oBAAY,YAAY;IACpB,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,OAAO,YAAY;CACtB;AAMD,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAK7D;AAGD,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAQrD;AAGD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,YAAkC,EAAE,QAAQ,SAAQ,EAAE,qBAAqB,CAAC,EAAE,MAAM,GAAG,MAAM,CAehK;AAGD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,SAAW,GAAG,YAAY,CAG9F;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,UAAQ,GAAG,MAAM,CAQnF;AAGD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAM7D"}
|
|
@@ -73,6 +73,16 @@
|
|
|
73
73
|
return date.toISOString();
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
+
/** Formats a calendar day (`YYYY-MM-DD`) for a locale, as that day and never shifted by the reader's time zone. */ function formatDay(day, locale) {
|
|
77
|
+
try {
|
|
78
|
+
return new Intl.DateTimeFormat(locale, {
|
|
79
|
+
dateStyle: 'full',
|
|
80
|
+
timeZone: 'UTC'
|
|
81
|
+
}).format(new Date(`${day}T12:00:00Z`));
|
|
82
|
+
} catch {
|
|
83
|
+
return day;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
76
86
|
|
|
77
|
-
export { NumberFormat, formatDate, formatNumber, isRightToLeft, readLocale, readNumberFormat };
|
|
87
|
+
export { NumberFormat, formatDate, formatDay, formatNumber, isRightToLeft, readLocale, readNumberFormat };
|
|
78
88
|
//# sourceMappingURL=formatting.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatting.js","sources":["../../../foundation/formatting.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ExternalComponent } from '@cratis/scene.model';\n\n/** How a number is presented. */\nexport enum NumberFormat {\n Number = 'number',\n Currency = 'currency',\n Percent = 'percent',\n Compact = 'compact',\n}\n\n/**\n * The locale a component formats dates, numbers and currency in: the element's `locale`, else the document language, else the\n * runtime's. Formatting never goes through a fixed locale, so the same screen reads correctly in every one.\n */\nexport function readLocale(element: ExternalComponent): string {\n const supplied = element.properties.locale;\n if (typeof supplied === 'string' && supplied.length > 0) return supplied;\n if (typeof document !== 'undefined' && document.documentElement.lang) return document.documentElement.lang;\n return typeof navigator !== 'undefined' && navigator.language ? navigator.language : 'en';\n}\n\n/** Whether the locale reads right to left, so a component can mirror what direction-sensitive CSS cannot. */\nexport function isRightToLeft(locale: string): boolean {\n try {\n const info = new Intl.Locale(locale) as Intl.Locale & { getTextInfo?: () => { direction: string }; textInfo?: { direction: string } };\n const direction = info.getTextInfo?.().direction ?? info.textInfo?.direction;\n return direction === 'rtl';\n } catch {\n return false;\n }\n}\n\n/** Formats a number for a locale, as a plain number, currency, percent (the value is the percentage, 12.5 is 12.5%) or compact. */\nexport function formatNumber(value: number, locale: string, format: NumberFormat = NumberFormat.Number, currency = 'USD', maximumFractionDigits?: number): string {\n try {\n switch (format) {\n case NumberFormat.Currency:\n return new Intl.NumberFormat(locale, { style: 'currency', currency, ...(maximumFractionDigits === undefined ? {} : { maximumFractionDigits }) }).format(value);\n case NumberFormat.Percent:\n return new Intl.NumberFormat(locale, { style: 'percent', maximumFractionDigits: maximumFractionDigits ?? 1 }).format(value / 100);\n case NumberFormat.Compact:\n return new Intl.NumberFormat(locale, { notation: 'compact', maximumFractionDigits: maximumFractionDigits ?? 1 }).format(value);\n default:\n return new Intl.NumberFormat(locale, { maximumFractionDigits: maximumFractionDigits ?? 2 }).format(value);\n }\n } catch {\n return String(value);\n }\n}\n\n/** Reads a number format name, defaulting to a plain number. */\nexport function readNumberFormat(element: ExternalComponent, property = 'format'): NumberFormat {\n const value = element.properties[property];\n return (Object.values(NumberFormat) as string[]).includes(value as string) ? (value as NumberFormat) : NumberFormat.Number;\n}\n\n/** Formats a date or an ISO 8601 date-time for a locale; a value that is not a date is returned as it was written. */\nexport function formatDate(value: unknown, locale: string, withTime = false): string {\n const date = value instanceof Date ? value : typeof value === 'string' || typeof value === 'number' ? new Date(value) : undefined;\n if (!date || Number.isNaN(date.getTime())) return typeof value === 'string' ? value : '';\n try {\n return new Intl.DateTimeFormat(locale, withTime ? { dateStyle: 'medium', timeStyle: 'short' } : { dateStyle: 'medium' }).format(date);\n } catch {\n return date.toISOString();\n }\n}\n"],"names":["NumberFormat","readLocale","element","supplied","properties","locale","length","document","documentElement","lang","navigator","language","isRightToLeft","info","Intl","Locale","direction","getTextInfo","textInfo","formatNumber","value","format","currency","maximumFractionDigits","style","undefined","notation","String","readNumberFormat","property","Object","values","includes","formatDate","withTime","date","Date","Number","isNaN","getTime","DateTimeFormat","dateStyle","timeStyle","toISOString"],"mappings":"AAAA;AACA;AAIA,kCACO,IAAKA,YAAAA,iBAAAA,SAAAA,YAAAA,EAAAA;;;;;AAAAA,IAAAA,OAAAA,YAAAA;AAKX,CAAA,CAAA,EAAA;AAED;;;IAIO,SAASC,UAAAA,CAAWC,OAA0B,EAAA;AACjD,IAAA,MAAMC,QAAAA,GAAWD,OAAAA,CAAQE,UAAU,CAACC,MAAM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,IAAAA,CAAKI,OAAO,EAAA,CAAA,EAAK,OAAO,OAAOnB,KAAAA,KAAU,QAAA,GAAWA,KAAAA,GAAQ,EAAA;IACtF,IAAI;AACA,QAAA,OAAO,IAAIN,IAAAA,CAAK0B,cAAc,CAACnC,QAAQ6B,QAAAA,GAAW;YAAEO,SAAAA,EAAW,QAAA;YAAUC,SAAAA,EAAW;SAAQ,GAAI;YAAED,SAAAA,EAAW;AAAS,SAAA,CAAA,CAAGpB,MAAM,CAACc,IAAAA,CAAAA;AACpI,IAAA,CAAA,CAAE,OAAM;AACJ,QAAA,OAAOA,KAAKQ,WAAW,EAAA;AAC3B,IAAA;AACJ;;"}
|
|
1
|
+
{"version":3,"file":"formatting.js","sources":["../../../foundation/formatting.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ExternalComponent } from '@cratis/scene.model';\n\n/** How a number is presented. */\nexport enum NumberFormat {\n Number = 'number',\n Currency = 'currency',\n Percent = 'percent',\n Compact = 'compact',\n}\n\n/**\n * The locale a component formats dates, numbers and currency in: the element's `locale`, else the document language, else the\n * runtime's. Formatting never goes through a fixed locale, so the same screen reads correctly in every one.\n */\nexport function readLocale(element: ExternalComponent): string {\n const supplied = element.properties.locale;\n if (typeof supplied === 'string' && supplied.length > 0) return supplied;\n if (typeof document !== 'undefined' && document.documentElement.lang) return document.documentElement.lang;\n return typeof navigator !== 'undefined' && navigator.language ? navigator.language : 'en';\n}\n\n/** Whether the locale reads right to left, so a component can mirror what direction-sensitive CSS cannot. */\nexport function isRightToLeft(locale: string): boolean {\n try {\n const info = new Intl.Locale(locale) as Intl.Locale & { getTextInfo?: () => { direction: string }; textInfo?: { direction: string } };\n const direction = info.getTextInfo?.().direction ?? info.textInfo?.direction;\n return direction === 'rtl';\n } catch {\n return false;\n }\n}\n\n/** Formats a number for a locale, as a plain number, currency, percent (the value is the percentage, 12.5 is 12.5%) or compact. */\nexport function formatNumber(value: number, locale: string, format: NumberFormat = NumberFormat.Number, currency = 'USD', maximumFractionDigits?: number): string {\n try {\n switch (format) {\n case NumberFormat.Currency:\n return new Intl.NumberFormat(locale, { style: 'currency', currency, ...(maximumFractionDigits === undefined ? {} : { maximumFractionDigits }) }).format(value);\n case NumberFormat.Percent:\n return new Intl.NumberFormat(locale, { style: 'percent', maximumFractionDigits: maximumFractionDigits ?? 1 }).format(value / 100);\n case NumberFormat.Compact:\n return new Intl.NumberFormat(locale, { notation: 'compact', maximumFractionDigits: maximumFractionDigits ?? 1 }).format(value);\n default:\n return new Intl.NumberFormat(locale, { maximumFractionDigits: maximumFractionDigits ?? 2 }).format(value);\n }\n } catch {\n return String(value);\n }\n}\n\n/** Reads a number format name, defaulting to a plain number. */\nexport function readNumberFormat(element: ExternalComponent, property = 'format'): NumberFormat {\n const value = element.properties[property];\n return (Object.values(NumberFormat) as string[]).includes(value as string) ? (value as NumberFormat) : NumberFormat.Number;\n}\n\n/** Formats a date or an ISO 8601 date-time for a locale; a value that is not a date is returned as it was written. */\nexport function formatDate(value: unknown, locale: string, withTime = false): string {\n const date = value instanceof Date ? value : typeof value === 'string' || typeof value === 'number' ? new Date(value) : undefined;\n if (!date || Number.isNaN(date.getTime())) return typeof value === 'string' ? value : '';\n try {\n return new Intl.DateTimeFormat(locale, withTime ? { dateStyle: 'medium', timeStyle: 'short' } : { dateStyle: 'medium' }).format(date);\n } catch {\n return date.toISOString();\n }\n}\n\n/** Formats a calendar day (`YYYY-MM-DD`) for a locale, as that day and never shifted by the reader's time zone. */\nexport function formatDay(day: string, locale: string): string {\n try {\n return new Intl.DateTimeFormat(locale, { dateStyle: 'full', timeZone: 'UTC' }).format(new Date(`${day}T12:00:00Z`));\n } catch {\n return day;\n }\n}\n"],"names":["NumberFormat","readLocale","element","supplied","properties","locale","length","document","documentElement","lang","navigator","language","isRightToLeft","info","Intl","Locale","direction","getTextInfo","textInfo","formatNumber","value","format","currency","maximumFractionDigits","style","undefined","notation","String","readNumberFormat","property","Object","values","includes","formatDate","withTime","date","Date","Number","isNaN","getTime","DateTimeFormat","dateStyle","timeStyle","toISOString","formatDay","day","timeZone"],"mappings":"AAAA;AACA;AAIA,kCACO,IAAKA,YAAAA,iBAAAA,SAAAA,YAAAA,EAAAA;;;;;AAAAA,IAAAA,OAAAA,YAAAA;AAKX,CAAA,CAAA,EAAA;AAED;;;IAIO,SAASC,UAAAA,CAAWC,OAA0B,EAAA;AACjD,IAAA,MAAMC,QAAAA,GAAWD,OAAAA,CAAQE,UAAU,CAACC,MAAM;AAC1C,IAAA,IAAI,OAAOF,QAAAA,KAAa,QAAA,IAAYA,SAASG,MAAM,GAAG,GAAG,OAAOH,QAAAA;AAChE,IAAA,IAAI,OAAOI,QAAAA,KAAa,WAAA,IAAeA,QAAAA,CAASC,eAAe,CAACC,IAAI,EAAE,OAAOF,QAAAA,CAASC,eAAe,CAACC,IAAI;IAC1G,OAAO,OAAOC,cAAc,WAAA,IAAeA,SAAAA,CAAUC,QAAQ,GAAGD,SAAAA,CAAUC,QAAQ,GAAG,IAAA;AACzF;AAEA,8GACO,SAASC,aAAAA,CAAcP,MAAc,EAAA;IACxC,IAAI;AACA,QAAA,MAAMQ,IAAAA,GAAO,IAAIC,IAAAA,CAAKC,MAAM,CAACV,MAAAA,CAAAA;AAC7B,QAAA,MAAMW,YAAYH,IAAAA,CAAKI,WAAW,KAAKD,SAAAA,IAAaH,IAAAA,CAAKK,QAAQ,EAAEF,SAAAA;AACnE,QAAA,OAAOA,SAAAA,KAAc,KAAA;AACzB,IAAA,CAAA,CAAE,OAAM;QACJ,OAAO,KAAA;AACX,IAAA;AACJ;AAEA,oIACO,SAASG,YAAAA,CAAaC,KAAa,EAAEf,MAAc,EAAEgB,MAAAA,GAAAA,QAA0C,EAAEC,QAAAA,GAAW,KAAK,EAAEC,qBAA8B,EAAA;IACpJ,IAAI;QACA,OAAQF,MAAAA;AACJ,YAAA,KAAA,UAAA;AACI,gBAAA,OAAO,IAAIP,IAAAA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IA,OAAO,EAAE,iBAAiB,EAA0B,MAAM,qBAAqB,CAAC;AAOhF,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"foundationComponentMetadata.d.ts","sourceRoot":"","sources":["../../../foundation/foundationComponentMetadata.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAA0B,MAAM,qBAAqB,CAAC;AAOhF,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAazE,CAAC"}
|
|
@@ -60,6 +60,32 @@ import { ComponentName } from '../ComponentName.js';
|
|
|
60
60
|
'views',
|
|
61
61
|
'presets',
|
|
62
62
|
'saved filters'
|
|
63
|
+
]),
|
|
64
|
+
[ComponentName.ChecklistSection]: componentMetadata('Checklist', ComponentCategory.DataDisplay, 'list-checks', [
|
|
65
|
+
'tasks',
|
|
66
|
+
'todo',
|
|
67
|
+
'onboarding',
|
|
68
|
+
'progress',
|
|
69
|
+
'steps'
|
|
70
|
+
]),
|
|
71
|
+
[ComponentName.ActivityFeed]: componentMetadata('Activity feed', ComponentCategory.DataDisplay, 'activity', [
|
|
72
|
+
'timeline',
|
|
73
|
+
'history',
|
|
74
|
+
'comments',
|
|
75
|
+
'audit',
|
|
76
|
+
'log'
|
|
77
|
+
]),
|
|
78
|
+
[ComponentName.AvatarStack]: componentMetadata('Avatar stack', ComponentCategory.DataDisplay, 'users', [
|
|
79
|
+
'people',
|
|
80
|
+
'members',
|
|
81
|
+
'assignees',
|
|
82
|
+
'team'
|
|
83
|
+
]),
|
|
84
|
+
[ComponentName.FileUploader]: componentMetadata('File uploader', ComponentCategory.Input, 'upload', [
|
|
85
|
+
'attachments',
|
|
86
|
+
'files',
|
|
87
|
+
'drop zone',
|
|
88
|
+
'documents'
|
|
63
89
|
])
|
|
64
90
|
};
|
|
65
91
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"foundationComponentMetadata.js","sources":["../../../foundation/foundationComponentMetadata.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ComponentCategory } from '@cratis/scene.model';\nimport { ComponentMetadata, componentMetadata as m } from '@cratis/scene.react';\nimport { ComponentName } from '../ComponentName';\n\n/**\n * The category, icon, keywords and picker badge of every foundation component (CMP1), keyed by bare component name.\n * The names are those of `ComponentName`; the metadata of the rest of the package lives in `defaultBlueprintComponentMetadata`.\n */\nexport const foundationComponentMetadata: Record<string, ComponentMetadata> = {\n [ComponentName.EmptyState]: m('Empty state', ComponentCategory.Feedback, 'inbox', ['no data', 'nothing', 'blank slate', 'zero state']),\n [ComponentName.StatCard]: m('Stat card', ComponentCategory.DataDisplay, 'gauge', ['kpi', 'metric', 'figure', 'number', 'dashboard']),\n [ComponentName.TrendChip]: m('Trend chip', ComponentCategory.DataDisplay, 'trending-up', ['delta', 'change', 'arrow', 'comparison']),\n [ComponentName.StatusChip]: m('Status chip', ComponentCategory.DataDisplay, 'badge-check', ['badge', 'state', 'tag', 'label']),\n [ComponentName.ChartWrapper]: m('Chart', ComponentCategory.DataDisplay, 'chart-line', ['graph', 'line', 'bar', 'stacked', 'donut', 'pie', 'funnel', 'plot']),\n [ComponentName.FilterBuilder]: m('Filter builder', ComponentCategory.Input, 'list-filter', ['filter', 'query', 'conditions', 'and or', 'search']),\n [ComponentName.ColumnChooser]: m('Column chooser', ComponentCategory.Actions, 'columns-3', ['columns', 'fields', 'show hide', 'table']),\n [ComponentName.SavedViewsMenu]: m('Saved views menu', ComponentCategory.Actions, 'bookmark', ['views', 'presets', 'saved filters']),\n};\n"],"names":["foundationComponentMetadata","ComponentName","EmptyState","m","ComponentCategory","Feedback","StatCard","DataDisplay","TrendChip","StatusChip","ChartWrapper","FilterBuilder","Input","ColumnChooser","Actions","SavedViewsMenu"],"mappings":";;;;AAAA;AACA;AAMA;;;UAIaA,2BAAAA,GAAiE;IAC1E,CAACC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X,aAAAA,CAAcY,aAAa,GAAGV,kBAAE,gBAAA,EAAkBC,iBAAAA,CAAkBU,OAAO,EAAE,WAAA,EAAa;AAAC,QAAA,SAAA;AAAW,QAAA,QAAA;AAAU,QAAA,WAAA;AAAa,QAAA;AAAQ,KAAA,CAAA;IACtI,CAACb,aAAAA,CAAcc,cAAc,GAAGZ,kBAAE,kBAAA,EAAoBC,iBAAAA,CAAkBU,OAAO,EAAE,UAAA,EAAY;AAAC,QAAA,OAAA;AAAS,QAAA,SAAA;AAAW,QAAA;AAAgB,KAAA;
|
|
1
|
+
{"version":3,"file":"foundationComponentMetadata.js","sources":["../../../foundation/foundationComponentMetadata.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ComponentCategory } from '@cratis/scene.model';\nimport { ComponentMetadata, componentMetadata as m } from '@cratis/scene.react';\nimport { ComponentName } from '../ComponentName';\n\n/**\n * The category, icon, keywords and picker badge of every foundation component (CMP1), keyed by bare component name.\n * The names are those of `ComponentName`; the metadata of the rest of the package lives in `defaultBlueprintComponentMetadata`.\n */\nexport const foundationComponentMetadata: Record<string, ComponentMetadata> = {\n [ComponentName.EmptyState]: m('Empty state', ComponentCategory.Feedback, 'inbox', ['no data', 'nothing', 'blank slate', 'zero state']),\n [ComponentName.StatCard]: m('Stat card', ComponentCategory.DataDisplay, 'gauge', ['kpi', 'metric', 'figure', 'number', 'dashboard']),\n [ComponentName.TrendChip]: m('Trend chip', ComponentCategory.DataDisplay, 'trending-up', ['delta', 'change', 'arrow', 'comparison']),\n [ComponentName.StatusChip]: m('Status chip', ComponentCategory.DataDisplay, 'badge-check', ['badge', 'state', 'tag', 'label']),\n [ComponentName.ChartWrapper]: m('Chart', ComponentCategory.DataDisplay, 'chart-line', ['graph', 'line', 'bar', 'stacked', 'donut', 'pie', 'funnel', 'plot']),\n [ComponentName.FilterBuilder]: m('Filter builder', ComponentCategory.Input, 'list-filter', ['filter', 'query', 'conditions', 'and or', 'search']),\n [ComponentName.ColumnChooser]: m('Column chooser', ComponentCategory.Actions, 'columns-3', ['columns', 'fields', 'show hide', 'table']),\n [ComponentName.SavedViewsMenu]: m('Saved views menu', ComponentCategory.Actions, 'bookmark', ['views', 'presets', 'saved filters']),\n [ComponentName.ChecklistSection]: m('Checklist', ComponentCategory.DataDisplay, 'list-checks', ['tasks', 'todo', 'onboarding', 'progress', 'steps']),\n [ComponentName.ActivityFeed]: m('Activity feed', ComponentCategory.DataDisplay, 'activity', ['timeline', 'history', 'comments', 'audit', 'log']),\n [ComponentName.AvatarStack]: m('Avatar stack', ComponentCategory.DataDisplay, 'users', ['people', 'members', 'assignees', 'team']),\n [ComponentName.FileUploader]: m('File uploader', ComponentCategory.Input, 'upload', ['attachments', 'files', 'drop zone', 'documents']),\n};\n"],"names":["foundationComponentMetadata","ComponentName","EmptyState","m","ComponentCategory","Feedback","StatCard","DataDisplay","TrendChip","StatusChip","ChartWrapper","FilterBuilder","Input","ColumnChooser","Actions","SavedViewsMenu","ChecklistSection","ActivityFeed","AvatarStack","FileUploader"],"mappings":";;;;AAAA;AACA;AAMA;;;UAIaA,2BAAAA,GAAiE;IAC1E,CAACC,aAAAA,CAAcC,UAAU,GAAGC,kBAAE,aAAA,EAAeC,iBAAAA,CAAkBC,QAAQ,EAAE,OAAA,EAAS;AAAC,QAAA,SAAA;AAAW,QAAA,SAAA;AAAW,QAAA,aAAA;AAAe,QAAA;AAAa,KAAA,CAAA;IACrI,CAACJ,aAAAA,CAAcK,QAAQ,GAAGH,kBAAE,WAAA,EAAaC,iBAAAA,CAAkBG,WAAW,EAAE,OAAA,EAAS;AAAC,QAAA,KAAA;AAAO,QAAA,QAAA;AAAU,QAAA,QAAA;AAAU,QAAA,QAAA;AAAU,QAAA;AAAY,KAAA,CAAA;IACnI,CAACN,aAAAA,CAAcO,SAAS,GAAGL,kBAAE,YAAA,EAAcC,iBAAAA,CAAkBG,WAAW,EAAE,aAAA,EAAe;AAA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AA;AAAQ,QAAA,YAAA;AAAc,QAAA,UAAA;AAAY,QAAA;AAAQ,KAAA,CAAA;IACnJ,CAACN,aAAAA,CAAcgB,YAAY,GAAGd,kBAAE,eAAA,EAAiBC,iBAAAA,CAAkBG,WAAW,EAAE,UAAA,EAAY;AAAC,QAAA,UAAA;AAAY,QAAA,SAAA;AAAW,QAAA,UAAA;AAAY,QAAA,OAAA;AAAS,QAAA;AAAM,KAAA,CAAA;IAC/I,CAACN,aAAAA,CAAciB,WAAW,GAAGf,kBAAE,cAAA,EAAgBC,iBAAAA,CAAkBG,WAAW,EAAE,OAAA,EAAS;AAAC,QAAA,QAAA;AAAU,QAAA,SAAA;AAAW,QAAA,WAAA;AAAa,QAAA;AAAO,KAAA,CAAA;IACjI,CAACN,aAAAA,CAAckB,YAAY,GAAGhB,kBAAE,eAAA,EAAiBC,iBAAAA,CAAkBQ,KAAK,EAAE,QAAA,EAAU;AAAC,QAAA,aAAA;AAAe,QAAA,OAAA;AAAS,QAAA,WAAA;AAAa,QAAA;AAAY,KAAA;AAC1I;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"foundationDescriptors.d.ts","sourceRoot":"","sources":["../../../foundation/foundationDescriptors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,kBAAkB,EAAyC,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"foundationDescriptors.d.ts","sourceRoot":"","sources":["../../../foundation/foundationDescriptors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,kBAAkB,EAAyC,MAAM,qBAAqB,CAAC;AAaxI,eAAO,MAAM,QAAQ,qBAAsG,CAAC;AAiB5H,eAAO,MAAM,IAAI,SAAU,MAAM,SAAS,MAAM,SAAS,MAAM,aAAa,MAAM,cAAc,kBAAkB,EAAE,gBAAgB,MAAM,KAAG,kBACoC,CAAC;AAMlL,eAAO,MAAM,uBAAuB,EAAE,kBAAkB,EAkBvD,CAAC;AAOF,eAAO,MAAM,qBAAqB,EAAE,mBAAmB,EAwNtD,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { BindingSourceKind, PropertyEditorKind, PropertyValueType } from '@crati
|
|
|
2
2
|
import { valueOutputProperty, componentRegistryKey } from '@cratis/scene.react';
|
|
3
3
|
import { ComponentName } from '../ComponentName.js';
|
|
4
4
|
import { defaultBlueprintName } from '../packageName.js';
|
|
5
|
+
import { ActivityKind } from './activityModel.js';
|
|
5
6
|
import { ChartKind } from './chartGeometry.js';
|
|
6
7
|
import { ComponentState } from './ComponentState.js';
|
|
7
8
|
import { FilterFieldType } from './filterModel.js';
|
|
@@ -373,6 +374,133 @@ const formats = {
|
|
|
373
374
|
},
|
|
374
375
|
...standardStateProperties
|
|
375
376
|
]
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
component: key(ComponentName.ChecklistSection),
|
|
380
|
+
displayName: 'Checklist',
|
|
381
|
+
description: 'Sections of tasks with an owner and due date each and a progress bar per section. Publishes the ids of the done tasks as the value output.',
|
|
382
|
+
properties: [
|
|
383
|
+
{
|
|
384
|
+
...list('sections', 'Sections', 'Data', 'Section', [
|
|
385
|
+
text('title', 'Title', 'Content', undefined, {
|
|
386
|
+
constraints: {
|
|
387
|
+
required: true
|
|
388
|
+
}
|
|
389
|
+
}),
|
|
390
|
+
list('items', 'Tasks', 'Data', 'Task', [
|
|
391
|
+
text('id', 'Id', 'Data', undefined, {
|
|
392
|
+
constraints: {
|
|
393
|
+
required: true
|
|
394
|
+
}
|
|
395
|
+
}),
|
|
396
|
+
text('label', 'Task', 'Content', undefined, {
|
|
397
|
+
constraints: {
|
|
398
|
+
required: true
|
|
399
|
+
}
|
|
400
|
+
}),
|
|
401
|
+
text('owner', 'Owner', 'Data'),
|
|
402
|
+
text('due', 'Due date', 'Data', 'An ISO 8601 date.'),
|
|
403
|
+
flag('done', 'Done', 'Data')
|
|
404
|
+
])
|
|
405
|
+
], 'The groups of tasks.'),
|
|
406
|
+
acceptedBindingKinds: bindable
|
|
407
|
+
},
|
|
408
|
+
text('today', 'Today', 'Content', 'The date overdue is judged against; empty is the current date.'),
|
|
409
|
+
rule('editPermission', 'Edit permission', 'Enabled lets the user tick tasks; otherwise they are shown read-only.'),
|
|
410
|
+
valueOutputProperty(PropertyValueType.Json, 'The ids of the done tasks, published as the user ticks them.'),
|
|
411
|
+
...standardStateProperties
|
|
412
|
+
]
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
component: key(ComponentName.ActivityFeed),
|
|
416
|
+
displayName: 'Activity feed',
|
|
417
|
+
description: 'What happened to a record, grouped by day. Content is supplied by the application; this lays it out.',
|
|
418
|
+
properties: [
|
|
419
|
+
{
|
|
420
|
+
...list('entries', 'Entries', 'Data', 'Entry', [
|
|
421
|
+
text('id', 'Id', 'Data', undefined, {
|
|
422
|
+
constraints: {
|
|
423
|
+
required: true
|
|
424
|
+
}
|
|
425
|
+
}),
|
|
426
|
+
text('actor', 'Who', 'Data'),
|
|
427
|
+
text('action', 'What', 'Data'),
|
|
428
|
+
choice('kind', 'Kind', 'Data', {
|
|
429
|
+
[ActivityKind.Comment]: 'Comment',
|
|
430
|
+
[ActivityKind.Change]: 'Change',
|
|
431
|
+
[ActivityKind.Status]: 'Status',
|
|
432
|
+
[ActivityKind.System]: 'System'
|
|
433
|
+
}, ActivityKind.System),
|
|
434
|
+
text('at', 'When', 'Data', 'An ISO 8601 date and time.', {
|
|
435
|
+
constraints: {
|
|
436
|
+
required: true
|
|
437
|
+
}
|
|
438
|
+
}),
|
|
439
|
+
text('body', 'Text', 'Data', 'A comment\'s text or the detail of a change.', {
|
|
440
|
+
editorOptions: {
|
|
441
|
+
multiline: true
|
|
442
|
+
}
|
|
443
|
+
})
|
|
444
|
+
], 'What happened.'),
|
|
445
|
+
acceptedBindingKinds: bindable
|
|
446
|
+
},
|
|
447
|
+
choice('order', 'Order', 'Appearance', {
|
|
448
|
+
descending: 'Newest first',
|
|
449
|
+
ascending: 'Oldest first'
|
|
450
|
+
}, 'descending'),
|
|
451
|
+
text('timeZone', 'Time zone', 'Content', 'The IANA zone days are cut in; empty is the reader\'s.'),
|
|
452
|
+
...standardStateProperties
|
|
453
|
+
]
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
component: key(ComponentName.AvatarStack),
|
|
457
|
+
displayName: 'Avatar stack',
|
|
458
|
+
description: 'Overlapping avatars for the people on a record, with a "+N" chip for the rest.',
|
|
459
|
+
properties: [
|
|
460
|
+
{
|
|
461
|
+
...list('people', 'People', 'Data', 'Person', [
|
|
462
|
+
text('name', 'Name', 'Data', undefined, {
|
|
463
|
+
constraints: {
|
|
464
|
+
required: true
|
|
465
|
+
}
|
|
466
|
+
}),
|
|
467
|
+
text('imageUrl', 'Picture', 'Data', 'Without one the initials are shown.')
|
|
468
|
+
], 'Who is shown.'),
|
|
469
|
+
acceptedBindingKinds: bindable
|
|
470
|
+
},
|
|
471
|
+
number('max', 'Shown at most', 'Appearance', 'How many avatars before the rest fold into "+N".', {
|
|
472
|
+
default: 4,
|
|
473
|
+
constraints: {
|
|
474
|
+
minimum: 1,
|
|
475
|
+
integer: true
|
|
476
|
+
}
|
|
477
|
+
}),
|
|
478
|
+
choice('size', 'Size', 'Appearance', {
|
|
479
|
+
small: 'Small',
|
|
480
|
+
medium: 'Medium'
|
|
481
|
+
}, 'medium'),
|
|
482
|
+
...standardStateProperties
|
|
483
|
+
]
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
component: key(ComponentName.FileUploader),
|
|
487
|
+
displayName: 'File uploader',
|
|
488
|
+
description: 'A drop zone and a button to choose files, checked against type and size before anything is sent. Publishes the selection as the value output.',
|
|
489
|
+
properties: [
|
|
490
|
+
text('accept', 'Accepted types', 'Behavior', 'Extensions, MIME types and wildcards separated by commas, for example ".pdf, image/*".'),
|
|
491
|
+
number('maxSizeMb', 'Largest file (MB)', 'Behavior', undefined, {
|
|
492
|
+
constraints: {
|
|
493
|
+
minimum: 0
|
|
494
|
+
}
|
|
495
|
+
}),
|
|
496
|
+
flag('multiple', 'Several files', 'Behavior', undefined, {
|
|
497
|
+
default: true
|
|
498
|
+
}),
|
|
499
|
+
text('serverUrl', 'Upload address', 'Behavior', 'Handed to the host\'s upload handler.'),
|
|
500
|
+
rule('actionPermission', 'Upload permission', 'Whether files can be chosen or dropped, refused with a reason, or the control is hidden.'),
|
|
501
|
+
valueOutputProperty(PropertyValueType.Json, 'The files chosen - name, size, type and status - published as they change.'),
|
|
502
|
+
...standardStateProperties.filter((property)=>property.path !== 'actionPermission')
|
|
503
|
+
]
|
|
376
504
|
}
|
|
377
505
|
];
|
|
378
506
|
|