@ng-formworks/daisyui 15.2.7
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 +176 -0
- package/css_names_extractor.js +133 -0
- package/ng-package.json +14 -0
- package/package.json +59 -0
- package/src/daisyui_class_names.css +1 -0
- package/src/daisyui_class_names_prefixed_tw.css +1 -0
- package/src/daisyui_class_names_prefixed_tw_dui.css +1 -0
- package/src/lib/daisui-cssframework.ts +237 -0
- package/src/lib/daisyui-framework.component.scss +48 -0
- package/src/lib/daisyui-framework.component.spec.ts +21 -0
- package/src/lib/daisyui-framework.component.ts +70 -0
- package/src/lib/daisyui-framework.module.ts +39 -0
- package/src/lib/daisyui-framework.prefixed.component.scss +48 -0
- package/src/lib/daisyui-framework.prefixed.component.ts +70 -0
- package/src/lib/daisyui-framework.service.spec.ts +16 -0
- package/src/lib/daisyui-framework.service.ts +9 -0
- package/src/lib/daisyui-ng-formworks-themes-prefixed.scss +61 -0
- package/src/lib/daisyui-ng-formworks-themes.scss +61 -0
- package/src/lib/daisyui.framework.ts +36 -0
- package/src/lib/tailwind-output-prefixed.scss +11772 -0
- package/src/lib/tailwind-output.scss +11402 -0
- package/src/lib/tokens.defs.ts +10 -0
- package/src/lib/widgets/daisyui-tabs.component.ts +92 -0
- package/src/public-api.ts +12 -0
- package/tailwind-input.css +3 -0
- package/tailwind.config.js +24 -0
- package/tailwind.prefixed.config.js +26 -0
- package/tsconfig.lib.json +21 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +14 -0
package/README.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# @ng-formworks/daisyui
|
|
2
|
+
This module is a dependency of the [ng-formworks project][npm_core_ver] and is meant to work as a framework installation module for using DaisyUI in the forms.
|
|
3
|
+
|
|
4
|
+
## Getting started
|
|
5
|
+
|
|
6
|
+
If you are unfamiliar with with the ng-formworks project, it is highly recommended to
|
|
7
|
+
first have a look at the [@ng-formworks pages][npm_core_ver] for examples, demos, options and documentation.
|
|
8
|
+
|
|
9
|
+
## Getting started
|
|
10
|
+
|
|
11
|
+
```shell
|
|
12
|
+
npm install @ng-formworks/core@latest @ng-formworks/cssframework@latest @ng-formworks/daisyui@latest
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
With YARN, run the following:
|
|
16
|
+
|
|
17
|
+
```shell
|
|
18
|
+
yarn add @ng-formworks/core@latest @ng-formworks/cssframework@latest @ng-formworks/daisyui@latest
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Then import `DaisyUIFrameworkModule` in your main application module if you want to use `daisyui` UI, like this:
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
25
|
+
import { NgModule } from '@angular/core';
|
|
26
|
+
|
|
27
|
+
import { DaisyUIFrameworkModule } from '@ng-formworks/daisyui';
|
|
28
|
+
|
|
29
|
+
import { AppComponent } from './app.component';
|
|
30
|
+
|
|
31
|
+
@NgModule({
|
|
32
|
+
declarations: [ AppComponent ],
|
|
33
|
+
imports: [
|
|
34
|
+
DaisyUIFrameworkModule
|
|
35
|
+
],
|
|
36
|
+
providers: [],
|
|
37
|
+
bootstrap: [ AppComponent ]
|
|
38
|
+
})
|
|
39
|
+
export class AppModule { }
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
For basic use, after loading JsonSchemaFormModule as described above, to display a form in your Angular component, simply add the following to your component's template:
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<json-schema-form
|
|
46
|
+
loadExternalAssets="true"
|
|
47
|
+
[schema]="yourJsonSchema"
|
|
48
|
+
framework="daisyui"
|
|
49
|
+
[theme]="yourTheme"
|
|
50
|
+
(onSubmit)="yourOnSubmitFn($event)">
|
|
51
|
+
</json-schema-form>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Where `schema` is a valid JSON schema object, and `onSubmit` calls a function to process the submitted JSON form data. If you don't already have your own schemas, you can find a bunch of samples to test with in the `demo/assets/example-schemas` folder, as described above.
|
|
55
|
+
|
|
56
|
+
`framework` is for the template you want to use, the default value is `no-framwork`. The possible values are:
|
|
57
|
+
|
|
58
|
+
* `material-design` for Material Design (if installed).
|
|
59
|
+
* `bootstrap-3` for Bootstrap 3 (if installed).
|
|
60
|
+
* `bootstrap-4` for Bootstrap 4 (if installed).
|
|
61
|
+
* `bootstrap-5` for Bootstrap 5 (if installed).
|
|
62
|
+
* `daisyui` for DaisyUi.
|
|
63
|
+
* `no-framework` for (plain HTML).
|
|
64
|
+
|
|
65
|
+
`theme` is for the framework theme you want to use.
|
|
66
|
+
The possible values for this framework are:
|
|
67
|
+
|
|
68
|
+
* `daisyui_default` for the default theme.
|
|
69
|
+
* `light` for the light theme.
|
|
70
|
+
* `dark` for the dark theme.
|
|
71
|
+
* `cupcake` for the cupcake theme.
|
|
72
|
+
* `cmyk` for the cmyk theme.
|
|
73
|
+
* `pastel` for the pastel theme.
|
|
74
|
+
* `daisyui_leaf` for the leaf theme.
|
|
75
|
+
|
|
76
|
+
the list of available themes can also be gotten using the
|
|
77
|
+
FrameworkLibraryService(found in '@ng-formworks/core'):
|
|
78
|
+
```typescript
|
|
79
|
+
getFrameworkThemes()
|
|
80
|
+
```
|
|
81
|
+
method
|
|
82
|
+
|
|
83
|
+
## Custom theming
|
|
84
|
+
|
|
85
|
+
Custom theming can be achieved in two ways:
|
|
86
|
+
|
|
87
|
+
* the simplest is to overwrite the default theme(or any other themes) with css rules:
|
|
88
|
+
css changes can be made using the `data-theme` attribute selector
|
|
89
|
+
so for example to change the .btn class of the default theme, you would
|
|
90
|
+
include the following rule in your application's styles
|
|
91
|
+
|
|
92
|
+
```css
|
|
93
|
+
[data-theme="daisyui_default"] .btn {
|
|
94
|
+
border-radius: 1rem
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
* the other method is to add a new theme:
|
|
99
|
+
the first step will be to create the entire theme (see the specific frameworks underlying documentation for how this can be done) and have it use the `data-theme` attribute selector for example:
|
|
100
|
+
|
|
101
|
+
```css
|
|
102
|
+
[data-theme="daisyui_custom"] {
|
|
103
|
+
background-color: green;
|
|
104
|
+
font: 15px Arial, sans-serif;
|
|
105
|
+
.
|
|
106
|
+
.
|
|
107
|
+
.
|
|
108
|
+
}
|
|
109
|
+
[data-theme="daisyui_custom"] .btn {
|
|
110
|
+
border-color: coral;
|
|
111
|
+
.
|
|
112
|
+
.
|
|
113
|
+
.
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
after making the css available, the theme will need to be registered using the
|
|
118
|
+
FrameworkLibraryService(found in '@ng-formworks/core'):
|
|
119
|
+
for example
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
constructor(
|
|
123
|
+
.
|
|
124
|
+
private frameworkLibrary: FrameworkLibraryService,
|
|
125
|
+
.
|
|
126
|
+
.
|
|
127
|
+
) {
|
|
128
|
+
|
|
129
|
+
frameworkLibrary.registerTheme({name:'daisyui_custom',text:'DaisyUi custom theme'})
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Using default DaisyUI css class names
|
|
136
|
+
|
|
137
|
+
By default, the framework prefixes all standard DaisyUI class names with 'dui-'
|
|
138
|
+
for example '.btn' will become '.dui-btn'. The standard names can be switched back without the 'dui-' prefix if need be. To switch opf the 'dui-' prefixing, the DUIOPTIONS token value needs to be provided with the classPrefix property set to false-see code snippet below. By default the classPrefix property is true.
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
|
|
142
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
143
|
+
import { NgModule } from '@angular/core';
|
|
144
|
+
|
|
145
|
+
import {DUIOPTIONS, DaisyUIFrameworkModule } from '@ng-formworks/daisyui';
|
|
146
|
+
|
|
147
|
+
import { AppComponent } from './app.component';
|
|
148
|
+
|
|
149
|
+
@NgModule({
|
|
150
|
+
declarations: [ AppComponent ],
|
|
151
|
+
imports: [
|
|
152
|
+
DaisyUIFrameworkModule
|
|
153
|
+
],
|
|
154
|
+
providers: [
|
|
155
|
+
{ provide: DUIOPTIONS, useValue: {classPrefix:false} }
|
|
156
|
+
],
|
|
157
|
+
bootstrap: [ AppComponent ]
|
|
158
|
+
})
|
|
159
|
+
export class AppModule { }
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Code scaffolding
|
|
164
|
+
|
|
165
|
+
Run `ng generate component component-name --project @ng-formworks/daisyui` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project @ng-formworks/daisyui`.
|
|
166
|
+
> Note: Don't forget to add `--project @ng-formworks/daisyui` or else it will be added to the default project in your `angular.json` file.
|
|
167
|
+
|
|
168
|
+
## Build
|
|
169
|
+
|
|
170
|
+
Run `ng build @ng-formworks/daisyui` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
171
|
+
|
|
172
|
+
## Running unit tests
|
|
173
|
+
|
|
174
|
+
Run `ng test @ng-formworks/daisyui` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
175
|
+
|
|
176
|
+
[npm_core_ver]:https://www.npmjs.com/package/@ng-formworks/core
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* aim of this script is to extract all of the css class names that are used
|
|
3
|
+
* in daisyui, it must be supplied a stylePath
|
|
4
|
+
* (for daisyui 3.7 this is typically un der ./node_modules/daisyui/dist/full.css)
|
|
5
|
+
* and an outputFile(typically ng-formworks-daisyui/src/daisyui_class_names.css)
|
|
6
|
+
* the script will then try to enumerate all of the css class names
|
|
7
|
+
* the reason this is done is: when the tailwind cli attempts to build the
|
|
8
|
+
* tailwind-output.scss file, it will include all of the css classes that are scanned
|
|
9
|
+
* so it should also include all of the classes that were extracted into daisyui_class_names.css
|
|
10
|
+
* if build size is large, then should maybe only use this for development
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const jsdom = require("jsdom");
|
|
14
|
+
const { JSDOM } = jsdom;
|
|
15
|
+
const path = require('path');
|
|
16
|
+
const fs = require('fs').promises;
|
|
17
|
+
const minimist = require('minimist');
|
|
18
|
+
|
|
19
|
+
// Read command line arguments
|
|
20
|
+
const args = minimist(process.argv.slice(2), {
|
|
21
|
+
boolean: ['all'],
|
|
22
|
+
string: ['stylePath', 'outputPath', 'outputFormat', 'classPrefix'],
|
|
23
|
+
alias: {
|
|
24
|
+
stylePath: 's',
|
|
25
|
+
outputPath: 'o',
|
|
26
|
+
outputFormat: 'f',
|
|
27
|
+
classPrefix: 'p'
|
|
28
|
+
|
|
29
|
+
},
|
|
30
|
+
default: {
|
|
31
|
+
outputFormat: 'css', //can be json|css
|
|
32
|
+
outputPath: 'css_class_names.css'
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Check if stylePath is defined
|
|
37
|
+
if (!args.stylePath) {
|
|
38
|
+
console.error('Error: stylePath is required');
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
var htmlDoc = `
|
|
44
|
+
<!DOCTYPE html>
|
|
45
|
+
<html><meta http-equiv="content-type" content="text/html; charset=utf-8">
|
|
46
|
+
<head>
|
|
47
|
+
</head>
|
|
48
|
+
<body>
|
|
49
|
+
</body>
|
|
50
|
+
</html>
|
|
51
|
+
`
|
|
52
|
+
let stylePath = args.stylePath;
|
|
53
|
+
let cwd = process.cwd()
|
|
54
|
+
var classes;
|
|
55
|
+
fs.readFile(path.join(cwd, stylePath), { encoding: 'utf-8' }).then(readRes => {
|
|
56
|
+
let mainCss = readRes;
|
|
57
|
+
|
|
58
|
+
var dom = new JSDOM(htmlDoc, {
|
|
59
|
+
resources: "usable"
|
|
60
|
+
});
|
|
61
|
+
var doc = dom.window.document
|
|
62
|
+
var head = doc.getElementsByTagName('head')[0];
|
|
63
|
+
style = doc.createElement("style");
|
|
64
|
+
style.type = 'text/css';
|
|
65
|
+
style.innerHTML = mainCss;
|
|
66
|
+
head.appendChild(style);
|
|
67
|
+
|
|
68
|
+
classes = getClassNames(doc, args.classPrefix);
|
|
69
|
+
console.log(Object.keys(classes).length + " class names to be written");
|
|
70
|
+
let cssTxt = args.outputFormat == "json" ? JSON.stringify(classes) : classesMap2Css(classes);
|
|
71
|
+
return fs.writeFile(args.outputPath, cssTxt);
|
|
72
|
+
}).then(wfres => {
|
|
73
|
+
// Object.keys(classes).forEach(cname => {
|
|
74
|
+
// fs.write(cname + ',').then(wfres => {
|
|
75
|
+
|
|
76
|
+
// }).catch(werr => {
|
|
77
|
+
// console.log(werr);
|
|
78
|
+
// })
|
|
79
|
+
// })
|
|
80
|
+
}).catch(err => {
|
|
81
|
+
console.log(err);
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
//doc.styleSheets[0].cssRules[0].cssText
|
|
87
|
+
|
|
88
|
+
function classesMap2Css(classMap) {
|
|
89
|
+
let cssTxt = "";
|
|
90
|
+
Object.keys(classMap).forEach(cname => {
|
|
91
|
+
cssTxt += cname + " {}"
|
|
92
|
+
})
|
|
93
|
+
return cssTxt;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function getClassNames(doc, prefix) {
|
|
97
|
+
var sheet, sheets = doc.styleSheets;
|
|
98
|
+
var rule, rules;
|
|
99
|
+
var classes = {};
|
|
100
|
+
var temp;
|
|
101
|
+
var identifier =
|
|
102
|
+
/(?:[A-Za-z0-9_-]|[^\0-\237]|\\(?:[^A-Fa-f0-9]|[A-Fa-f0-9]{1,6} ?))+/;
|
|
103
|
+
var classInSelector = new RegExp('\\.(' + identifier.source + ')',
|
|
104
|
+
'gm');
|
|
105
|
+
for (var i = 0, iLen = sheets.length; i < iLen; i++) {
|
|
106
|
+
sheet = sheets[i];
|
|
107
|
+
rules = sheet.cssRules;
|
|
108
|
+
|
|
109
|
+
for (var j = 0, jLen = rules.length; j < jLen; j++) {
|
|
110
|
+
rule = rules[j];
|
|
111
|
+
|
|
112
|
+
// Get the classes
|
|
113
|
+
temp = rule.cssText.match(classInSelector)
|
|
114
|
+
//rule.cssText.match(/\.\w+/g);
|
|
115
|
+
|
|
116
|
+
if (temp) {
|
|
117
|
+
let cname = temp[0];
|
|
118
|
+
if (cname.substring(1).match(/^\d/)) {
|
|
119
|
+
cname = '\\' + cname
|
|
120
|
+
}
|
|
121
|
+
let fcname = cname;
|
|
122
|
+
if (prefix) {
|
|
123
|
+
fcname = "." + prefix + "-" + cname.split(".")[1];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
classes[fcname] = {}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Return an array of the classes
|
|
131
|
+
return classes;
|
|
132
|
+
|
|
133
|
+
}
|
package/ng-package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
|
|
3
|
+
"dest": "../../dist/@ng-formworks/daisyui",
|
|
4
|
+
"lib": {
|
|
5
|
+
"entryFile": "src/public-api.ts"
|
|
6
|
+
},
|
|
7
|
+
"assets": ["./assets"],
|
|
8
|
+
"allowedNonPeerDependencies": [
|
|
9
|
+
"lodash-es",
|
|
10
|
+
"@ng-formworks/core",
|
|
11
|
+
"@ng-formworks/cssframework",
|
|
12
|
+
"daisyui"
|
|
13
|
+
]
|
|
14
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ng-formworks/daisyui",
|
|
3
|
+
"version": "15.2.7",
|
|
4
|
+
"description": "Angular ng-formworks - JSON Schema Form builder using DaisyUI",
|
|
5
|
+
"author": "https://github.com/zahmo/ng-formworks/graphs/contributors",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"Angular",
|
|
8
|
+
"ng",
|
|
9
|
+
"Angular15",
|
|
10
|
+
"Angular 15",
|
|
11
|
+
"Angular16",
|
|
12
|
+
"Angular 16",
|
|
13
|
+
"Angular17",
|
|
14
|
+
"Angular 17",
|
|
15
|
+
"ng15",
|
|
16
|
+
"ng16",
|
|
17
|
+
"ng17",
|
|
18
|
+
"JSON Schema",
|
|
19
|
+
"form",
|
|
20
|
+
"forms",
|
|
21
|
+
"form builder",
|
|
22
|
+
"form themes",
|
|
23
|
+
"form generator",
|
|
24
|
+
"daisyui",
|
|
25
|
+
"tailwind",
|
|
26
|
+
"tailwindcss",
|
|
27
|
+
"tailwind css",
|
|
28
|
+
"ajsf",
|
|
29
|
+
"ng-formworks",
|
|
30
|
+
"ng formworks",
|
|
31
|
+
"formworks",
|
|
32
|
+
"angular json schema form"
|
|
33
|
+
],
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/zahmo/ng-formworks"
|
|
38
|
+
},
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/zahmo/ng-formworks/issues"
|
|
41
|
+
},
|
|
42
|
+
"private": false,
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@angular/common": "^17.0.0",
|
|
45
|
+
"@angular/core": "^17.0.0"
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"tslib": "^2.3.0",
|
|
50
|
+
"@ng-formworks/core": "~15.2.7",
|
|
51
|
+
"@ng-formworks/cssframework": "~15.2.7"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/lodash-es": "^4.17.6",
|
|
55
|
+
"daisyui": "^4.7.0",
|
|
56
|
+
"jsdom": "^16.7.0"
|
|
57
|
+
},
|
|
58
|
+
"sideEffects": false
|
|
59
|
+
}
|