Skip to content

Commit 9c9e59e

Browse files
authored
Refactored examples demo app (#1097)
* refactored examples . * chlog * bash -> sh for CSB * github.dev
1 parent d795e5f commit 9c9e59e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1450
-933
lines changed

.devcontainer/devcontainer.json

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"image": "mcr.microsoft.com/devcontainers/universal:2",
3+
"features": {
4+
},
5+
6+
"customizations": {
7+
"codespaces": {
8+
"openFiles": [
9+
"README.md",
10+
"packages/examples/src/demo/index.tsx"
11+
]
12+
}
13+
},
14+
15+
"postCreateCommand": "./scripts/nvms.sh pnpm install",
16+
"postAttachCommand": {
17+
"server": "./scripts/nvms.sh pnpm start"
18+
},
19+
20+
"forwardPorts": [
21+
3001,
22+
5174,
23+
5175,
24+
3002
25+
],
26+
"portsAttributes": {
27+
"3001": {
28+
"label": "Examples app",
29+
"onAutoForward": "openPreview"
30+
},
31+
"3002": {
32+
"label": "Sandbox Next.js",
33+
"onAutoForward": "openPreview"
34+
},
35+
"5174": {
36+
"label": "Sandbox simple",
37+
"onAutoForward": "openPreview"
38+
},
39+
"5175": {
40+
"label": "Sandbox",
41+
"onAutoForward": "openPreview"
42+
}
43+
}
44+
}

.vscode/extensions.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"actboy168.tasks"
4+
]
5+
}

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Fixed `Utils.isValidTree` for prod build.
44
Removed `checkTree`, `isValidTree` from `Utils.Import` and `getTreeBadFields` from `Utils.TreeUtils`. (PR #1091) (issue #1075)
55
- Use pnpm 8
6+
- Refactored examples demo app (PR #1097)
67
- 6.6.2
78
- Fixed issue with rendering func select inside func (PR #1086) (issue #1085)
89
- Added `DefaultUtils` typings to `index.d.ts` (PR #1078) (issue #1079)

CONFIG.adoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ endif::[]
1414
:i18n: https://github.com/ukrbublik/react-awesome-query-builder/#i18n
1515
:config1: https://github.com/ukrbublik/react-awesome-query-builder/tree/master/packages/sandbox_simple/src/demo/config.jsx
1616
:config2: https://github.com/ukrbublik/react-awesome-query-builder/tree/master/packages/sandbox/src/demo/config.tsx
17-
:config3: https://github.com/ukrbublik/react-awesome-query-builder/tree/master/packages/examples/demo/config.tsx
17+
:config3: https://github.com/ukrbublik/react-awesome-query-builder/tree/master/packages/examples/src/demo/config/index.tsx
1818
:funcs: https://github.com/ukrbublik/react-awesome-query-builder/tree/master/packages/core/modules/config/funcs.js
1919
:renderSwitch: https://github.com/ukrbublik/react-awesome-query-builder/blob/master/packages/antd/modules/config/index.jsx#L54
2020
:config_ser: https://github.com/ukrbublik/react-awesome-query-builder/blob/master/packages/sandbox_next/lib/config_ser.js
@@ -235,7 +235,7 @@ Example:
235235
|fieldSettings.useAsyncSearch |- for `select` widget |false |If true, `asyncFetch` supports search.
236236
|fieldSettings.useLoadMore |- for `select` widget |false |If true, `asyncFetch` supports pagination.
237237
|defaultValue | | |Default value
238-
|preferWidgets | | |See usecase at {config3}[`examples/demo`] for `slider` field. +
238+
|preferWidgets | | |See usecase at {config3}[`packages/examples/src/demo/config`] for `slider` field. +
239239
Its type is `number`. There are 3 widgets defined for number type: `number`, `slider`, `rangeslider`. +
240240
So setting `preferWidgets: ['slider', 'rangeslider']` will force rendering slider, and setting `preferWidgets: ['number']` will render number input.
241241
|operators, defaultOperator, widgets, valueSources | | |You can override config of corresponding type (see below at section link:#configtypes[config.types])
@@ -576,7 +576,7 @@ There is also special `proximity` operator, its options are rendered with `<Prox
576576
import {CustomOperators: {ProximityOperator}} from '@react-awesome-query-builder/ui';
577577
----
578578
579-
See {config3}[`examples/demo`]
579+
See {config3}[`packages/examples/src/demo/config`]
580580
====
581581

582582

@@ -720,7 +720,7 @@ To enable this feature set `valueSources` of type to `['value', 'func']` (see be
720720
|valueSources | |keys of `valueSourcesInfo` at link:#configsettings[config.settings] |Array with values `'value'`, `'field'`, `'func'`. If `'value'` is included, you can compare field with values. If `'field'` is included, you can compare field with another field of same type. If `'func'` is included, you can compare field with result of function (see link:#configfuncs[config.funcs]).
721721
|defaultOperator | | |If specified, it will be auto selected when user selects field
722722
|widgets.* |+ | |Available widgets for current type and their config. +
723-
Normally there is only 1 widget per type. But see type `number` at {config3}[`examples/demo`] - it has 3 widgets `number`, `slider`, `rangeslider`. +
723+
Normally there is only 1 widget per type. But see type `number` at {config3}[`packages/examples/src/demo/config`] - it has 3 widgets `number`, `slider`, `rangeslider`. +
724724
Or see type `select` - it has widget `select` for operator `=` and widget `multiselect` for operator `IN`.
725725
|widgets.<widget>.operators | | |List of operators for widget, described in link:#configoperators[config.operators]
726726
|widgets.<widget>.widgetProps | | |Can be used to override config of corresponding widget specified in link:#configwidgets[config.widgets]. Example: `{timeFormat: 'h:mm:ss A'}` for time field with AM/PM.

CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ Or with VSCode:
5555
- [`packages/bootstrap`](/packages/bootstrap) - Provides config with [Bootstrap](https://reactstrap.github.io/) widgets
5656
- [`packages/fluent`](/packages/fluent) - Provides config with [Fluent UI](https://developer.microsoft.com/en-us/fluentui#/get-started/web) widgets
5757
- [`packages/examples`](/packages/examples) - Demo app with hot reload of demo code and local library code, uses TS, uses complex config to demonstrate anvanced usage.
58-
- [`demo`](/packages/examples/demo) - Advanced demo
59-
- [`demo_switch`](/packages/examples/demo_switch) - Demo of ternary mode (switch/case) for SpEL
58+
- [`src/demo`](/packages/examples/src/demo) - Advanced demo
59+
- [`src/demo_switch`](/packages/examples/src/demo_switch) - Demo of ternary mode (switch/case)
6060
- [`packages/sandbox`](/packages/sandbox) - Demo app with hot reload of only demo code (uses latest version of library from npm), uses TS, uses AntDesign widgets.
6161
- [`packages/sandbox_simple`](/packages/sandbox_simple) - Demo app with hot reload of only demo code (uses latest version of library from npm), not uses TS, uses vanilla widgets.
6262
- [`packages/sandbox_next`](/packages/sandbox_next) - Demo app on Next.js with SSR, simple server-side query storage and export
@@ -93,7 +93,7 @@ Currently there are 5 collections of widgets:
9393
Let's say you want to create new collection of widgets for new UI framework X to be used in this lib (and submit PR which is always welcomed!).
9494
You can use any of this packages as a skeleton, eg. [mui](/packages/mui). I don't recommend to take [antd](/packages/antd) as example as it's more complicated.
9595
Create new package `@react-awesome-query-builder/x` in [packages](/packages).
96-
For a playground integrate it in [examples](/packages/examples) - add to `dependecies` in [package.json](/packages/examples/package.json), `paths` in [tsconfig.json](/packages/examples/tsconfig.json), `aliases` in [webpack.config.js](/packages/examples/webpack.config.js), `skinToConfig` in [config.tsx](/packages/examples/demo/config.tsx).
96+
For a playground integrate it in [examples](/packages/examples) - add to `dependecies` in [package.json](/packages/examples/package.json), `paths` in [tsconfig.json](/packages/examples/tsconfig.json), `aliases` in [webpack.config.js](/packages/examples/webpack.config.js), `skinToConfig` in [config.tsx](/packages/examples/src/demo/config/index.tsx).
9797

9898
Take [PR #727 to add Fluent UI widgets](https://github.com/ukrbublik/react-awesome-query-builder/pull/727) as an example.
9999

README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Now [Fluent UI](https://developer.microsoft.com/en-us/fluentui#/get-started/web)
2828
See [live demo](https://ukrbublik.github.io/react-awesome-query-builder)
2929

3030
[![Edit in codesandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/p/github/ukrbublik/react-awesome-query-builder/master?file=%2Fpackages%2Fexamples%2Fdemo%2Findex.tsx)
31+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/ukrbublik/react-awesome-query-builder)
3132

3233

3334
* [Features](#features)
@@ -238,7 +239,7 @@ class DemoQueryBuilder extends Component {
238239
)
239240

240241
onChange = (immutableTree, config) => {
241-
// Tip: for better performance you can apply `throttle` - see `examples/demo`
242+
// Tip: for better performance you can apply `throttle` - see `packages/examples/src/demo`
242243
this.setState({tree: immutableTree, config: config});
243244

244245
const jsonTree = QbUtils.getTree(immutableTree);
@@ -319,7 +320,7 @@ const DemoQueryBuilder: React.FC = () => {
319320
});
320321

321322
const onChange = useCallback((immutableTree: ImmutableTree, config: Config) => {
322-
// Tip: for better performance you can apply `throttle` - see `examples/demo`
323+
// Tip: for better performance you can apply `throttle` - see `packages/examples/src/demo`
323324
setState(prevState => ({ ...prevState, tree: immutableTree, config: config }));
324325

325326
const jsonTree = QbUtils.getTree(immutableTree);
@@ -395,7 +396,7 @@ Props:
395396
- If you put query builder component inside [Fluent-UI](https://developer.microsoft.com/en-us/fluentui)'s `<Panel />`, please:
396397
- set css `.ms-Layer.ms-Layer--fixed.root-119 { z-index: 900 !important; }`
397398
- `props` arg in `renderBuilder` have `actions` and `dispatch` you can use to run actions programmatically
398-
- For a list of available actions see `Actions` interface in [`index.d.ts`](/packages/core/modules/index.d.ts). See `runActions()` in [examples](/packages/examples/demo/index.tsx) as a demonstration of calling actions programmatically.
399+
- For a list of available actions see `Actions` interface in [`index.d.ts`](/packages/core/modules/index.d.ts). See `runActions()` in [examples](/packages/examples/src/demo/index.tsx) as a demonstration of calling actions programmatically.
399400

400401
## `<Builder />`
401402

@@ -617,7 +618,7 @@ const config = {
617618
// then use <Query {...config} />
618619
```
619620

620-
See [example](/packages/examples/demo/index.tsx).
621+
See [example](/packages/examples/src/demo/index.tsx).
621622

622623

623624
## Ternary mode
@@ -660,7 +661,7 @@ const emptyJson: JsonSwitchGroup = { id: QbUtils.uuid(), type: "switch_group", }
660661
const tree = QbUtils.loadTree(emptyJson);
661662
```
662663

663-
See [example](/packages/examples/demo_switch/index.tsx)
664+
See [example](/packages/examples/src/demo_switch/index.tsx)
664665

665666
![Screenshot](https://github.com/ukrbublik/react-awesome-query-builder/assets/3238637/4bf87da5-47f2-4a64-b1be-8924a62f96ad)
666667

0 commit comments

Comments
 (0)