@formique/semantq 1.0.3 → 1.0.5

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 CHANGED
@@ -42,7 +42,7 @@ Formique Semantq is a native Semantq JS framework Schema Defintion Language (SDL
42
42
  - **Mobile Responsive**: Forms are mobile responsive out of the box.
43
43
  - **Nested Dynamic Conditional Logic**: Implement complex conditional logic to show or hide form fields based on user input.
44
44
  - **Dynamic Dropdowns**: Create dropdowns whose options change dynamically based on other field selections.
45
- - **JavaScript-Driven Themes**: Apply themes dynamically using JavaScript for a customizable user interface.
45
+ - **JavaScript-Driven Themes**: Apply themes or theme colors dynamically using JavaScript for a customizable user interface.
46
46
  - **WAI-ARIA and WCAG-Compliant HTML**: Ensure all form elements are accessible and meet WCAG standards.
47
47
  - **Progressive Enhancement**: Forms function with or without JavaScript, ensuring accessibility and functionality across all environments.
48
48
 
@@ -60,14 +60,6 @@ npx sv create
60
60
  npx sv create my-app
61
61
  ```
62
62
 
63
- #### Select the following options:
64
-
65
- - **SemantqKit minimal** (optional but preferred)
66
- - **Type checking with TypeScript** (optional but preferred)
67
- - **ESLint** (optional but preferred)
68
- - **npm** (required)
69
-
70
-
71
63
  > **Note:** Always refer to the latest official Semantq guide on how to create a Semantq app, as this may change. [Semantq Documentation: Creating a Project](https://Semantq.dev/docs/kit/creating-a-project)
72
64
 
73
65
 
@@ -77,7 +69,7 @@ npx sv create my-app
77
69
  npm run dev
78
70
 
79
71
  # or start the server and open the app in a new browser tab
80
- npm run dev -- --open
72
+ npm run dev
81
73
  ```
82
74
 
83
75
 
@@ -99,15 +91,30 @@ For demo purposes, let's create a new route (page) in `src/routes/registration`.
99
91
  touch src/routes/registration/+page.Semantq
100
92
  ```
101
93
 
102
- ## Step 2: Add the CSS
94
+ ## Step 2: Add the CSS (Optional)
95
+
96
+ The NPM option:
97
+
98
+ ```javascript
99
+ npm i formique-css
100
+ ```
101
+
102
+ ```javascript
103
+ import 'formique-css';
104
+ ```
103
105
 
104
- Paste the following Formique CSS in the `<head>` section of `src/app.html`:
106
+ The CDN Option:
107
+
108
+ Include this inside the @head .. @end block of page layout file: `@layout.smq`
105
109
 
106
110
  ```html
107
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/formique-css@1.0.7/formique.min.css" formique-style>
111
+ <link rel="stylesheet" href="https://unpkg.com/formique-css@1.0.11/formique-css.css" />
108
112
  ```
109
113
 
110
- ## Step 3: Install `formique-semantq`
114
+
115
+ **Note:** The provided Formique CSS is optional. Formique will function fully without it, allowing you full flexibility to apply your own styles. However, for convenience, a set of default class names is available to help you quickly style form containers, form elements, and input types. See the sections below for a complete list of available class names.
116
+
117
+ ## Step 3: Install `@formique/semantq`
111
118
 
112
119
  To use Formique in your Semantq application, you need to install the `formique-semantq` package.
113
120
 
@@ -124,7 +131,7 @@ Add the following code to +page.Semantq:
124
131
  ```Semantq
125
132
  <script>
126
133
  import { onMount } from 'Semantq';
127
- import Formique from 'formique-semantq';
134
+ import Formique from '@formique/semantq';
128
135
 
129
136
  // Define the form schema
130
137
  const formSchema = [
@@ -184,8 +191,238 @@ Once the server is running, you can view the form at:
184
191
 
185
192
  http://localhost:5173/registration
186
193
 
187
- > **Note** If you want to use a custom target element (form container) ID, you can do so by adding the item (property) `containerId: 'element-id'` in the `formSettings` object. This is particularly useful when you need to implement multiple Formique forms on a single page.
188
- Also, note that if the target element's ID is 'formique', you do not need to declare this item (property) in the `formSettings` object.
194
+
195
+ ## 1. Styling the Form
196
+
197
+ Formique comes with a set of built-in themes to help you quickly style your forms. These themes are **headless and minimal**, allowing easy blending with your site's design system. They apply styling **primarily to the submit button background** and **the bottom border of focused inputs**, while maintaining a **light background** for most themes.
198
+
199
+ ### Available Built-in Themes:
200
+
201
+ * `light`
202
+ * `dark`
203
+ * `pink`
204
+ * `indigo`
205
+ * `dark-blue`
206
+ * `light-blue`
207
+ * `dark-orange`
208
+ * `bright-yellow`
209
+ * `green`
210
+ * `purple`
211
+ * `midnight-blush`
212
+ * `deep-blue`
213
+ * `blue`
214
+ * `brown`
215
+ * `orange`
216
+
217
+ > ⚠️ The `dark` theme is more opinionated with full dark background support. All others are intentionally minimal.
218
+
219
+ To apply a theme, set the `theme` option in your `formSettings`:
220
+
221
+ ```js
222
+ const formSettings = {
223
+ theme: 'indigo'
224
+ };
225
+ ```
226
+ If no theme is set, Formique will default to the dark theme.
227
+
228
+ ### Fine-Grained Theme Control
229
+
230
+ To override the button and focus color with your own custom color, use the `themeColor` option in hexadecimal format:
231
+
232
+ ```js
233
+ const formSettings = {
234
+ themeColor: '#327ba8' // Must be a valid hex value
235
+ };
236
+ ```
237
+
238
+ ### Custom Styling
239
+
240
+ Formique’s form classes are exposed for complete customization. You can target the form using `.formique`, and inputs with classes like `.formique-input`, `.formique-label`, `.formique-submit`. See section below.
241
+
242
+ Example:
243
+
244
+ ```css
245
+ .formique-input {
246
+ border-radius: 5px;
247
+ padding: 10px;
248
+ }
249
+ ```
250
+
251
+
252
+ ## 2. Styling and Sizing the Form Container
253
+
254
+ Formique renders inside a container `<div>` that you specify by ID.
255
+
256
+ ### Default Container
257
+
258
+ ```html
259
+ <div id="formique" class=""></div>
260
+ ```
261
+
262
+ ### ⚙Custom Container ID
263
+
264
+ You can use any custom container ID by declaring it in your `formSettings`:
265
+
266
+ ```js
267
+ const formSettings = {
268
+ formContainerId: 'myForm'
269
+ };
270
+ ```
271
+
272
+ And in your HTML:
273
+
274
+ ```html
275
+ <div id="myForm"></div>
276
+ ```
277
+
278
+ ### Built-in Container Size Classes
279
+
280
+ Formique includes several responsive width utility classes that can be used directly on your form container:
281
+
282
+ | Class Name | Description |
283
+ | -- | -- |
284
+ | `width-full` | 100% width |
285
+ | `width-half` | 50% width |
286
+ | `width-medium` | 600px fixed width |
287
+ | `width-small` | 400px fixed width |
288
+
289
+ Example:
290
+
291
+ ```html
292
+ <div id="formique" class="width-half"></div>
293
+ ```
294
+
295
+ ### Custom Inline Style Control
296
+
297
+ If you want precise control over the container styling, use the `formContainerStyle` setting:
298
+
299
+ ```js
300
+ const formSettings = {
301
+ formContainerStyle: 'width: 100%; max-width: 700px; padding: 2rem;'
302
+ };
303
+ ```
304
+
305
+ > This will override the container’s `style` attribute directly.
306
+
307
+
308
+
309
+
310
+ ## ✅ Complete List of `.formique`-Scoped CSS Classes
311
+
312
+ Here is a clean, alphabetically grouped list of **all unique CSS class selectors** used in your Formique stylesheet:
313
+
314
+ ### 📦 Container & Layout
315
+
316
+ * `.formique`
317
+ * `.formique-form`
318
+ * `.width-full`
319
+ * `.width-half`
320
+ * `.width-medium`
321
+ * `.width-small`
322
+ * `.width-custom`
323
+
324
+ ### 🏷️ Labels & Inputs
325
+
326
+ * `.form-label`
327
+ * `.form-input`
328
+ * `.form-control`
329
+ * `.form-textarea`
330
+ * `.form-select`
331
+ * `.form-select-input`
332
+ * `.form-radio-input`
333
+ * `.form-checkbox-input`
334
+
335
+ ### 📚 Input Wrappers
336
+
337
+ * `.input-block`
338
+ * `.radio-group`
339
+ * `.checkbox-group`
340
+
341
+ ### 🎨 Themes
342
+
343
+ * `.custom-theme`
344
+ * `.dark-theme`
345
+ * `.light-theme`
346
+ * `.pink-theme`
347
+ * `.indigo-theme`
348
+ * `.dark-blue-theme`
349
+ * `.light-blue-theme`
350
+ * `.dark-orange-theme`
351
+ * `.bright-yellow-theme`
352
+ * `.green-theme`
353
+ * `.purple-theme`
354
+ * `.midnight-blush-theme`
355
+ * `.deep-blue-theme`
356
+ * `.blue-theme`
357
+ * `.brown-theme`
358
+ * `.orange-theme`
359
+
360
+ ### 🚀 Button
361
+
362
+ * `.form-submit-btn`
363
+
364
+ ### 🔁 Loading
365
+
366
+ * `#formiqueSpinner`
367
+ * `.formique-spinner`
368
+ * `.formique-spinner .message`
369
+
370
+ ### Status Messages
371
+
372
+ * `.formique-success`
373
+ * `.formique-error`
374
+
375
+
376
+
377
+ ## 📬 3. Contact Form Quick Setup
378
+
379
+ Formique supports plug-and-play email contact forms using `@formique/semantq`.
380
+
381
+ ### 🔧 Basic Email Contact Setup
382
+
383
+ ```js
384
+ const formSettings = {
385
+ submitMode: 'email', // Required
386
+ submitOnPage: true, // Required
387
+ successMessage: 'Survey filled successfully', // Optional
388
+ errorMessage: 'Something went wrong', // Optional
389
+ sendTo: ['contacts@yourwebsite.com'] // Your actual email
390
+ };
391
+ ```
392
+
393
+ ### 📑 Defining a Form Schema
394
+
395
+ Create your form fields using a simple schema array:
396
+
397
+ ```js
398
+ const formSchema = [
399
+ ['text', 'name', 'Name', { required: true }],
400
+ ['text', 'surname', 'Surname', { required: true }],
401
+ ['email', 'email', 'Email', { required: true }, { style: 'color: red' }],
402
+ ['textarea', 'message', 'Your Message here', { required: true }]
403
+ ];
404
+ ```
405
+
406
+ ### Schema Syntax Recap
407
+
408
+ Each form field follows this format:
409
+
410
+ ```js
411
+ ['field type', 'field name', 'Label', { inlineValidation }, { inputAttributes }, [options]]
412
+ ```
413
+
414
+ Examples:
415
+
416
+ * `text`, `email`, `textarea`, `select`, `checkbox`, `radio`
417
+ * Inline validation can include `{ required: true }`
418
+ * Additional HTML attributes (like `style`, `placeholder`, etc.) are supported.
419
+
420
+
421
+ ## ⚠️ Domain Verification for Email Submissions
422
+
423
+ To enable email submissions, ensure your domain is **registered on your [useformique.com](https://useformique.com) account**.
424
+
425
+ This is required for sender verification and spam protection.
189
426
 
190
427
 
191
428
  For more comprehensive details on Formique's features and usage and options visit the [Formique GitHub Repository](https://github.com/Gugulethu-Nyoni/formique).