@opkod-france/strapi-plugin-opening-hours 1.0.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/README.md +139 -0
- package/dist/_chunks/OpeningHoursInput-D-td87fX.js +732 -0
- package/dist/_chunks/OpeningHoursInput-lDHRcMXu.mjs +714 -0
- package/dist/_chunks/en-CuIn-o3X.js +68 -0
- package/dist/_chunks/en-lTUTjTNl.mjs +68 -0
- package/dist/_chunks/index-Cc3lqJgR.js +107 -0
- package/dist/_chunks/index-D_gywVTC.mjs +108 -0
- package/dist/admin/index.js +3 -0
- package/dist/admin/index.mjs +4 -0
- package/dist/server/index.js +12 -0
- package/dist/server/index.mjs +13 -0
- package/package.json +69 -0
- package/strapi-server.js +3 -0
package/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Strapi Plugin: Opening Hours
|
|
2
|
+
|
|
3
|
+
A custom field plugin for [Strapi v5](https://strapi.io) that provides a rich UI for managing business opening hours, split shifts, and special/holiday schedules.
|
|
4
|
+
|
|
5
|
+
The JSON output follows [Schema.org OpeningHoursSpecification](https://schema.org/OpeningHoursSpecification) conventions for SEO interoperability.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Weekly schedule** with per-day open/closed toggle
|
|
10
|
+
- **Split shifts** — multiple time slots per day (e.g. lunch + dinner)
|
|
11
|
+
- **Copy hours** from one day to weekdays or all days
|
|
12
|
+
- **Special/holiday hours** with date ranges and labels
|
|
13
|
+
- **Preview tab** for read-only formatted display
|
|
14
|
+
- **Schema.org compatible** JSON structure
|
|
15
|
+
- Built entirely with **Strapi Design System** components
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install strapi-plugin-opening-hours
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Add the plugin to your Strapi config:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
// config/plugins.ts
|
|
27
|
+
export default () => ({
|
|
28
|
+
'opening-hours': {
|
|
29
|
+
enabled: true,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Rebuild your Strapi admin panel:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm run build
|
|
38
|
+
npm run develop
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
1. Open the **Content-Type Builder**
|
|
44
|
+
2. Add a new custom field and select **Opening Hours**
|
|
45
|
+
3. Save the content type
|
|
46
|
+
4. The field appears in the content editor with three tabs: **Regular Hours**, **Special Hours**, and **Preview**
|
|
47
|
+
|
|
48
|
+
## JSON Structure
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"regularHours": [
|
|
53
|
+
{
|
|
54
|
+
"dayOfWeek": "Monday",
|
|
55
|
+
"isOpen": true,
|
|
56
|
+
"timeSlots": [
|
|
57
|
+
{ "opens": "09:00", "closes": "12:00" },
|
|
58
|
+
{ "opens": "14:00", "closes": "18:00" }
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"dayOfWeek": "Sunday",
|
|
63
|
+
"isOpen": false,
|
|
64
|
+
"timeSlots": []
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"specialHours": [
|
|
68
|
+
{
|
|
69
|
+
"label": "Christmas Day",
|
|
70
|
+
"validFrom": "2025-12-25",
|
|
71
|
+
"validThrough": "2025-12-25",
|
|
72
|
+
"isOpen": false,
|
|
73
|
+
"timeSlots": []
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Fields:**
|
|
80
|
+
|
|
81
|
+
| Field | Type | Description |
|
|
82
|
+
|-------|------|-------------|
|
|
83
|
+
| `dayOfWeek` | string | Schema.org day name (Monday–Sunday) |
|
|
84
|
+
| `isOpen` | boolean | Whether the business is open |
|
|
85
|
+
| `timeSlots` | array | Time ranges; empty when closed |
|
|
86
|
+
| `opens` / `closes` | string | HH:MM in 24-hour format |
|
|
87
|
+
| `label` | string | Name for special hours entry |
|
|
88
|
+
| `validFrom` / `validThrough` | string | ISO date (YYYY-MM-DD) |
|
|
89
|
+
|
|
90
|
+
## Development
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Install dependencies
|
|
94
|
+
npm install
|
|
95
|
+
|
|
96
|
+
# Build the plugin
|
|
97
|
+
npm run build
|
|
98
|
+
|
|
99
|
+
# Watch mode (rebuilds on changes)
|
|
100
|
+
npm run watch
|
|
101
|
+
|
|
102
|
+
# Run tests
|
|
103
|
+
npm test
|
|
104
|
+
|
|
105
|
+
# Run tests in watch mode
|
|
106
|
+
npm run test:watch
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Local development with a Strapi project
|
|
110
|
+
|
|
111
|
+
Link the plugin for local testing:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# In the plugin directory
|
|
115
|
+
npm link
|
|
116
|
+
|
|
117
|
+
# In your Strapi project
|
|
118
|
+
npm link strapi-plugin-opening-hours
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Add the plugin with an explicit resolve path in `config/plugins.ts`:
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
export default () => ({
|
|
125
|
+
'opening-hours': {
|
|
126
|
+
enabled: true,
|
|
127
|
+
resolve: './node_modules/strapi-plugin-opening-hours',
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Requirements
|
|
133
|
+
|
|
134
|
+
- Strapi v5
|
|
135
|
+
- Node.js 18+
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
MIT
|