@profitstudio/booking-engine 0.0.0-stage → 2.0.0-beta.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.
Files changed (114) hide show
  1. package/CHANGELOG.md +562 -0
  2. package/LICENSE +21 -0
  3. package/README.md +18 -2
  4. package/THIRD_PARTY_NOTICES.md +41 -0
  5. package/bin/booking-engine.mjs +575 -0
  6. package/bin/connect.mjs +408 -0
  7. package/bin/photos.mjs +82 -0
  8. package/dist/admin/BookingAdmin.d.ts +22 -0
  9. package/dist/admin/BookingAdmin.js +337 -0
  10. package/dist/admin/admin.css +1423 -0
  11. package/dist/admin/alerts.d.ts +10 -0
  12. package/dist/admin/alerts.js +11 -0
  13. package/dist/admin/booking-detail.d.ts +37 -0
  14. package/dist/admin/booking-detail.js +149 -0
  15. package/dist/admin/content-inputs.d.ts +15 -0
  16. package/dist/admin/content-inputs.js +105 -0
  17. package/dist/admin/context.d.ts +37 -0
  18. package/dist/admin/context.js +8 -0
  19. package/dist/admin/drawer.d.ts +14 -0
  20. package/dist/admin/drawer.js +56 -0
  21. package/dist/admin/feedback.d.ts +32 -0
  22. package/dist/admin/feedback.js +70 -0
  23. package/dist/admin/fields.d.ts +27 -0
  24. package/dist/admin/fields.js +146 -0
  25. package/dist/admin/fonts/OFL-Geist-Mono.txt +93 -0
  26. package/dist/admin/fonts/OFL-Geist.txt +93 -0
  27. package/dist/admin/fonts/geist-latin-wght-normal.woff2 +0 -0
  28. package/dist/admin/fonts/geist-mono-latin-wght-normal.woff2 +0 -0
  29. package/dist/admin/icons.d.ts +66 -0
  30. package/dist/admin/icons.js +72 -0
  31. package/dist/admin/image-upload.d.ts +58 -0
  32. package/dist/admin/image-upload.js +111 -0
  33. package/dist/admin/index.d.ts +6 -0
  34. package/dist/admin/index.js +6 -0
  35. package/dist/admin/lucide.generated.d.ts +521 -0
  36. package/dist/admin/lucide.generated.js +76 -0
  37. package/dist/admin/sections/BookingsSection.d.ts +1 -0
  38. package/dist/admin/sections/BookingsSection.js +137 -0
  39. package/dist/admin/sections/EmailSection.d.ts +8 -0
  40. package/dist/admin/sections/EmailSection.js +182 -0
  41. package/dist/admin/sections/HoursSection.d.ts +1 -0
  42. package/dist/admin/sections/HoursSection.js +110 -0
  43. package/dist/admin/sections/OverviewSection.d.ts +1 -0
  44. package/dist/admin/sections/OverviewSection.js +427 -0
  45. package/dist/admin/sections/ServicesSection.d.ts +1 -0
  46. package/dist/admin/sections/ServicesSection.js +236 -0
  47. package/dist/admin/sections/SettingsSection.d.ts +10 -0
  48. package/dist/admin/sections/SettingsSection.js +96 -0
  49. package/dist/admin/sections/WebsiteSection.d.ts +1 -0
  50. package/dist/admin/sections/WebsiteSection.js +228 -0
  51. package/dist/admin/sections.d.ts +22 -0
  52. package/dist/admin/sections.js +29 -0
  53. package/dist/admin/setup.d.ts +1 -0
  54. package/dist/admin/setup.js +45 -0
  55. package/dist/admin/today.d.ts +43 -0
  56. package/dist/admin/today.js +115 -0
  57. package/dist/admin/ui.d.ts +134 -0
  58. package/dist/admin/ui.js +220 -0
  59. package/dist/calendar.d.ts +64 -0
  60. package/dist/calendar.js +139 -0
  61. package/dist/client.d.ts +147 -0
  62. package/dist/client.js +507 -0
  63. package/dist/config.d.ts +25 -0
  64. package/dist/config.js +120 -0
  65. package/dist/content/image.d.ts +20 -0
  66. package/dist/content/image.js +90 -0
  67. package/dist/content/resolve.d.ts +12 -0
  68. package/dist/content/resolve.js +73 -0
  69. package/dist/content/schema.d.ts +119 -0
  70. package/dist/content/schema.js +53 -0
  71. package/dist/content/store.d.ts +48 -0
  72. package/dist/content/store.js +123 -0
  73. package/dist/content/validate.d.ts +33 -0
  74. package/dist/content/validate.js +177 -0
  75. package/dist/errors.d.ts +19 -0
  76. package/dist/errors.js +94 -0
  77. package/dist/generated/manifest.d.ts +6 -0
  78. package/dist/generated/manifest.js +7 -0
  79. package/dist/index.d.ts +20 -0
  80. package/dist/index.js +20 -0
  81. package/dist/presets/hair-salon.d.ts +8 -0
  82. package/dist/presets/hair-salon.js +94 -0
  83. package/dist/presets/index.d.ts +5 -0
  84. package/dist/presets/index.js +6 -0
  85. package/dist/preview.d.ts +18 -0
  86. package/dist/preview.js +134 -0
  87. package/dist/semver.d.ts +16 -0
  88. package/dist/semver.js +55 -0
  89. package/dist/time.d.ts +31 -0
  90. package/dist/time.js +138 -0
  91. package/dist/types.d.ts +477 -0
  92. package/dist/types.js +3 -0
  93. package/dist/vite.d.ts +52 -0
  94. package/dist/vite.js +150 -0
  95. package/docs/BUILD-A-SITE.md +203 -0
  96. package/docs/EMAIL-SETUP.md +224 -0
  97. package/docs/INTEGRATION.md +1109 -0
  98. package/engine.manifest.json +90 -0
  99. package/functions/booking-mailer/deno.json +6 -0
  100. package/functions/booking-mailer/index.ts +44 -0
  101. package/functions/booking-mailer/mailer.js +156 -0
  102. package/functions/booking-mailer/providers/index.js +42 -0
  103. package/functions/booking-mailer/providers/resend.js +75 -0
  104. package/functions/booking-mailer/templates.js +345 -0
  105. package/migrations/0001_core.sql +1673 -0
  106. package/migrations/0002_security_hardening.sql +711 -0
  107. package/migrations/0003_private_definers_and_holds.sql +808 -0
  108. package/migrations/0004_verified_requests.sql +1702 -0
  109. package/migrations/0005_scoped_mailer_credential.sql +347 -0
  110. package/migrations/0006_trusted_client_ip.sql +56 -0
  111. package/migrations/0007_site_content.sql +380 -0
  112. package/migrations/0008_service_images_opening_times.sql +328 -0
  113. package/package.json +85 -4
  114. package/templates/BOOKING_ENGINE.md +61 -0
@@ -0,0 +1,146 @@
1
+ export const BUSINESS_GROUP = {
2
+ id: 'business',
3
+ title: 'Business information',
4
+ intro: 'Shown on your website and used for every date and time in the booking system.',
5
+ fields: [
6
+ { key: 'businessName', label: 'Business name', help: 'As customers should see it.', kind: 'text', maxLength: 120 },
7
+ {
8
+ key: 'timezone',
9
+ label: 'Time zone',
10
+ help: 'Where your appointments take place. All booking times use this zone, whatever the customer’s device says. Changing it does not move existing appointments.',
11
+ kind: 'timezone',
12
+ },
13
+ {
14
+ key: 'currency',
15
+ label: 'Currency',
16
+ help: 'Three-letter code used for prices, e.g. USD, EUR, GBP.',
17
+ kind: 'currency',
18
+ maxLength: 3,
19
+ },
20
+ {
21
+ key: 'locale',
22
+ label: 'Language and region',
23
+ help: 'Controls date, time and price formatting, e.g. en-US, en-GB, fr-FR.',
24
+ kind: 'text',
25
+ maxLength: 35,
26
+ placeholder: 'en-US',
27
+ },
28
+ { key: 'publicEmail', label: 'Public email', help: 'Optional. Shown to customers.', kind: 'email', maxLength: 254 },
29
+ { key: 'publicPhone', label: 'Public phone', help: 'Optional. Shown to customers.', kind: 'tel', maxLength: 40 },
30
+ { key: 'address', label: 'Address', help: 'Optional. Where customers come for their appointment.', kind: 'textarea', maxLength: 300 },
31
+ ],
32
+ };
33
+ export const POLICY_GROUP = {
34
+ id: 'policies',
35
+ title: 'Booking policies',
36
+ intro: 'Rules the booking system enforces on every request. They apply immediately. Every online request comes from a customer who has confirmed their email address with a code.',
37
+ fields: [
38
+ {
39
+ key: 'autoConfirm',
40
+ label: 'Confirm verified requests instantly',
41
+ help: 'On: the appointment is booked as soon as the customer enters their email code, and they receive a confirmation email. Off: you confirm or decline each request in Bookings, and the customer is emailed either way.',
42
+ kind: 'boolean',
43
+ },
44
+ {
45
+ key: 'pendingHoldMinutes',
46
+ label: 'Hold a requested time for',
47
+ help: 'A request waiting for your answer keeps its time reserved for this long. If you have not confirmed it by then, other customers can book that time again (the customer is told by email) — and you can still confirm the request if nobody has.',
48
+ kind: 'select',
49
+ options: [
50
+ { value: 30, label: '30 minutes' },
51
+ { value: 60, label: '1 hour' },
52
+ { value: 120, label: '2 hours' },
53
+ { value: 240, label: '4 hours' },
54
+ { value: 720, label: '12 hours' },
55
+ { value: 1440, label: '24 hours' },
56
+ { value: 2880, label: '2 days' },
57
+ { value: 4320, label: '3 days' },
58
+ { value: 10080, label: '1 week' },
59
+ ],
60
+ },
61
+ {
62
+ key: 'slotIntervalMinutes',
63
+ label: 'Start times every',
64
+ help: 'How often a start time is offered. 15 minutes gives customers more choice; 30 or 60 keeps your day tidier.',
65
+ kind: 'select',
66
+ options: [5, 10, 15, 20, 30, 45, 60, 90, 120].map((m) => ({ value: m, label: `${m} minutes` })),
67
+ },
68
+ {
69
+ key: 'minNoticeMinutes',
70
+ label: 'Minimum notice',
71
+ help: 'How long before an appointment customers must book online.',
72
+ kind: 'select',
73
+ options: [
74
+ { value: 0, label: 'No minimum' },
75
+ { value: 30, label: '30 minutes' },
76
+ { value: 60, label: '1 hour' },
77
+ { value: 120, label: '2 hours' },
78
+ { value: 240, label: '4 hours' },
79
+ { value: 720, label: '12 hours' },
80
+ { value: 1440, label: '1 day' },
81
+ { value: 2880, label: '2 days' },
82
+ { value: 10080, label: '1 week' },
83
+ ],
84
+ },
85
+ {
86
+ key: 'maxAdvanceDays',
87
+ label: 'Book up to (days ahead)',
88
+ help: 'How far into the future customers can book.',
89
+ kind: 'number',
90
+ min: 1,
91
+ max: 730,
92
+ },
93
+ {
94
+ key: 'requirePhone',
95
+ label: 'Require a phone number',
96
+ help: 'Customers must give a phone number so you can reach them about their appointment.',
97
+ kind: 'boolean',
98
+ },
99
+ {
100
+ key: 'maxActiveBookingsPerEmail',
101
+ label: 'Upcoming bookings per email address',
102
+ help: 'Protects your calendar from spam: one email address can hold at most this many upcoming appointments.',
103
+ kind: 'number',
104
+ min: 1,
105
+ max: 50,
106
+ },
107
+ {
108
+ key: 'maxWebsiteBookingsPerHour',
109
+ label: 'Booking requests per hour (whole website)',
110
+ help: 'A safety limit against automated spam. If more requests than this arrive within an hour, new visitors are asked to try later or contact you. Raise it temporarily during a promotion.',
111
+ kind: 'number',
112
+ min: 1,
113
+ max: 1000,
114
+ },
115
+ ],
116
+ };
117
+ export const EMAIL_GROUP = {
118
+ id: 'email',
119
+ title: 'Email settings',
120
+ intro: 'How booking emails reach you and your customers.',
121
+ fields: [
122
+ {
123
+ key: 'ownerNotificationEmail',
124
+ label: 'Send new-request alerts to',
125
+ help: 'Where you are told about each new request. Leave empty to use your public business email; with neither, nobody is told.',
126
+ kind: 'email',
127
+ maxLength: 254,
128
+ },
129
+ {
130
+ key: 'verificationWindowMinutes',
131
+ label: 'Time to enter the email code',
132
+ help: 'How long a customer has to type the code from their email. Their chosen time is held for them meanwhile, then released.',
133
+ kind: 'select',
134
+ options: [5, 10, 15, 20, 30].map((m) => ({ value: m, label: `${m} minutes` })),
135
+ },
136
+ {
137
+ key: 'maxVerificationEmailsPerDay',
138
+ label: 'Code emails per day (whole website)',
139
+ help: 'Protects your email budget from abuse. The default fits Resend’s free plan (100 emails a day in total). Raise it on a paid email plan.',
140
+ kind: 'number',
141
+ min: 1,
142
+ max: 5000,
143
+ },
144
+ ],
145
+ };
146
+ export const CURRENCY_SUGGESTIONS = ['USD', 'EUR', 'GBP', 'CAD', 'AUD', 'CHF', 'MAD', 'AED', 'INR', 'JPY', 'BRL', 'MXN'];
@@ -0,0 +1,93 @@
1
+ Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font.git) GeistMono-Italic[wght].ttf: Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font.git)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,93 @@
1
+ Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font) Geist-Italic[wght].ttf: Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,66 @@
1
+ /** The dashboard's names for its icons, mapped to Lucide's. */
2
+ declare const NAMES: {
3
+ readonly today: "sun";
4
+ readonly bookings: "calendar-days";
5
+ readonly website: "globe";
6
+ readonly services: "list";
7
+ readonly hours: "clock";
8
+ readonly email: "mail";
9
+ readonly policies: "shield-check";
10
+ readonly business: "building";
11
+ readonly more: "ellipsis";
12
+ readonly sun: "sun";
13
+ readonly moon: "moon";
14
+ readonly system: "monitor";
15
+ readonly account: "circle-user-round";
16
+ readonly signout: "log-out";
17
+ readonly external: "arrow-up-right";
18
+ readonly arrow: "arrow-right";
19
+ readonly check: "check";
20
+ readonly close: "x";
21
+ readonly search: "search";
22
+ readonly add: "plus";
23
+ readonly edit: "pencil";
24
+ readonly remove: "trash";
25
+ readonly copy: "copy";
26
+ readonly upload: "upload";
27
+ readonly preview: "eye";
28
+ readonly send: "send";
29
+ readonly retry: "refresh-cw";
30
+ readonly reset: "rotate-ccw";
31
+ readonly up: "chevron-up";
32
+ readonly down: "chevron-down";
33
+ readonly left: "chevron-left";
34
+ readonly right: "chevron-right";
35
+ readonly 'move-up': "arrow-up";
36
+ readonly 'move-down': "arrow-down";
37
+ readonly phone: "phone";
38
+ readonly hold: "hourglass";
39
+ readonly timer: "timer";
40
+ readonly note: "message-square-text";
41
+ readonly closure: "calendar-off";
42
+ readonly online: "calendar-check";
43
+ readonly schedule: "calendar-clock";
44
+ readonly morning: "sunrise";
45
+ readonly 'mail-ok': "mail-check";
46
+ readonly 'mail-problem': "mail-warning";
47
+ readonly info: "info";
48
+ readonly warning: "triangle-alert";
49
+ readonly error: "circle-alert";
50
+ readonly success: "circle-check";
51
+ readonly checklist: "list-checks";
52
+ readonly inbox: "inbox";
53
+ readonly image: "image";
54
+ readonly connect: "plug";
55
+ readonly database: "database";
56
+ readonly denied: "shield-alert";
57
+ readonly lock: "lock-keyhole";
58
+ };
59
+ export type IconName = keyof typeof NAMES;
60
+ export type IconSize = 16 | 18 | 20;
61
+ export declare function Icon({ name, size, label }: {
62
+ name: IconName;
63
+ size?: IconSize;
64
+ label?: string;
65
+ }): import("react").JSX.Element;
66
+ export {};
@@ -0,0 +1,72 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // The dashboard's icons: Lucide (ISC licence, see lucide.generated.ts), inlined
3
+ // at build time. One stroke width; sizes 16 (inline, buttons, navigation),
4
+ // 18 (headers) and 20 (phone tab bar, empty states). Decorative unless a
5
+ // `label` is given: every other use sits next to visible text.
6
+ import { createElement } from 'react';
7
+ import { LUCIDE } from './lucide.generated.js';
8
+ /** The dashboard's names for its icons, mapped to Lucide's. */
9
+ const NAMES = {
10
+ // Navigation
11
+ today: 'sun',
12
+ bookings: 'calendar-days',
13
+ website: 'globe',
14
+ services: 'list',
15
+ hours: 'clock',
16
+ email: 'mail',
17
+ policies: 'shield-check',
18
+ business: 'building',
19
+ more: 'ellipsis',
20
+ // Appearance and account
21
+ sun: 'sun',
22
+ moon: 'moon',
23
+ system: 'monitor',
24
+ account: 'circle-user-round',
25
+ signout: 'log-out',
26
+ // Actions
27
+ external: 'arrow-up-right',
28
+ arrow: 'arrow-right',
29
+ check: 'check',
30
+ close: 'x',
31
+ search: 'search',
32
+ add: 'plus',
33
+ edit: 'pencil',
34
+ remove: 'trash',
35
+ copy: 'copy',
36
+ upload: 'upload',
37
+ preview: 'eye',
38
+ send: 'send',
39
+ retry: 'refresh-cw',
40
+ reset: 'rotate-ccw',
41
+ up: 'chevron-up',
42
+ down: 'chevron-down',
43
+ left: 'chevron-left',
44
+ right: 'chevron-right',
45
+ 'move-up': 'arrow-up',
46
+ 'move-down': 'arrow-down',
47
+ phone: 'phone',
48
+ // Meaning
49
+ hold: 'hourglass',
50
+ timer: 'timer',
51
+ note: 'message-square-text',
52
+ closure: 'calendar-off',
53
+ online: 'calendar-check',
54
+ schedule: 'calendar-clock',
55
+ morning: 'sunrise',
56
+ 'mail-ok': 'mail-check',
57
+ 'mail-problem': 'mail-warning',
58
+ info: 'info',
59
+ warning: 'triangle-alert',
60
+ error: 'circle-alert',
61
+ success: 'circle-check',
62
+ checklist: 'list-checks',
63
+ inbox: 'inbox',
64
+ image: 'image',
65
+ connect: 'plug',
66
+ database: 'database',
67
+ denied: 'shield-alert',
68
+ lock: 'lock-keyhole',
69
+ };
70
+ export function Icon({ name, size = 16, label }) {
71
+ return (_jsx("svg", { className: "pbe-icon", width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.75, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": label ? undefined : true, role: label ? 'img' : undefined, "aria-label": label, focusable: "false", children: LUCIDE[NAMES[name]].map(([tag, attributes], i) => createElement(tag, { key: i, ...attributes })) }));
72
+ }
@@ -0,0 +1,58 @@
1
+ import { type DragEvent, type ReactNode } from 'react';
2
+ import type { EngineError, Result, UploadedSiteImage } from '../types.js';
3
+ /** What the owner may upload, in words. */
4
+ export declare const IMAGE_TYPES_TEXT = "JPEG, PNG, WebP or AVIF";
5
+ /** What happens to an upload, in words (the engine's image preparation). */
6
+ export declare const IMAGE_PREPARATION_TEXT = "Large images are scaled down; photos lose hidden data such as where they were taken.";
7
+ export interface ImageUpload {
8
+ busy: boolean;
9
+ /** The last upload's problem (INVALID_INPUT messages are written for the owner). */
10
+ error: EngineError | null;
11
+ /** Open the file chooser. */
12
+ choose: () => void;
13
+ /** Upload a file (from the chooser or a drop). */
14
+ take: (file: File | null | undefined) => void;
15
+ clearError: () => void;
16
+ /** The hidden file input: render it once, inside the field. */
17
+ input: ReactNode;
18
+ /** Drag-and-drop handlers for any element that accepts a dropped image. */
19
+ dropTarget: {
20
+ onDragEnter: (e: DragEvent<HTMLElement>) => void;
21
+ onDragOver: (e: DragEvent<HTMLElement>) => void;
22
+ onDragLeave: (e: DragEvent<HTMLElement>) => void;
23
+ onDrop: (e: DragEvent<HTMLElement>) => void;
24
+ };
25
+ /** True while a file is dragged over the drop target. */
26
+ over: boolean;
27
+ }
28
+ export declare function useImageUpload(upload: (file: Blob) => Promise<Result<UploadedSiteImage>>, onUploaded: (image: UploadedSiteImage) => void): ImageUpload;
29
+ /**
30
+ * A fixed-ratio frame for an image (object-fit: cover), so a photo of any
31
+ * shape keeps the layout; the image is decorative here (its description, if
32
+ * any, is edited next to it).
33
+ */
34
+ export declare function ImageFrame({ src, ratio, className, empty, width, height, }: {
35
+ src: string | null;
36
+ /** Width / height, e.g. 4 / 3 (the stylesheet's default) or 1. */
37
+ ratio?: number;
38
+ className?: string;
39
+ /** What an empty frame shows. */
40
+ empty?: ReactNode;
41
+ width?: number | null;
42
+ height?: number | null;
43
+ }): import("react").JSX.Element;
44
+ /** An upload's problem, under the field (announced when it appears). */
45
+ export declare function UploadProblem({ error, id }: {
46
+ error: EngineError | null;
47
+ id?: string;
48
+ }): import("react").JSX.Element | null;
49
+ /**
50
+ * The empty state of an image field: one large button that opens the file
51
+ * chooser (Enter / Space) and also takes a dropped file.
52
+ */
53
+ export declare function ImageDropZone({ upload, title, hint, describedBy, }: {
54
+ upload: ImageUpload;
55
+ title: string;
56
+ hint: ReactNode;
57
+ describedBy?: string;
58
+ }): import("react").JSX.Element;
@@ -0,0 +1,111 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // Image uploads, shared by the Website editor's image fields and the service
3
+ // photo field: one file chooser, one upload state, one preview frame, one drop
4
+ // target and one way of showing a problem. The engine checks, scales and
5
+ // uploads the file (uploadSiteImage / uploadServiceImage); these pieces only
6
+ // collect it and show what happened.
7
+ import { useEffect, useId, useRef, useState } from 'react';
8
+ import { SITE_IMAGE_TYPES } from '../content/image.js';
9
+ import { Icon } from './icons.js';
10
+ /** What the owner may upload, in words. */
11
+ export const IMAGE_TYPES_TEXT = 'JPEG, PNG, WebP or AVIF';
12
+ /** What happens to an upload, in words (the engine's image preparation). */
13
+ export const IMAGE_PREPARATION_TEXT = 'Large images are scaled down; photos lose hidden data such as where they were taken.';
14
+ const carriesFiles = (e) => Array.from(e.dataTransfer?.types ?? []).includes('Files');
15
+ export function useImageUpload(upload, onUploaded) {
16
+ const inputRef = useRef(null);
17
+ const [busy, setBusy] = useState(false);
18
+ const [error, setError] = useState(null);
19
+ const [over, setOver] = useState(false);
20
+ const done = useRef(onUploaded);
21
+ done.current = onUploaded;
22
+ const alive = useRef(true);
23
+ useEffect(() => {
24
+ alive.current = true;
25
+ return () => {
26
+ alive.current = false;
27
+ };
28
+ }, []);
29
+ async function run(file) {
30
+ setBusy(true);
31
+ setError(null);
32
+ const r = await upload(file);
33
+ if (!alive.current)
34
+ return;
35
+ setBusy(false);
36
+ if (!r.ok) {
37
+ setError(r.error);
38
+ return;
39
+ }
40
+ done.current(r.data);
41
+ }
42
+ const take = (file) => {
43
+ if (file && !busy)
44
+ void run(file);
45
+ };
46
+ return {
47
+ busy,
48
+ error,
49
+ choose: () => {
50
+ if (!busy)
51
+ inputRef.current?.click();
52
+ },
53
+ take,
54
+ clearError: () => setError(null),
55
+ input: (_jsx("input", { ref: inputRef, type: "file", accept: SITE_IMAGE_TYPES.join(','), className: "pbe-sr-only", tabIndex: -1, "aria-hidden": "true", onChange: (e) => {
56
+ const file = e.target.files?.[0];
57
+ e.target.value = '';
58
+ take(file);
59
+ } })),
60
+ dropTarget: {
61
+ onDragEnter: (e) => {
62
+ if (!carriesFiles(e))
63
+ return;
64
+ e.preventDefault();
65
+ setOver(true);
66
+ },
67
+ onDragOver: (e) => {
68
+ if (!carriesFiles(e))
69
+ return;
70
+ e.preventDefault();
71
+ e.dataTransfer.dropEffect = 'copy';
72
+ },
73
+ onDragLeave: (e) => {
74
+ // Leaving for a child of the target is not leaving the target.
75
+ if (e.currentTarget.contains(e.relatedTarget))
76
+ return;
77
+ setOver(false);
78
+ },
79
+ onDrop: (e) => {
80
+ if (!carriesFiles(e))
81
+ return;
82
+ e.preventDefault();
83
+ setOver(false);
84
+ take(e.dataTransfer.files?.[0]);
85
+ },
86
+ },
87
+ over,
88
+ };
89
+ }
90
+ /**
91
+ * A fixed-ratio frame for an image (object-fit: cover), so a photo of any
92
+ * shape keeps the layout; the image is decorative here (its description, if
93
+ * any, is edited next to it).
94
+ */
95
+ export function ImageFrame({ src, ratio, className, empty, width, height, }) {
96
+ return (_jsx("div", { className: `pbe-image-preview${className ? ` ${className}` : ''}`, style: ratio ? { aspectRatio: String(ratio) } : undefined, children: src ? (_jsx("img", { src: src, alt: "", width: width ?? undefined, height: height ?? undefined, decoding: "async" })) : ((empty ?? (_jsxs("span", { className: "pbe-image-empty", children: [_jsx(Icon, { name: "image", size: 20 }), "No image"] })))) }));
97
+ }
98
+ /** An upload's problem, under the field (announced when it appears). */
99
+ export function UploadProblem({ error, id }) {
100
+ if (!error)
101
+ return null;
102
+ return (_jsxs("p", { className: "pbe-field-error", id: id, role: "alert", children: [_jsx(Icon, { name: "error" }), error.message] }));
103
+ }
104
+ /**
105
+ * The empty state of an image field: one large button that opens the file
106
+ * chooser (Enter / Space) and also takes a dropped file.
107
+ */
108
+ export function ImageDropZone({ upload, title, hint, describedBy, }) {
109
+ const id = useId();
110
+ return (_jsxs("button", { type: "button", className: `pbe-dropzone${upload.over ? ' pbe-dropzone--over' : ''}`, "aria-labelledby": `${id}-title`, "aria-describedby": [`${id}-hint`, describedBy].filter(Boolean).join(' '), "aria-busy": upload.busy || undefined, onClick: upload.choose, ...upload.dropTarget, children: [_jsx("span", { className: "pbe-dropzone-icon", "aria-hidden": "true", children: upload.busy ? _jsx("span", { className: "pbe-spinner" }) : _jsx(Icon, { name: "upload", size: 18 }) }), _jsx("span", { className: "pbe-dropzone-title", id: `${id}-title`, children: upload.busy ? 'Uploading…' : title }), _jsx("span", { className: "pbe-dropzone-hint", id: `${id}-hint`, children: hint })] }));
111
+ }
@@ -0,0 +1,6 @@
1
+ export { BookingAdmin } from './BookingAdmin.js';
2
+ export type { Appearance, BookingAdminProps } from './BookingAdmin.js';
3
+ export { ADMIN_SECTIONS } from './sections.js';
4
+ export type { AdminSection } from './sections.js';
5
+ export { BUSINESS_GROUP, POLICY_GROUP } from './fields.js';
6
+ export type { SettingField, SettingGroup } from './fields.js';
@@ -0,0 +1,6 @@
1
+ // @profitstudio/booking-engine/admin — the packaged admin dashboard (React).
2
+ // Mount on its own page, e.g. admin/index.html → <BookingAdmin engine={engine} />,
3
+ // and import '@profitstudio/booking-engine/admin.css' once.
4
+ export { BookingAdmin } from './BookingAdmin.js';
5
+ export { ADMIN_SECTIONS } from './sections.js';
6
+ export { BUSINESS_GROUP, POLICY_GROUP } from './fields.js';